diff options
author | lain <lain@soykaf.club> | 2024-05-28 04:42:35 +0000 |
---|---|---|
committer | lain <lain@soykaf.club> | 2024-05-28 04:42:35 +0000 |
commit | 25903a4996d12306d454be960a0a7478541b1879 (patch) | |
tree | 299b348adc572ffc5bec6ca11aaac3584b7bd567 /test | |
parent | 8ff0c32903938d84b7d7ae58af15b5b7a966ce33 (diff) | |
parent | 73d58c22d4a9a87539cf1c3a33083464fc4b8540 (diff) | |
download | pleroma-25903a4996d12306d454be960a0a7478541b1879.tar.gz pleroma-25903a4996d12306d454be960a0a7478541b1879.zip |
Merge branch 'auth-fetch-exception' into 'develop'
HTTPSignaturePlug: Add :authorized_fetch_mode_exceptions
See merge request pleroma/pleroma!4007
Diffstat (limited to 'test')
-rw-r--r-- | test/pleroma/web/plugs/http_signature_plug_test.exs | 19 |
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 |