Add device diagnostics and P2P access controls
This commit is contained in:
@@ -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: [
|
||||
|
||||
Reference in New Issue
Block a user