- Timestamp:
- 07/31/2026 05:43:16 PM (6 weeks ago)
- Branches:
- main
- Children:
- bfa6fa1
- Parents:
- f434294
- File:
-
- 1 edited
-
test/move-actor.test.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
test/move-actor.test.js
rf434294 r0ca7e9a4 124 124 assert.equal('alsoKnownAs' in buildActor('https://test.example', site), false); 125 125 }); 126 127 // ── Slice 2: the OUTGOING half ───────────────────────────────────── 128 // This Klonkt as the old home. A guarded account refuses (shaer-tge), a 129 // target without the alsoKnownAs back-reference refuses, and the happy path 130 // records moved_to and delivers ONE Move to every follower inbox. 131 const { moveAccount } = await import('../src/services/ActivityPubService.js'); 132 const ME_RADIO = 'https://test.example/ap/users/radio'; 133 const radioSite = () => db.prepare("SELECT * FROM sites WHERE slug = 'radio'").get(); 134 135 test('a guarded account refuses to move (shaer-tge)', async () => { 136 db.prepare(`INSERT OR IGNORE INTO ap_guardianships (slug, role, other_uri, status, offer_id) 137 VALUES ('blog', 'ward', 'https://oma.example/u/oma', 'accepted', 'o9')`).run(); 138 const blogSite = db.prepare("SELECT * FROM sites WHERE slug = 'blog'").get(); 139 const r = await moveAccount(blogSite, 'https://elders.example/users/nieuw', { 140 fetchActorFn: async () => ({ id: 'https://elders.example/users/nieuw', inbox: 'https://elders.example/inbox', alsoKnownAs: ['https://test.example/ap/users/blog'] }), 141 }); 142 assert.equal(r.error, 'guarded_account'); 143 assert.equal(db.prepare("SELECT moved_to FROM sites WHERE slug = 'blog'").get().moved_to, null, 'nothing recorded'); 144 }); 145 146 test('without the back-reference the move refuses', async () => { 147 const r = await moveAccount(radioSite(), 'https://elders.example/users/nieuw', { 148 fetchActorFn: async () => ({ id: 'https://elders.example/users/nieuw', inbox: 'https://elders.example/inbox', alsoKnownAs: ['https://iemand-anders.example/x'] }), 149 }); 150 assert.equal(r.error, 'no_backreference'); 151 assert.equal(db.prepare("SELECT moved_to FROM sites WHERE slug = 'radio'").get().moved_to, null); 152 }); 153 154 test('the happy path: moved_to recorded, one Move to every follower inbox', async () => { 155 db.prepare("INSERT INTO ap_followers (slug, actor_uri, inbox) VALUES ('radio', 'https://a.example/u/a', 'https://a.example/inbox')").run(); 156 db.prepare("INSERT INTO ap_followers (slug, actor_uri, inbox, shared_inbox) VALUES ('radio', 'https://b.example/u/b', 'https://b.example/inbox', 'https://b.example/shared')").run(); 157 const delivered = []; 158 const r = await moveAccount(radioSite(), 'https://elders.example/users/nieuw', { 159 fetchActorFn: async () => ({ id: 'https://elders.example/users/nieuw', inbox: 'https://elders.example/inbox', alsoKnownAs: [ME_RADIO] }), 160 deliverFn: async (slug, inbox, activity) => { delivered.push({ inbox, activity }); }, 161 }); 162 assert.equal(r.ok, true); 163 assert.equal(r.target, 'https://elders.example/users/nieuw'); 164 assert.equal(db.prepare("SELECT moved_to FROM sites WHERE slug = 'radio'").get().moved_to, 'https://elders.example/users/nieuw'); 165 assert.equal(delivered.length, 2, 'both follower inboxes'); 166 for (const d of delivered) { 167 assert.equal(d.activity.type, 'Move'); 168 assert.equal(d.activity.object, ME_RADIO); 169 assert.equal(d.activity.target, 'https://elders.example/users/nieuw'); 170 } 171 assert.ok(delivered.some((d) => d.inbox === 'https://b.example/shared'), 'shared inbox preferred'); 172 });
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)