From b31a934a804aed3f35442ceafe2080b0955e7317 Mon Sep 17 00:00:00 2001 From: dcc Date: Wed, 15 May 2024 00:57:23 -0700 Subject: total rebase --- test/pleroma/http/adapter_helper/gun_test.exs | 4 +- test/pleroma/http/adapter_helper/hackney_test.exs | 2 +- test/pleroma/http/adapter_helper_test.exs | 0 test/pleroma/http/ex_aws_test.exs | 0 test/pleroma/http/request_builder_test.exs | 0 test/pleroma/http/tzdata_test.exs | 0 test/pleroma/http/web_push_test.exs | 45 +++++++++++++++++++++++ 7 files changed, 48 insertions(+), 3 deletions(-) mode change 100755 => 100644 test/pleroma/http/adapter_helper/gun_test.exs mode change 100755 => 100644 test/pleroma/http/adapter_helper/hackney_test.exs mode change 100755 => 100644 test/pleroma/http/adapter_helper_test.exs mode change 100755 => 100644 test/pleroma/http/ex_aws_test.exs mode change 100755 => 100644 test/pleroma/http/request_builder_test.exs mode change 100755 => 100644 test/pleroma/http/tzdata_test.exs create mode 100644 test/pleroma/http/web_push_test.exs (limited to 'test/pleroma/http') diff --git a/test/pleroma/http/adapter_helper/gun_test.exs b/test/pleroma/http/adapter_helper/gun_test.exs old mode 100755 new mode 100644 index 7515f4e..d567bc8 --- a/test/pleroma/http/adapter_helper/gun_test.exs +++ b/test/pleroma/http/adapter_helper/gun_test.exs @@ -36,7 +36,7 @@ defmodule Pleroma.HTTP.AdapterHelper.GunTest do assert opts[:certificates_verification] end - test "https url with non standart port" do + test "https url with non-standard port" do uri = URI.parse("https://example.com:115") opts = Gun.options([receive_conn: false], uri) @@ -44,7 +44,7 @@ defmodule Pleroma.HTTP.AdapterHelper.GunTest do assert opts[:certificates_verification] end - test "merges with defaul http adapter config" do + test "merges with default http adapter config" do defaults = Gun.options([receive_conn: false], URI.parse("https://example.com")) assert Keyword.has_key?(defaults, :a) assert Keyword.has_key?(defaults, :b) diff --git a/test/pleroma/http/adapter_helper/hackney_test.exs b/test/pleroma/http/adapter_helper/hackney_test.exs old mode 100755 new mode 100644 index 35d6c49..57ce472 --- a/test/pleroma/http/adapter_helper/hackney_test.exs +++ b/test/pleroma/http/adapter_helper/hackney_test.exs @@ -3,7 +3,7 @@ # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.HTTP.AdapterHelper.HackneyTest do - use ExUnit.Case, async: true + use ExUnit.Case use Pleroma.Tests.Helpers alias Pleroma.HTTP.AdapterHelper.Hackney diff --git a/test/pleroma/http/adapter_helper_test.exs b/test/pleroma/http/adapter_helper_test.exs old mode 100755 new mode 100644 diff --git a/test/pleroma/http/ex_aws_test.exs b/test/pleroma/http/ex_aws_test.exs old mode 100755 new mode 100644 diff --git a/test/pleroma/http/request_builder_test.exs b/test/pleroma/http/request_builder_test.exs old mode 100755 new mode 100644 diff --git a/test/pleroma/http/tzdata_test.exs b/test/pleroma/http/tzdata_test.exs old mode 100755 new mode 100644 diff --git a/test/pleroma/http/web_push_test.exs b/test/pleroma/http/web_push_test.exs new file mode 100644 index 0000000..dd8e45e --- /dev/null +++ b/test/pleroma/http/web_push_test.exs @@ -0,0 +1,45 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2022 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + +defmodule Pleroma.HTTP.WebPushTest do + use ExUnit.Case + + import Tesla.Mock + alias Pleroma.HTTP + + @push_url "https://some-push-server/" + + setup do + mock(fn + %{ + method: :post, + url: @push_url, + headers: headers + } -> + if {"content-type", "octet-stream"} in headers do + %Tesla.Env{ + status: 200 + } + else + %Tesla.Env{ + status: 403 + } + end + end) + + :ok + end + + test "post" do + response = + HTTP.WebPush.post( + @push_url, + "encrypted payload", + %{"authorization" => "WebPush"}, + [] + ) + + assert {:ok, %{status: 200}} = response + end +end -- cgit v1.2.3