test(federation-identity): #11 invalid mode / #12 empty origins

This commit is contained in:
Jannis Braun
2026-05-03 23:35:15 +02:00
parent 2df346cf03
commit b62ffdf03b
@@ -20,4 +20,30 @@ describe('Federation identity deletion — server suite', () => {
expect(harness.remote.origin).toMatch(/^http:\/\/127\.0\.0\.1:\d+$/);
expect(sharedHmacSecret).toHaveLength(64);
});
it('#11 returns 400 for invalid mode', async () => {
const { createFederatedUser } = await import('./helpers/testUsers.js');
const { homeUser } = await createFederatedUser(harness.home, harness.remote, 't11');
const res = await fetch(`${harness.home.origin}/api/users/@me/federation-identity/delete`, {
method: 'POST',
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${homeUser.token}` },
body: JSON.stringify({ origins: [harness.remote.origin], mode: 'foo' }),
});
expect(res.status).toBe(400);
const body = await res.json();
expect(String(body.error)).toMatch(/Invalid mode/);
});
it('#12 returns 400 for empty origins', async () => {
const { createFederatedUser } = await import('./helpers/testUsers.js');
const { homeUser } = await createFederatedUser(harness.home, harness.remote, 't12');
const res = await fetch(`${harness.home.origin}/api/users/@me/federation-identity/delete`, {
method: 'POST',
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${homeUser.token}` },
body: JSON.stringify({ origins: [], mode: 'full' }),
});
expect(res.status).toBe(400);
const body = await res.json();
expect(String(body.error)).toMatch(/origins/);
});
});