Compact contour actions and delete VPS applications with all access
Device Core qualification / qualify (push) Successful in 7m19s
Device Core qualification / qualify (push) Successful in 7m19s
This commit is contained in:
@@ -179,7 +179,7 @@ export class B2Infrastructure {
|
||||
// Host management can affect all projects of the company. A project-only
|
||||
// grant must not turn into company-wide administration.
|
||||
if (action !== 'devices') assertActorCanManageOwnerScope(actor, { scopeKind: project.scope_kind, ownerRef: project.owner_ref });
|
||||
if (['connect', 'key-issue', 'key-revoke', 'application-connect'].includes(action)) {
|
||||
if (['connect', 'key-issue', 'key-revoke', 'application-connect', 'application-delete'].includes(action)) {
|
||||
await findProjectWithCapability(db, actor, projectId, 'credential.manage');
|
||||
}
|
||||
const host = (await db.query('select id,host_key,display_name,provider_ref from device_infrastructure_hosts where id=$1 and project_id=$2 and lifecycle_state <> $3 for share',
|
||||
@@ -286,6 +286,9 @@ export class B2Infrastructure {
|
||||
result = { id: app.id, connection: await remote.call('/v2/management/credentials', {
|
||||
integration_id: app.id, replace: false, request_id: requestId,
|
||||
}) };
|
||||
} else if (action === 'application-delete') {
|
||||
fields(input, ['integrationId']);
|
||||
result = await remote.call('/v2/management/applications/delete', { integration_id: opaque(input.integrationId) });
|
||||
} else if (action === 'key-issue') {
|
||||
fields(input, ['integrationId', 'replace']);
|
||||
if (typeof input.replace !== 'boolean') throw b2Error('b2_replace_invalid');
|
||||
|
||||
@@ -303,3 +303,18 @@ test('VPS onboarding reuses the project host and audits no credential material',
|
||||
assert.ok(audit.length > 0);
|
||||
assert.ok(!JSON.stringify(audit).includes(pkg.client_secret));
|
||||
});
|
||||
|
||||
|
||||
test('application deletion requires company and credential authority and forwards only the application ID', async () => {
|
||||
const repo = repository(); const calls = [];
|
||||
const service = new B2Infrastructure({ pool: repo.pool, secrets: { read: async () => pkg },
|
||||
clientFactory: () => ({ async call(path, body) { calls.push({ path, body }); return { deleted: true, id: body.integration_id }; } }) });
|
||||
const input = { projectRef: `project:${projectId}`, hostRef: `host:${hostId}`, action: 'application-delete', integrationId: 'c'.repeat(32) };
|
||||
await assert.rejects(service.execute({ ...actor, hubRole: 'member', ownerScopes: [] }, input, '1'.repeat(32)), /device_owner_scope_access_denied/);
|
||||
await assert.rejects(service.execute(actor, { ...input, integrationId: '../foreign' }, '1'.repeat(32)), /b2_identifier_invalid/);
|
||||
await assert.rejects(service.execute(actor, { ...input, force: true }, '1'.repeat(32)), /b2_unexpected_field/);
|
||||
assert.equal(calls.length, 0);
|
||||
assert.deepEqual(await service.execute(actor, input, '1'.repeat(32)), { deleted: true, id: input.integrationId });
|
||||
assert.deepEqual(calls, [{ path: '/v2/management/applications/delete', body: { integration_id: input.integrationId } }]);
|
||||
assert.equal(repo.writes.at(-1).values[1], 'b2.application-delete');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user