Bind typed SYSTEM service plans and qualify Domain contract on cloud Linux
Rust development slice / linux (push) Failing after 7s

This commit is contained in:
2026-11-14 05:30:21 +01:00
parent 5f356a92ac
commit e85f9ed750
10 changed files with 422 additions and 17 deletions
+18
View File
@@ -30,6 +30,24 @@ describe('immutable catalog and strict import contracts', () => {
});
});
describe('root and dedicated dev-test APT actions', () => {
it('requires independent system scope and verifies the exact bounded SYSTEM service plan', async () => {
const value: PlanInput = { tenant_id: 't', action: 'set_service_state', targets: { asset_ids: ['asset'] }, parameters: { execution_identity: 'system', unit: 'RmmDiscoveryFixtureService', state: 'running', timeout_seconds: 30, max_output_bytes: 4096 }, schedule: { not_before: '', start_before: '', offline_policy: 'wait_until_deadline' }, rollout: { max_parallel: 1, halt_after_failures: 1 }, reason: 'unit only' };
for (const permissions of [undefined, [], ['root:execute']]) await expect(validateSensitiveInput(value, { ...auth, permissions })).rejects.toThrow('system:execute');
const systemAuth = { ...auth, permissions: ['system:execute'] };
const before = JSON.stringify(value); await validateSensitiveInput(value, systemAuth); expect(JSON.stringify(value)).toBe(before);
await expect(validateSensitiveInput({ ...value, action: 'run_script' }, systemAuth)).rejects.toThrow('typisierte');
await expect(validateSensitiveInput({ ...value, parameters: { ...value.parameters, state: 'restarted' } }, systemAuth)).rejects.toThrow('running');
const payload = { execution_identity: 'system', asset_id: 'asset', action: { action: 'set_service_state', unit: 'RmmDiscoveryFixtureService', state: 'running' }, max_runtime_seconds: 30, max_output_bytes: 4096 };
const plan_payload = { jobs: [{ payload }] }, raw = new TextEncoder().encode(JSON.stringify(plan_payload));
const plan = { plan_payload, plan_payload_bytes: Array.from(raw), plan_hash: await sha256(raw), jobs: plan_payload.jobs };
await verifyPlanIntegrity(plan);
await expect(verifyPlanIntegrity({ ...plan, plan_payload_bytes: undefined })).rejects.toThrow('exakte gespeicherte');
const changed = structuredClone(plan_payload), first = changed.jobs[0]; if (!first) throw new Error('One fixed service job required'); first.payload.action.state = 'stopped';
await expect(verifyPlanIntegrity({ ...plan, plan_payload: changed })).rejects.toThrow('widerspricht');
const shell = { jobs: [{ payload: { ...payload, action: { action: 'run_script', interpreter: 'powershell' } } }] }, shellRaw = new TextEncoder().encode(JSON.stringify(shell));
await expect(verifyPlanIntegrity({ plan_payload_bytes: Array.from(shellRaw), plan_hash: await sha256(shellRaw) })).rejects.toThrow();
await expect(validateSensitiveInput({ ...value, parameters: { ...value.parameters, execution_identity: 'root' } }, systemAuth)).rejects.toThrow('root:execute');
});
it('shows native acceptance only with explicit server simulation evidence, never upgrades identity', async () => {
expect(availableActions(auth, actions)).toContain('apt_native_acceptance');
expect(availableActions({ ...auth, principal: { ...auth.principal, simulated: false } }, actions)).not.toContain('apt_native_acceptance');