logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git

web_push_test.exs (858B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.HTTP.WebPushTest do
  5. use ExUnit.Case
  6. import Tesla.Mock
  7. alias Pleroma.HTTP
  8. @push_url "https://some-push-server/"
  9. setup do
  10. mock(fn
  11. %{
  12. method: :post,
  13. url: @push_url,
  14. headers: headers
  15. } ->
  16. if {"content-type", "octet-stream"} in headers do
  17. %Tesla.Env{
  18. status: 200
  19. }
  20. else
  21. %Tesla.Env{
  22. status: 403
  23. }
  24. end
  25. end)
  26. :ok
  27. end
  28. test "post" do
  29. response =
  30. HTTP.WebPush.post(
  31. @push_url,
  32. "encrypted payload",
  33. %{"authorization" => "WebPush"},
  34. []
  35. )
  36. assert {:ok, %{status: 200}} = response
  37. end
  38. end