aboutsummaryrefslogtreecommitdiff
path: root/test/pleroma/http
diff options
context:
space:
mode:
Diffstat (limited to 'test/pleroma/http')
-rw-r--r--[-rwxr-xr-x]test/pleroma/http/adapter_helper/gun_test.exs4
-rw-r--r--[-rwxr-xr-x]test/pleroma/http/adapter_helper/hackney_test.exs2
-rw-r--r--[-rwxr-xr-x]test/pleroma/http/adapter_helper_test.exs0
-rw-r--r--[-rwxr-xr-x]test/pleroma/http/ex_aws_test.exs0
-rw-r--r--[-rwxr-xr-x]test/pleroma/http/request_builder_test.exs0
-rw-r--r--[-rwxr-xr-x]test/pleroma/http/tzdata_test.exs0
-rw-r--r--test/pleroma/http/web_push_test.exs45
7 files changed, 48 insertions, 3 deletions
diff --git a/test/pleroma/http/adapter_helper/gun_test.exs b/test/pleroma/http/adapter_helper/gun_test.exs
index 7515f4e..d567bc8 100755..100644
--- 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
index 35d6c49..57ce472 100755..100644
--- 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
index e3c78f3..e3c78f3 100755..100644
--- a/test/pleroma/http/adapter_helper_test.exs
+++ b/test/pleroma/http/adapter_helper_test.exs
diff --git a/test/pleroma/http/ex_aws_test.exs b/test/pleroma/http/ex_aws_test.exs
index 2bf3415..2bf3415 100755..100644
--- a/test/pleroma/http/ex_aws_test.exs
+++ b/test/pleroma/http/ex_aws_test.exs
diff --git a/test/pleroma/http/request_builder_test.exs b/test/pleroma/http/request_builder_test.exs
index 0f1ec74..0f1ec74 100755..100644
--- a/test/pleroma/http/request_builder_test.exs
+++ b/test/pleroma/http/request_builder_test.exs
diff --git a/test/pleroma/http/tzdata_test.exs b/test/pleroma/http/tzdata_test.exs
index 9c260fb..9c260fb 100755..100644
--- a/test/pleroma/http/tzdata_test.exs
+++ b/test/pleroma/http/tzdata_test.exs
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 <https://pleroma.social/>
+# 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