Fork of Pleroma with site-specific changes and feature branches https://git.pleroma.social/pleroma/pleroma
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
900B

  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Web.Plugs.HTTPSignaturePlugTest do
  5. use Pleroma.Web.ConnCase
  6. alias Pleroma.Web.Plugs.HTTPSignaturePlug
  7. import Plug.Conn
  8. import Mock
  9. test "it call HTTPSignatures to check validity if the actor sighed it" do
  10. params = %{"actor" => "http://mastodon.example.org/users/admin"}
  11. conn = build_conn(:get, "/doesntmattter", params)
  12. with_mock HTTPSignatures, validate_conn: fn _ -> true end do
  13. conn =
  14. conn
  15. |> put_req_header(
  16. "signature",
  17. "keyId=\"http://mastodon.example.org/users/admin#main-key"
  18. )
  19. |> HTTPSignaturePlug.call(%{})
  20. assert conn.assigns.valid_signature == true
  21. assert called(HTTPSignatures.validate_conn(:_))
  22. end
  23. end
  24. end