summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHaelwenn (lanodan) Monnier <contact@hacktivis.me>2023-12-16 18:56:46 +0100
committerHaelwenn (lanodan) Monnier <contact@hacktivis.me>2023-12-16 19:25:51 +0100
commit086ba59d0346be870dc7df2660fbb55666bf0af7 (patch)
treef3989b2ef5334f578759c44cb1e1500440b854c1 /test
parentf271ea6e432d685c113582e5944d79e12c153016 (diff)
downloadpleroma-086ba59d0346be870dc7df2660fbb55666bf0af7.tar.gz
pleroma-086ba59d0346be870dc7df2660fbb55666bf0af7.zip
HTTPSignaturePlug: Add :authorized_fetch_mode_exceptions
Diffstat (limited to 'test')
-rw-r--r--test/pleroma/web/plugs/http_signature_plug_test.exs19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/pleroma/web/plugs/http_signature_plug_test.exs b/test/pleroma/web/plugs/http_signature_plug_test.exs
index 2d8fba3cd..deb7e4a23 100644
--- a/test/pleroma/web/plugs/http_signature_plug_test.exs
+++ b/test/pleroma/web/plugs/http_signature_plug_test.exs
@@ -81,5 +81,24 @@ defmodule Pleroma.Web.Plugs.HTTPSignaturePlugTest do
assert conn.state == :sent
assert conn.resp_body == "Request not signed"
end
+
+ test "exempts specific IPs from `authorized_fetch_mode_exceptions`", %{conn: conn} do
+ clear_config([:activitypub, :authorized_fetch_mode_exceptions], ["192.168.0.0/24"])
+
+ with_mock HTTPSignatures, validate_conn: fn _ -> false end do
+ conn =
+ conn
+ |> Map.put(:remote_ip, {192, 168, 0, 1})
+ |> put_req_header(
+ "signature",
+ "keyId=\"http://mastodon.example.org/users/admin#main-key"
+ )
+ |> HTTPSignaturePlug.call(%{})
+
+ assert conn.remote_ip == {192, 168, 0, 1}
+ assert conn.halted == false
+ assert called(HTTPSignatures.validate_conn(:_))
+ end
+ end
end
end