Qualify tenant-scoped bootstrap rotation and fresh Windows scripting

This commit is contained in:
2026-11-17 16:19:08 +01:00
parent 81fcd9c8f8
commit fbd24b6d75
26 changed files with 877 additions and 118 deletions
+12
View File
@@ -1,3 +1,4 @@
import { windowsUpdateScriptHash } from './script-console';
import { expect, it, vi } from 'vitest';
import { renderToStaticMarkup } from 'react-dom/server';
import { ConsoleOutput, outputBytes, outputText } from './console-output';
@@ -25,3 +26,14 @@ it('distinguishes no result, empty bytes, invalid encoding, invalid bytes and mi
const bytes = outputBytes([239, 187, 191, 65, 13, 10]);
expect(outputText(bytes).text).toBe('\\ufeffA\\u000d\n'); expect(Array.from(bytes)).toEqual([239, 187, 191, 65, 13, 10]);
});
it('shows unknown restart state for an incomplete Windows Update summary', () => {
function rendered(hash: string) {
const result = { stdout: [], stderr: [], reboot_required: false, evidence: {
script_sha256: hash, windows_update_reboot_required: null
}};
return renderToStaticMarkup(<ConsoleOutput job={{ result }}/>);
}
expect(rendered(windowsUpdateScriptHash)).toContain('Neustartbedarf: unknown');
expect(rendered('ordinary script')).toContain('Neustartbedarf: false');
});
+3 -2
View File
@@ -1,3 +1,4 @@
import { windowsUpdateScriptHash } from './script-console';
import { record, RecordValue, stringField } from './api';
/** The wire format carries bytes, not an encoding declaration. Never guess a
@@ -45,8 +46,8 @@ export function ConsoleOutput({ job }: { job: RecordValue }) {
function Result({ value }: { value: unknown }) {
try {
const result = record(value, 'Jobergebnis');
const evidence = result.evidence && typeof result.evidence === 'object' ? record(result.evidence) : {};
const reboot = Object.hasOwn(evidence, 'windows_update_reboot_required') ? evidence.windows_update_reboot_required : result.reboot_required;
const evidence = result.evidence && typeof result.evidence === 'object' && !Array.isArray(result.evidence) ? record(result.evidence) : {};
const reboot = evidence.script_sha256 === windowsUpdateScriptHash && Object.hasOwn(evidence, 'windows_update_reboot_required') ? evidence.windows_update_reboot_required : result.reboot_required;
return <><p>Exitcode: {typeof result.exit_code === 'number' && Number.isInteger(result.exit_code) ? result.exit_code : 'unknown / nicht gemeldet'} · Fehlercode: {typeof result.error_code === 'string' && result.error_code ? result.error_code : 'nicht gemeldet'}</p>
<p className={result.output_truncated === false ? 'muted' : 'warning'}>Ausgabe begrenzt: {typeof result.output_truncated === 'boolean' ? String(result.output_truncated) : 'unknown'}. {result.output_truncated === true ? 'Die gespeicherten Bytes sind nur ein Ausschnitt.' : result.output_truncated !== false ? 'Vollständigkeit ist nicht bestätigt.' : 'Keine Trunkierung gemeldet.'}</p>
<p>Neustartbedarf: {typeof reboot === 'boolean' ? String(reboot) : 'unknown'}. Ein Exitcode 0 bestätigt Prozessabschluss; fachliche Nachbedingungen stehen im vollständigen Ergebnis.</p>