Bring Device Core settings to Mission UI and expose scoped B2 controls
Device Core qualification / qualify (push) Successful in 6m40s
Device Core qualification / qualify (push) Successful in 6m40s
This commit is contained in:
@@ -234,3 +234,33 @@ test('application creation and issuance use one server-generated request identit
|
||||
await assert.rejects(service.execute(actor, { action: 'application-connect', projectRef: `project:${projectId}`, hostRef: `host:${hostId}`, name: 'Other', contourId: 'f'.repeat(32) }, requestId), /b2_access_denied/);
|
||||
assert.equal(calls.length, 2);
|
||||
});
|
||||
|
||||
test('tracker settings keep project and contour authority across remote calls', async () => {
|
||||
const contour = 'c'.repeat(32), device = 'd'.repeat(32), calls = [];
|
||||
const repo = repository({ role: 'viewer' }); const db = await repo.pool.connect();
|
||||
let released = false; const original = db.query;
|
||||
db.release = () => { released = true; };
|
||||
db.query = async (sql, values) => {
|
||||
if (sql.includes('from device_b2_hosts')) {
|
||||
assert.match(sql, /l.project_id=v.project_id/);
|
||||
assert.match(sql, /h.lifecycle_state='active'/);
|
||||
assert.deepEqual(values, [hostId, projectId, contour]);
|
||||
return { rows: [source] };
|
||||
}
|
||||
return original(sql, values);
|
||||
};
|
||||
const service = new B2Infrastructure({ pool: repo.pool, secrets: { read: async () => pkg }, clientFactory: () => ({ async call(path, body) {
|
||||
assert.equal(released, true); calls.push({path,body});
|
||||
return path === '/v2/identity' ? {host_id:pkg.host_id} : {revision:1};
|
||||
} }) });
|
||||
const input = {action:'tracker',projectRef:`project:${projectId}`,hostRef:`host:${hostId}`,contourId:contour,deviceId:device,request:{action:'state'}};
|
||||
assert.deepEqual(await service.execute({...actor,hubRole:'member'},input), {revision:1});
|
||||
assert.equal(calls[1].path, `/v2/contours/${contour}/devices/${device}/settings`);
|
||||
for (const action of ['save','apply','read','command','cancel','firmware-upload','profile-save']) {
|
||||
await assert.rejects(service.execute({...actor,hubRole:'member'},{...input,request:{action}}));
|
||||
}
|
||||
assert.equal(calls.length,2);
|
||||
db.query = async (sql,values) => sql.includes('from device_b2_hosts') ? {rows:[]} : original(sql,values);
|
||||
await assert.rejects(service.execute(actor,input), /b2_access_denied/);
|
||||
assert.equal(calls.length,2);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user