Restructure ARNavi contour UX and expose project-scoped VPS inventory
Device Core qualification / qualify (push) Successful in 7m42s

This commit is contained in:
DCCONSTRUCTIONS
2026-09-30 19:35:18 +03:00
parent 1bf3ee6d41
commit c0487ca17b
17 changed files with 508 additions and 388 deletions
@@ -156,3 +156,42 @@ test('TLS pin is verified before any HTTP credential reaches the peer', async ()
await rm(root, { recursive: true, force: true });
}
});
test('project inventory releases DB before networking and never exposes other projects or credentials', async () => {
const contour = 'c'.repeat(32); let released = false; const calls = [];
const repo = repository({ role: 'viewer' });
const db = await repo.pool.connect(); const original = db.query;
db.release = () => { released = true; };
db.query = async (sql, values) => {
if (sql.includes('from device_b2_hosts')) {
assert.match(sql, /v.project_id=\$1 and h.lifecycle_state='active'/);
assert.match(sql, /l.project_id=v.project_id/);
assert.deepEqual(values, [projectId]);
return { rows: [{ ...source, host_id: hostId, display_name: 'VPS', contour_ids: [contour] }] };
}
return original(sql, values);
};
const service = new B2Infrastructure({ pool: repo.pool, secrets: { read: async () => pkg }, clientFactory: () => ({ async call(path) {
assert.equal(released, true); calls.push(path);
return path === '/v2/identity' ? { host_id: pkg.host_id } : { items: [{ id: 'device', imei: '123456789012345', number: 1, name: 'B2', active: true }] };
} }) });
const result = await service.execute({ ...actor, hubRole: 'member' }, { projectRef: `project:${projectId}`, action: 'inventory' });
assert.deepEqual(calls, ['/v2/identity', `/v2/contours/${contour}/devices`]);
assert.equal(result.items[0].identifier.masked, '…12345');
assert.equal(result.hosts[0].reachable, true);
assert.equal(result.hosts[0].devices, 1);
const json = JSON.stringify(result);
for (const secret of [pkg.client_secret, source.secret_ref, '123456789012345', otherProject]) assert.equal(json.includes(secret), false);
assert.equal('online' in result.items[0], false);
});
test('unreachable or mismatched host is reported as unavailable, not an empty healthy fleet', async () => {
for (const fail of [false, true]) {
const repo = repository(); const db = await repo.pool.connect(); const original = db.query;
db.query = (sql, values) => sql.includes('from device_b2_hosts') ? { rows: [{ ...source, host_id: hostId, display_name: 'VPS', contour_ids: [] }] } : original(sql, values);
const service = new B2Infrastructure({ pool: repo.pool, secrets: { read: async () => pkg }, clientFactory: () => ({ async call() { if (fail) throw Error('contains-private-details'); return { host_id: 'wrong-host' }; } }) });
const result = await service.execute(actor, { projectRef: `project:${projectId}`, action: 'inventory' });
assert.equal(result.hosts[0].reachable, false); assert.equal(result.hosts[0].devices, null);
assert.deepEqual(result.items, []); assert.equal(JSON.stringify(result).includes('private-details'), false);
}
});