Add device diagnostics and P2P access controls

This commit is contained in:
Jonathan Sykes
2026-10-14 02:45:33 +08:00
parent e9a597c415
commit 5177a4d441
11 changed files with 147 additions and 8 deletions

View File

@@ -63,6 +63,15 @@ test('holdings need a valid device secret', async () => {
expect((await req('/api/p2p/holdings', { method: 'POST', body: { items: [] }, dev: { ...dev, secret: 'e'.repeat(64) } })).status).toBe(401);
});
test('banned device is denied with an explicit forbidden response', async () => {
const dev = await newDevice();
await p2pDb.setDeviceBanned(dev.deviceId, true);
const r = await req('/api/p2p/holdings', { method: 'POST', body: { items: [] }, dev });
expect(r.status).toBe(403);
expect(await r.json()).toMatchObject({ ok: false, error: 'device access revoked' });
await p2pDb.setDeviceBanned(dev.deviceId, false);
});
test('report accepts verified cids, returns unknown ones, and challenges the server-held file', async () => {
const dev = await newDevice();
const r = await (await req('/api/p2p/holdings', { method: 'POST', dev, body: { share: true, items: [