summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorfeld <feld@feld.me>2023-12-19 16:19:35 +0000
committerfeld <feld@feld.me>2023-12-19 16:19:35 +0000
commit99b07c817e65d8855069a996777d41a9984f93bf (patch)
tree93094e7c900f0b316b9ac3a71223b388844d1845 /test
parent8893a044b3af5be607512a6b19747dc447d02262 (diff)
parente2066994b1e64481e0e74350688d91c71d03e230 (diff)
downloadpleroma-99b07c817e65d8855069a996777d41a9984f93bf.tar.gz
pleroma-99b07c817e65d8855069a996777d41a9984f93bf.zip
Merge branch 'web_push' into 'develop'
Fix Web Push notification delivery See merge request pleroma/pleroma!4008
Diffstat (limited to 'test')
-rw-r--r--test/pleroma/http/web_push_test.exs45
1 files changed, 45 insertions, 0 deletions
diff --git a/test/pleroma/http/web_push_test.exs b/test/pleroma/http/web_push_test.exs
new file mode 100644
index 000000000..dd8e45e6a
--- /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