Share signed job core and verify native Linux then Windows contracts
Rust development slice / linux (push) Failing after 6s
Rust development slice / linux (push) Failing after 6s
This commit is contained in:
+17
-1
@@ -1,5 +1,5 @@
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||||
import { approvalBlockers, page, PlanInput, request, session, validateInput } from './api';
|
||||
import { expectedStdout, approvalBlockers, page, PlanInput, request, session, validateInput } from './api';
|
||||
afterEach(() => vi.unstubAllGlobals());
|
||||
describe('JSON contract boundary', () => {
|
||||
it('refuses missing simulation identity metadata', () => {
|
||||
@@ -49,6 +49,22 @@ describe('JSON contract boundary', () => {
|
||||
validateInput(input); expect(input.parameters.variants).toEqual([variant]);
|
||||
expect(() => validateInput({ ...input, targets: { asset_ids: ['a', 'a'] } })).toThrow('eindeutige');
|
||||
});
|
||||
it('binds explicitly escaped stdout CRLF before planning and leaves text unchanged', () => {
|
||||
expect(expectedStdout('"Hello\\r\\n"', 'json')).toBe('Hello\r\n');
|
||||
expect(expectedStdout('Hello\n', 'text')).toBe('Hello\n');
|
||||
expect(expectedStdout('', 'json')).toBeNull();
|
||||
expect(() => expectedStdout('{}', 'json')).toThrow();
|
||||
expect(() => expectedStdout('x', 'unknown')).toThrow();
|
||||
});
|
||||
it('binds explicit Windows and mixed variants without normalizing script bytes', () => {
|
||||
const windows = { os_family: 'windows', interpreter: 'powershell', encoding: 'utf-8', script_utf8: "Write-Output 'hi'\r\n" };
|
||||
const linux = { os_family: 'linux', interpreter: 'posix_sh', encoding: 'utf-8', script_utf8: "printf hi\n" };
|
||||
const input: PlanInput = { tenant_id: 't', action: 'run_script', targets: { asset_ids: ['a', 'b'] }, parameters: { variants: [linux, windows], execution_identity: 'agent_service', timeout_seconds: 60, max_output_bytes: 4096 }, schedule: { not_before: new Date().toISOString(), start_before: new Date(Date.now() + 60000).toISOString(), offline_policy: 'wait_until_deadline' }, rollout: { max_parallel: 1, halt_after_failures: 1 }, reason: 'fixed mixed plan' };
|
||||
const original = JSON.stringify(input); validateInput(input); expect(JSON.stringify(input)).toBe(original);
|
||||
for (const variants of [[windows, windows], [{ ...windows, interpreter: 'pwsh' }], [{ ...windows, interpreter: 'bash' }], [{ ...windows, script_utf8: "Write-Output 'é'" }]]) expect(() => validateInput({ ...input, parameters: { ...input.parameters, variants } })).toThrow();
|
||||
expect(() => validateInput({ ...input, parameters: { ...input.parameters, execution_identity: 'root' } })).toThrow('agent_service');
|
||||
validateInput({ ...input, parameters: { ...input.parameters, variants: [{ ...windows, script_utf8: "\ufeffWrite-Output 'é'\r\n" }] } });
|
||||
});
|
||||
it('accepts explicit existing dev simulation evidence but not a principal-name guess', () => {
|
||||
expect(session({ principal: 'sim-test', tenant_id: 't', testsimulation: true, csrf_token: 'csrf' }).principal.simulated).toBe(true);
|
||||
expect(() => session({ principal: 'sim-test', tenant_id: 't', csrf_token: 'csrf' })).toThrow();
|
||||
|
||||
Reference in New Issue
Block a user