v4: a remote account's links to its home lead to the home's pages — the settings' "Change it on <host>" button and the profile's "Account on <host>" link went to the host in the handle, which is the home's issuer, its API, not necessarily where its pages are: in development musique's button led to localhost:8000/settings, gerbeur's API, which served a stale build, instead of localhost:3000/settings. GET /api/users/:key/home?path= now redirects to a page of a remote user's home, their profile there by default, at the origin of the home's authorization_endpoint, which its metadata gives (homePageUrl in federation-service.ts), the issuer standing in while the home doesn't answer; a local user 404s, and a path that isn't one 400s. homeUrl links to it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
khannurien
2026-10-09 21:06:14 +00:00
parent 5f2fb4479a
commit 8bcc005140
5 changed files with 90 additions and 9 deletions

View File

@@ -123,6 +123,39 @@ test("federation: a trusted instance's user signs in as name@host, once made", a
);
});
test("federation: a remote user's home link leads to its pages, not its API", async () => {
const home = await fakeInstance(HOME, {
authorization_endpoint: "https://www.home.test/authorize",
});
using _net = network(home);
await trust(HOME);
await signIn(home, ALICE);
const profile = await get("/api/users/@alice%40home.test/home");
assertEquals(profile.status, 302);
assertEquals(
profile.headers.get("location"),
"https://www.home.test/@alice",
);
const settings = await get(
"/api/users/@alice%40home.test/home?path=%2Fsettings",
);
assertEquals(
settings.headers.get("location"),
"https://www.home.test/settings",
);
assertEquals(
(await get("/api/users/@alice%40home.test/home?path=%2F%2Fevil.test"))
.status,
400,
);
const local = await createUser();
assertEquals(
(await get(`/api/users/@${local.username}/home`)).status,
404,
);
});
test("federation: a login works once, with the code the home made for it", async () => {
const home = await fakeInstance(HOME);
using _net = network(home);