Changeset 679924e in Klonkt for test/webfinger-bare-host.test.js
- Timestamp:
- 08/02/2026 08:06:21 AM (5 weeks ago)
- Branches:
- main
- Children:
- af035e6
- Parents:
- 26c5f71
- File:
-
- 1 edited
-
test/webfinger-bare-host.test.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
test/webfinger-bare-host.test.js
r26c5f71 r679924e 28 28 // `kid` is the primary site; `oma` is a second public site that must NOT be 29 29 // what a bare host resolves to. 30 db.prepare('INSERT INTO sites (id, slug, title, owner_id, is_primary) VALUES (?,?,?,?,1)').run('s1', 'kid', 'kid', 'u1'); 31 db.prepare('INSERT INTO sites (id, slug, title, owner_id, is_primary) VALUES (?,?,?,?,0)').run('s2', 'oma', 'oma', 'u1'); 30 // Explicit created_at: getPrimarySite() falls back to the OLDEST site, and two 31 // rows inserted in the same second would make that order a coin flip. 32 db.prepare('INSERT INTO sites (id, slug, title, owner_id, is_primary, created_at) VALUES (?,?,?,?,1,?)') 33 .run('s1', 'kid', 'kid', 'u1', '2026-01-01 00:00:00'); 34 db.prepare('INSERT INTO sites (id, slug, title, owner_id, is_primary, created_at) VALUES (?,?,?,?,0,?)') 35 .run('s2', 'oma', 'oma', 'u1', '2026-06-01 00:00:00'); 32 36 33 37 const app = express(); … … 86 90 }); 87 91 92 test('a bare host resolves even when no site carries the primary flag', async () => { 93 // This is the state a fresh instance is actually in: is_primary defaults to 0 94 // and the backfill only runs when the column is first added, so a site created 95 // afterwards leaves the instance with no primary at all. The HTML side coped 96 // (getPrimarySite falls back to the oldest) while this route kept its own 97 // is_primary-only lookup — so / served the site and WebFinger said 404. 98 db.prepare('UPDATE sites SET is_primary = 0').run(); 99 try { 100 const { status, body } = await finger('acct:test.example@test.example'); 101 assert.equal(status, 200, 'an unflagged instance is still discoverable'); 102 assert.equal(actorOf(body), 'https://test.example/ap/users/kid', 'falls back to the oldest site'); 103 } finally { 104 db.prepare('UPDATE sites SET is_primary = 1 WHERE id = ?').run('s1'); 105 } 106 }); 107 88 108 test('an unknown user is still a 404', async () => { 89 109 // The fallback must not turn every miss into the primary actor, or a typo
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)