Enforce claim permission and bounded full USB enrollment envelopes
Device Core qualification / qualify (push) Successful in 8m31s

This commit is contained in:
DCCONSTRUCTIONS
2026-10-01 09:33:04 +03:00
parent dc9fe6e0fc
commit be30fafa95
6 changed files with 32 additions and 3 deletions
@@ -360,3 +360,14 @@ test('enrollment validates project capability, active host and contour before fo
await assert.rejects(denied.execute({ ...actor, hubRole: 'member' }, input));
await assert.rejects(denied.execute({ ...actor, hubRole: 'member' }, { projectRef: input.projectRef, action: 'enrollment-options' }));
});
test('enrollment permission alone cannot claim a device into a project', async () => {
const repo = repository({ role: 'engineer' }), db = await repo.pool.connect(), original = db.query;
db.query = async (sql, values) => {
const result = await original(sql, values);
if (sql.includes('from device_project_grants')) result.rows[0].capability_deny = ['device.claim'];
return result;
};
const service = new B2Infrastructure({ pool: repo.pool, secrets: { read: async () => assert.fail('no remote credentials') } });
await assert.rejects(service.execute({ ...actor, hubRole: 'member' }, { projectRef: `project:${projectId}`, hostRef: `host:${hostId}`, action: 'enrollment', contourId: 'a'.repeat(32), request: { action: 'register', imei: '323456789012345', number: 300, name: 'B2' } }));
});