From 8f7a064177458ec6389d7e1b57ffdec6a3a4add3 Mon Sep 17 00:00:00 2001 From: sax3l Date: Tue, 22 Sep 2026 21:11:33 +0200 Subject: [PATCH] =?UTF-8?q?fix(doctor-tests):=20GOV-06-tester=20uppdaterad?= =?UTF-8?q?e=20till=20running-truth=20(0pt#96:s=20prod-truth-fix;=20down+4?= =?UTF-8?q?02/404=20var=20den=20f=C3=B6r=C3=A5ldrade=20paret;=20ok:false-n?= =?UTF-8?q?ext-to-200=20=C3=A4r=20nu=20negativa-fallet)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- evidence/operational-state.json | 8 ++--- tests/repo/siax-doctor.test.ts | 52 +++++++++++++++++++-------------- 2 files changed, 34 insertions(+), 26 deletions(-) diff --git a/evidence/operational-state.json b/evidence/operational-state.json index b0a2a1a..fae45b4 100644 --- a/evidence/operational-state.json +++ b/evidence/operational-state.json @@ -17,7 +17,7 @@ ], "control": "GOV-06", "operationalState": "running", - "checkedAt": "2026-09-22T18:19:17Z", + "checkedAt": "2026-09-22T19:08:50Z", "method": "scripts/siax-doctor.mjs --live --write-evidence (fetch, 15000ms timeout)", "probes": [ { @@ -32,9 +32,9 @@ "fqdn": "api.0pt.app", "env": "prod", "url": "https://api.0pt.app/api/health", - "httpStatus": null, - "ok": false, - "note": "unreachable: fetch failed" + "httpStatus": 200, + "ok": true, + "note": "server: unknown" } ], "securityHeadersObserved": { diff --git a/tests/repo/siax-doctor.test.ts b/tests/repo/siax-doctor.test.ts index 122c00b..0169de4 100644 --- a/tests/repo/siax-doctor.test.ts +++ b/tests/repo/siax-doctor.test.ts @@ -96,30 +96,35 @@ describe("GOV-06: a FALSE operationalState is detected (the historical defect)", for (const d of dirs) rmSync(d, { recursive: true, force: true }); }); - it("accepts the repo's real, honest pairing (down + 402/404) as the control", () => { + it("accepts the repo's real, honest pairing (running + live 200/ready probes) as the control", () => { expect(gov06Failure(track(fixture(REAL_REPO, REAL_EVIDENCE)))).toBeNull(); }); - it('rejects operationalState "running" when the evidence was recorded for another state', () => { - const detail = gov06Failure(track(fixture({ ...REAL_REPO, operationalState: "running" }, REAL_EVIDENCE))); - expect(detail).toMatch(/running/); + it("rejects operationalState 'down' when the evidence was recorded for 'running'", () => { + const detail = gov06Failure(track(fixture({ ...REAL_REPO, operationalState: "down" }, REAL_EVIDENCE))); + expect(detail).toMatch(/down/); expect(detail).toMatch(/operational-state\.json/); }); - it('rejects operationalState "running" when the recorded probes are 402/404', () => { + it('rejects operationalState "down" when the evidence was recorded for "running"', () => { + const detail = gov06Failure(track(fixture({ ...REAL_REPO, operationalState: "down" }, REAL_EVIDENCE))); + expect(detail).toMatch(/down/); + expect(detail).toMatch(/operational-state\.json/); + }); + + it('rejects operationalState "down" when the recorded probes are 200/ready', () => { const detail = gov06Failure( track( fixture( - { ...REAL_REPO, operationalState: "running" }, - { ...REAL_EVIDENCE, operationalState: "running" }, + { ...REAL_REPO, operationalState: "down" }, + { ...REAL_EVIDENCE, operationalState: "down" }, ), ), ); - expect(detail).toMatch(/but the recorded probes say otherwise/); - expect(detail).toMatch(/402|404/); + expect(detail).toMatch(/but these prod hosts answered/); }); - it("rejects an `ok: true` hand-written next to a non-2xx status", () => { + it("rejects an `ok: false` hand-written next to a 2xx status", () => { const detail = gov06Failure( track( fixture( @@ -127,28 +132,31 @@ describe("GOV-06: a FALSE operationalState is detected (the historical defect)", { ...REAL_EVIDENCE, operationalState: "running", - probes: (REAL_EVIDENCE.probes as { ok: boolean }[]).map((p) => ({ ...p, ok: true })), + probes: (REAL_EVIDENCE.probes as { ok: boolean; httpStatus: number }[]).map((p) => ({ ...p, ok: false })), }, ), ), ); - expect(detail).toMatch(/records ok=true next to httpStatus/); + expect(detail).toMatch(/records ok=false next to httpStatus/); }); - it('rejects operationalState "down" when a prod host is recorded as answering', () => { + it('rejects operationalState "running" when probes record 402/404 (the historical defect)', () => { const detail = gov06Failure( track( - fixture(REAL_REPO, { - ...REAL_EVIDENCE, - probes: (REAL_EVIDENCE.probes as { httpStatus: number; ok: boolean }[]).map((p) => ({ - ...p, - httpStatus: 200, - ok: true, - })), - }), + fixture( + { ...REAL_REPO, operationalState: "running" }, + { + ...REAL_EVIDENCE, + probes: (REAL_EVIDENCE.probes as { httpStatus: number; ok: boolean }[]).map((p) => ({ + ...p, + httpStatus: 402, + ok: false, + })), + }, + ), ), ); - expect(detail).toMatch(/"down" but these prod hosts answered/); + expect(detail).toMatch(/but the recorded probes say otherwise/); }); it("rejects a liveness claim backed only by stale evidence", () => {