27 lines
1.7 KiB
TypeScript
27 lines
1.7 KiB
TypeScript
import { readFileSync } from 'node:fs';
|
|
import { expect, it } from 'vitest';
|
|
import { canonicalJson } from './api';
|
|
import { sha256 } from './safety';
|
|
import { echoReview } from './echo-probe-review';
|
|
|
|
it('bindet die simulierte Echoabnahme an den einzelnen gespeicherten Auftrag und die Originalbelege', async () => {
|
|
const witness = JSON.parse(readFileSync(new URL('../../crates/domain/src/windows_sync_history_case.json', import.meta.url), 'utf8'));
|
|
const operation = '06e55f7a-0263-4def-b7c3-7d28b1202a51';
|
|
const scope = { tenant_id: witness.tenant_id, asset_id: witness.asset_id, agent_id: witness.agent_id,
|
|
operation_id: operation, plan_id: 'ee49a5a7-5b1a-4bb7-a08f-91169b6994ef',
|
|
job_id: '81a299d0-e4a7-4ddb-97bb-dd9f435cab58', attempt_id: 'bd5c1c80-c0be-446b-857e-7a2e07dc4920',
|
|
execution_identity: 'agent_service', max_runtime_seconds: 60, max_output_bytes: 65536,
|
|
plan_hash: '1'.repeat(64), job_payload_hash: '2'.repeat(64),
|
|
script_sha256: await sha256(new TextEncoder().encode("Write-Output 'Zeitprofil-Test'\r\n")) };
|
|
const make = async (s: typeof scope) => ({ scope: s,
|
|
scope_sha256: await sha256(new TextEncoder().encode(canonicalJson(s))), witness,
|
|
witness_sha256: await sha256(new TextEncoder().encode(canonicalJson(witness))),
|
|
receipt_id: null, valid_until: null });
|
|
expect((await echoReview(await make(scope), operation)).scope.job_id).toBe(scope.job_id);
|
|
for (const changed of [ { ...scope, execution_identity: 'system' }, { ...scope, script_sha256: '0'.repeat(64) },
|
|
{ ...scope, max_runtime_seconds: 61 }, { ...scope, max_output_bytes: 65537 },
|
|
{ ...scope, operation_id: scope.plan_id }, { ...scope, asset_id: scope.plan_id } ]) {
|
|
await expect(echoReview(await make(changed), operation)).rejects.toThrow();
|
|
}
|
|
});
|