Verify the fixed Windows LocalService PowerShell plan in the test WebUI
Rust development slice / linux (push) Failing after 7s

This commit is contained in:
2026-11-15 21:41:05 +01:00
parent e32f6330a0
commit 6fb973a247
+28 -3
View File
@@ -2,15 +2,32 @@
const fs = require('node:fs');
const path = require('node:path');
const crypto = require('node:crypto');
const { isDeepStrictEqual } = require('node:util');
const { chromium } = require('../../web/node_modules/playwright');
const root = path.resolve(__dirname, '../..');
const assert = (value) => { if (!value) throw new Error('UI contract mismatch'); };
function checkWindowsHello(job, planBytes) {
const payload = job.payload;
const action = {
action: 'run_script', interpreter: 'powershell', script_utf8: "Write-Output 'Zeitprofil-Test'\r\n",
arguments: [], expected_stdout: 'Zeitprofil-Test\r\n', windows_execution_profile: 'powershell_51_remote_signed',
};
const stored = JSON.parse(Buffer.from(planBytes).toString('utf8'));
assert(stored.jobs.length === 1 && isDeepStrictEqual(stored.jobs[0].payload, payload));
assert(payload.tenant_id === '11111111-1111-4111-8111-111111111111'
&& payload.agent_id === '63ea15b2-0643-403d-b5b4-cba1288dbea3'
&& payload.asset_id === 'a176520e-8a91-4e93-a78b-8e7620f430e0'
&& payload.execution_identity === 'agent_service' && isDeepStrictEqual(payload.action, action));
assert(stored.jobs[0].job_payload_hash === job.job_payload_hash
&& stored.jobs[0].script_sha256 === job.script_sha256
&& crypto.createHash('sha256').update(action.script_utf8, 'utf8').digest('hex') === job.script_sha256);
}
(async () => {
const file = path.resolve(process.argv[2]);
const stat = fs.lstatSync(file);
assert(stat.isFile() && !stat.isSymbolicLink() && stat.uid === process.getuid() && (stat.mode & 0o777) === 0o600);
const expected = JSON.parse(fs.readFileSync(file, 'utf8'));
assert(expected.profile === 'dev/test' && ['hello', 'refresh_inventory', 'cancel_queued'].includes(expected.case));
assert(expected.profile === 'dev/test' && ['hello', 'refresh_inventory', 'cancel_queued', 'windows_hello'].includes(expected.case));
assert(expected.expected_principal === 'simulated-testprincipal-a');
const loginFile = path.join(root, 'credentials/server-browser-login.json');
const loginStat = fs.lstatSync(loginFile);
@@ -38,7 +55,7 @@ const assert = (value) => { if (!value) throw new Error('UI contract mismatch');
assert(pending.approval_state === 'pending_approval' && pending.job_count === 0 && pending.execution_state === null);
await op.getByRole('button', { name: 'Unveränderlichen Plan zur Prüfung öffnen', exact: true }).click();
const detail = page.locator('section').filter({ has: page.getByRole('heading', { name: 'Unveränderlicher Plan / Genehmigungsdetail', exact: true }) });
const rendered = JSON.parse(await detail.locator('pre').first().innerText());
const rendered = JSON.parse(await detail.getByLabel('Alle festen Zielpreviews, exakte Skriptinhalte/Hashes, Parameter, Rechte, Fristen, Rollout und Nachbedingungen', { exact: true }).innerText());
assert(rendered.plan_hash === expected.plan.plan_hash && crypto.createHash('sha256').update(Buffer.from(rendered.plan_payload_bytes)).digest('hex') === expected.plan.plan_hash);
assert(JSON.stringify(rendered.plan_payload_bytes) === JSON.stringify(expected.plan.plan_payload_bytes));
assert(rendered.jobs.length === 1 && rendered.resolved_targets.length === 1);
@@ -47,7 +64,15 @@ const assert = (value) => { if (!value) throw new Error('UI contract mismatch');
assert(payload.agent_id === expected.agent_id && payload.asset_id === expected.asset_id && payload.tenant_id === expected.tenant_id);
assert(payload.execution_identity === 'agent_service' && payload.max_runtime_seconds === 60 && payload.max_output_bytes <= 65536);
assert(Date.parse(payload.start_before) > Date.now());
if (expected.case === 'hello' || expected.case === 'cancel_queued') assert(payload.action.action === 'run_script' && payload.action.interpreter === 'posix_sh' && payload.action.script_utf8 === "printf '%s\\n' 'Hello World'\n" && payload.action.expected_stdout === 'Hello World\n');
if (expected.case === 'windows_hello') {
checkWindowsHello(job, rendered.plan_payload_bytes);
assert(expected.stage === 'pending_approval' && expected.preapproval.jobs === 0
&& expected.preapproval.outbox === 0 && expected.preapproval.permits === 0);
assert(pending.plan_id === rendered.plan_id && pending.operation_id === expected.operation_id);
await detail.getByLabel('Feste PowerShell-Prozessprofile', { exact: true })
.getByText('Asset: ' + payload.asset_id + ' · Windows PowerShell5.1 · agent_service · RemoteSigned · nur Jobprozess', { exact: true }).waitFor();
}
else if (expected.case === 'hello' || expected.case === 'cancel_queued') assert(payload.action.action === 'run_script' && payload.action.interpreter === 'posix_sh' && payload.action.script_utf8 === "printf '%s\\n' 'Hello World'\n" && payload.action.expected_stdout === 'Hello World\n');
else assert(payload.action.action === 'refresh_inventory' && payload.action.scope === 'linux.base');
const approve = detail.getByRole('button', { name: 'SIMULIERT: Diesen festen Plan ausdrücklich genehmigen', exact: true });
assert(await approve.isDisabled());