commit: e5be1d04d6fadf5a7c92ec86c5c97efd7ea09501
parent 3e2573f1c4688a227dae2a8fa96141c0a65cffbc
Author: nicole mikołajczyk <git@mkljczk.pl>
Date: Mon, 15 Dec 2025 16:59:23 +0100
Update tests, make the mastodon subdomain example not have the /.well-known/host-meta redirect, as the docs don't include it
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
Diffstat:
2 files changed, 41 insertions(+), 17 deletions(-)
diff --git a/test/pleroma/web/web_finger_test.exs b/test/pleroma/web/web_finger_test.exs
@@ -234,7 +234,10 @@ defmodule Pleroma.Web.WebFingerTest do
test "prevents forgeries" do
Tesla.Mock.mock(fn
- %{url: "https://fba.ryona.agency/.well-known/webfinger?resource=acct:graf@fba.ryona.agency"} ->
+ %{
+ url:
+ "https://fba.ryona.agency/.well-known/webfinger?resource=acct:graf@fba.ryona.agency"
+ } ->
fake_webfinger =
File.read!("test/fixtures/webfinger/graf-imposter-webfinger.json") |> Jason.decode!()
@@ -242,16 +245,21 @@ defmodule Pleroma.Web.WebFingerTest do
%{url: url}
when url in [
- "https://poa.st/.well-known/webfinger?resource=acct:graf@poa.st",
- "https://fba.ryona.agency/.well-known/host-meta"
- ] ->
+ "https://poa.st/.well-known/webfinger?resource=acct:graf@poa.st",
+ "https://fba.ryona.agency/.well-known/host-meta"
+ ] ->
{:ok, %Tesla.Env{status: 404}}
end)
assert {:error, _} = WebFinger.finger("graf@fba.ryona.agency")
end
- test "works for correctly set up split-domain instances" do
+ test "works for correctly set up split-domain instances implementing host-meta redirect" do
+ {:ok, _data} = WebFinger.finger("a@pleroma.example")
+ {:ok, _data} = WebFinger.finger("a@sub.pleroma.example")
+ end
+
+ test "works for correctly set up split-domain instances without host-meta redirect" do
{:ok, _data} = WebFinger.finger("a@mastodon.example")
{:ok, _data} = WebFinger.finger("a@sub.mastodon.example")
end
diff --git a/test/support/http_request_mock.ex b/test/support/http_request_mock.ex
@@ -1527,14 +1527,6 @@ defmodule HttpRequestMock do
}}
end
- def get("https://mastodon.example/.well-known/host-meta", _, _, _) do
- {:ok,
- %Tesla.Env{
- status: 302,
- headers: [{"location", "https://sub.mastodon.example/.well-known/host-meta"}]
- }}
- end
-
def get("https://sub.mastodon.example/.well-known/host-meta", _, _, _) do
{:ok,
%Tesla.Env{
@@ -1547,11 +1539,15 @@ defmodule HttpRequestMock do
end
def get(
- "https://sub.mastodon.example/.well-known/webfinger?resource=acct:a@mastodon.example",
+ url,
_,
_,
_
- ) do
+ )
+ when url in [
+ "https://sub.mastodon.example/.well-known/webfinger?resource=acct:a@mastodon.example",
+ "https://sub.mastodon.example/.well-known/webfinger?resource=acct:a@sub.mastodon.example"
+ ] do
{:ok,
%Tesla.Env{
status: 200,
@@ -1565,6 +1561,22 @@ defmodule HttpRequestMock do
}}
end
+ def get(
+ "https://mastodon.example/.well-known/webfinger?resource=acct:a@mastodon.example",
+ _,
+ _,
+ _
+ ) do
+ {:ok,
+ %Tesla.Env{
+ status: 302,
+ headers: [
+ {"location",
+ "https://sub.mastodon.example/.well-known/webfinger?resource=acct:a@mastodon.example"}
+ ]
+ }}
+ end
+
def get("https://sub.mastodon.example/users/a", _, _, _) do
{:ok,
%Tesla.Env{
@@ -1610,11 +1622,15 @@ defmodule HttpRequestMock do
end
def get(
- "https://sub.pleroma.example/.well-known/webfinger?resource=acct:a@pleroma.example",
+ url,
_,
_,
_
- ) do
+ )
+ when url in [
+ "https://sub.pleroma.example/.well-known/webfinger?resource=acct:a@pleroma.example",
+ "https://sub.pleroma.example/.well-known/webfinger?resource=acct:a@sub.pleroma.example"
+ ] do
{:ok,
%Tesla.Env{
status: 200,