forked from mirrors/akkoma
quarantine instances info
Added a new field in the nodeinfo called quarantined_instances_info This holds an object like `"quarantined_instances_info":{"quarantined_instances":{"quar.inst":{"reason":"whatever reason"}}}}`
This commit is contained in:
parent
47fc57bbcc
commit
03030b47c2
|
@ -98,7 +98,15 @@ def federation do
|
|||
|> Map.merge(%{
|
||||
quarantined_instances:
|
||||
quarantined
|
||||
|> Enum.map(fn {instance, reason} -> %{"instance" => instance, "reason" => reason} end)
|
||||
|> Enum.map(fn {instance, _reason} -> instance end)
|
||||
})
|
||||
|> Map.merge(%{
|
||||
quarantined_instances_info: %{
|
||||
"quarantined_instances" =>
|
||||
quarantined
|
||||
|> Enum.map(fn {instance, reason} -> {instance, %{"reason" => reason}} end)
|
||||
|> Enum.into(%{})
|
||||
}
|
||||
})
|
||||
else
|
||||
%{}
|
||||
|
|
|
@ -150,20 +150,42 @@ test "it shows default features flags", %{conn: conn} do
|
|||
)
|
||||
end
|
||||
|
||||
test "it shows quarantined instances data if enabled", %{conn: conn} do
|
||||
clear_config([:mrf, :transparency], true)
|
||||
describe "Quarantined instances" do
|
||||
setup do
|
||||
clear_config([:mrf, :transparency], true)
|
||||
quarantined_instances = [{"example.com", "reason to quarantine"}]
|
||||
clear_config([:instance, :quarantined_instances], quarantined_instances)
|
||||
end
|
||||
|
||||
quarantined_instances = [{"example.com", ""}]
|
||||
clear_config([:instance, :quarantined_instances], quarantined_instances)
|
||||
test "shows quarantined instances data if enabled", %{conn: conn} do
|
||||
expected_config = ["example.com"]
|
||||
|
||||
expected_config = [%{"instance" => "example.com", "reason" => ""}]
|
||||
response =
|
||||
conn
|
||||
|> get("/nodeinfo/2.1.json")
|
||||
|> json_response(:ok)
|
||||
|
||||
response =
|
||||
conn
|
||||
|> get("/nodeinfo/2.1.json")
|
||||
|> json_response(:ok)
|
||||
assert response["metadata"]["federation"]["quarantined_instances"] == expected_config
|
||||
end
|
||||
|
||||
assert response["metadata"]["federation"]["quarantined_instances"] == expected_config
|
||||
test "shows extra information in the quarantined_info field for relevant entries", %{
|
||||
conn: conn
|
||||
} do
|
||||
clear_config([:mrf, :transparency], true)
|
||||
|
||||
expected_config = %{
|
||||
"quarantined_instances" => %{
|
||||
"example.com" => %{"reason" => "reason to quarantine"}
|
||||
}
|
||||
}
|
||||
|
||||
response =
|
||||
conn
|
||||
|> get("/nodeinfo/2.1.json")
|
||||
|> json_response(:ok)
|
||||
|
||||
assert response["metadata"]["federation"]["quarantined_instances_info"] == expected_config
|
||||
end
|
||||
end
|
||||
|
||||
describe "MRF SimplePolicy" do
|
||||
|
@ -205,7 +227,7 @@ test "performs exclusions from MRF transparency data if configured", %{conn: con
|
|||
assert response["metadata"]["federation"]["exclusions"] == true
|
||||
end
|
||||
|
||||
test "shows extra information in the mrf_simple_extra field for relevant entries", %{
|
||||
test "shows extra information in the mrf_simple_info field for relevant entries", %{
|
||||
conn: conn
|
||||
} do
|
||||
simple_config = %{
|
||||
|
|
Loading…
Reference in a new issue