Change what nodeinfo returns without breaking backwards compatibility
* Only for SimplePolicy for now * I added an extra mrf_simple_info key that has an object as value. The object contains only relevant extra info
This commit is contained in:
parent
7fdc3cde06
commit
47fc57bbcc
2 changed files with 90 additions and 28 deletions
|
|
@ -166,39 +166,89 @@ defmodule Pleroma.Web.NodeInfoTest do
|
|||
assert response["metadata"]["federation"]["quarantined_instances"] == expected_config
|
||||
end
|
||||
|
||||
test "it shows MRF transparency data if enabled", %{conn: conn} do
|
||||
clear_config([:mrf, :policies], [Pleroma.Web.ActivityPub.MRF.SimplePolicy])
|
||||
clear_config([:mrf, :transparency], true)
|
||||
describe "MRF SimplePolicy" do
|
||||
setup do
|
||||
clear_config([:mrf, :policies], [Pleroma.Web.ActivityPub.MRF.SimplePolicy])
|
||||
clear_config([:mrf, :transparency], true)
|
||||
end
|
||||
|
||||
simple_config = %{"reject" => [{"example.com", ""}]}
|
||||
clear_config(:mrf_simple, simple_config)
|
||||
test "shows MRF transparency data if enabled", %{conn: conn} do
|
||||
simple_config = %{"reject" => [{"example.com", ""}]}
|
||||
clear_config(:mrf_simple, simple_config)
|
||||
|
||||
expected_config = %{"reject" => [%{"instance" => "example.com", "reason" => ""}]}
|
||||
expected_config = %{"reject" => ["example.com"]}
|
||||
|
||||
response =
|
||||
conn
|
||||
|> get("/nodeinfo/2.1.json")
|
||||
|> json_response(:ok)
|
||||
response =
|
||||
conn
|
||||
|> get("/nodeinfo/2.1.json")
|
||||
|> json_response(:ok)
|
||||
|
||||
assert response["metadata"]["federation"]["mrf_simple"] == expected_config
|
||||
end
|
||||
assert response["metadata"]["federation"]["mrf_simple"] == expected_config
|
||||
end
|
||||
|
||||
test "it performs exclusions from MRF transparency data if configured", %{conn: conn} do
|
||||
clear_config([:mrf, :policies], [Pleroma.Web.ActivityPub.MRF.SimplePolicy])
|
||||
clear_config([:mrf, :transparency], true)
|
||||
clear_config([:mrf, :transparency_exclusions], [{"other.site", "We don't want them to know"}])
|
||||
test "performs exclusions from MRF transparency data if configured", %{conn: conn} do
|
||||
clear_config([:mrf, :transparency_exclusions], [
|
||||
{"other.site", "We don't want them to know"}
|
||||
])
|
||||
|
||||
simple_config = %{"reject" => [{"example.com", ""}, {"other.site", ""}]}
|
||||
clear_config(:mrf_simple, simple_config)
|
||||
simple_config = %{"reject" => [{"example.com", ""}, {"other.site", ""}]}
|
||||
clear_config(:mrf_simple, simple_config)
|
||||
|
||||
expected_config = %{"reject" => [%{"instance" => "example.com", "reason" => ""}]}
|
||||
expected_config = %{"reject" => ["example.com"]}
|
||||
|
||||
response =
|
||||
conn
|
||||
|> get("/nodeinfo/2.1.json")
|
||||
|> json_response(:ok)
|
||||
response =
|
||||
conn
|
||||
|> get("/nodeinfo/2.1.json")
|
||||
|> json_response(:ok)
|
||||
|
||||
assert response["metadata"]["federation"]["mrf_simple"] == expected_config
|
||||
assert response["metadata"]["federation"]["exclusions"] == true
|
||||
assert response["metadata"]["federation"]["mrf_simple"] == expected_config
|
||||
assert response["metadata"]["federation"]["exclusions"] == true
|
||||
end
|
||||
|
||||
test "shows extra information in the mrf_simple_extra field for relevant entries", %{
|
||||
conn: conn
|
||||
} do
|
||||
simple_config = %{
|
||||
media_removal: [{"no.media", "LEEWWWDD >//<"}],
|
||||
media_nsfw: [],
|
||||
federated_timeline_removal: [{"no.ftl", ""}],
|
||||
report_removal: [],
|
||||
reject: [
|
||||
{"example.instance", "Some reason"},
|
||||
{"uwu.owo", "awoo to much"},
|
||||
{"no.reason", ""}
|
||||
],
|
||||
followers_only: [],
|
||||
accept: [],
|
||||
avatar_removal: [],
|
||||
banner_removal: [],
|
||||
reject_deletes: [
|
||||
{"peak.me", "I want to peak at what they don't want me to see, eheh"}
|
||||
]
|
||||
}
|
||||
|
||||
clear_config(:mrf_simple, simple_config)
|
||||
|
||||
clear_config([:mrf, :transparency_exclusions], [
|
||||
{"peak.me", "I don't want them to know"}
|
||||
])
|
||||
|
||||
expected_config = %{
|
||||
"media_removal" => %{
|
||||
"no.media" => %{"reason" => "LEEWWWDD >//<"}
|
||||
},
|
||||
"reject" => %{
|
||||
"example.instance" => %{"reason" => "Some reason"},
|
||||
"uwu.owo" => %{"reason" => "awoo to much"}
|
||||
}
|
||||
}
|
||||
|
||||
response =
|
||||
conn
|
||||
|> get("/nodeinfo/2.1.json")
|
||||
|> json_response(:ok)
|
||||
|
||||
assert response["metadata"]["federation"]["mrf_simple_info"] == expected_config
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue