NodeInfo is read as Mobilizon serves it
Mobilizon sends its NodeInfo as `application/json; profile=http://…#` with the URL unquoted, which .NET cannot parse, so the document was refused for its content type and the server never described; and it names its software "Mobilizon" where NodeInfo wants lower case. The media type is now read from the raw header when the parsed one is missing, and software names are lowercased, so one software is counted under one name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LsXgEaXee4GCU1hwYgPJXw
This commit is contained in:
1 parent
206506f5e9
commit
7f6837ccb1
4 files changed
+24
-3
No files matched your search
@@ -27,6 +27,12 @@ namespace PrivaPub.Tests.Infrastructure
|
||||
_peer.MapGet("/big", () => Results.Text("{\"a\":\"" + new string('a', FederationHttp.MaxResponseBytes) + "\"}", "application/activity+json"));
|
||||
_peer.MapGet("/hop/{n:int}", (int n) => Results.Redirect(n == 0 ? "/actor" : $"/hop/{n - 1}"));
|
||||
_peer.MapGet("/gone", () => Results.StatusCode(410));
|
||||
// Mobilizon's NodeInfo: a profile URL left unquoted, which .NET cannot parse as a media type
|
||||
_peer.MapGet("/nodeinfo", (HttpContext context) =>
|
||||
{
|
||||
context.Response.Headers.ContentType = "application/json; profile=http://nodeinfo.diaspora.software/ns/schema/2.1#; charset=utf-8";
|
||||
return context.Response.WriteAsync("{\"software\":{\"name\":\"Mobilizon\"}}");
|
||||
});
|
||||
await _peer.StartAsync();
|
||||
_base = _peer.Urls.First();
|
||||
}
|
||||
@@ -64,6 +70,13 @@ namespace PrivaPub.Tests.Infrastructure
|
||||
public async Task Refuses_a_fourth_redirect() =>
|
||||
Assert.Null(await Client().GetJson($"{_base}/hop/3", "application/activity+json", default, TestContext.Current.CancellationToken));
|
||||
|
||||
[Fact]
|
||||
public async Task Reads_json_under_a_content_type_dotnet_cannot_parse()
|
||||
{
|
||||
using var fetched = await Client().GetJson($"{_base}/nodeinfo", "application/json", default, TestContext.Current.CancellationToken);
|
||||
Assert.Equal("Mobilizon", fetched.Root.GetProperty("software").GetProperty("name").GetString());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Refuses_html() =>
|
||||
Assert.Null(await Client().GetJson($"{_base}/html", "application/activity+json", default, TestContext.Current.CancellationToken));
|
||||
|
||||
Reference in new issue
Block a user