mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-07 04:12:04 +00:00
test(ops): prove the journey's redactor on a key-shaped body
Low, review 2. The self-test walked every leg but never once asked whether the redactor actually holds. The excerpt path is the only thing between a token in a failure body and the run log, so it gets its own case: a body carrying this project's own key prefix must come back with the token replaced.
This commit is contained in:
1 parent
3ba2fe3b82
commit
79cb08efc7
1 file changed
+18
-2
@@ -673,6 +673,22 @@ function selfTestHostAllowlist() {
|
||||
return failures;
|
||||
}
|
||||
|
||||
/**
|
||||
* The excerpt path is what keeps a token out of a failure log. Prove it
|
||||
* once, on a body shaped like this project's own key prefix.
|
||||
*/
|
||||
function selfTestRedaction() {
|
||||
const shaped = `hlk_${"a".repeat(24)}`;
|
||||
const redacted = excerpt(`{"error":"bad token","token":"${shaped}"}`);
|
||||
const label = "redaction";
|
||||
if (redacted.includes("hlk_") || !redacted.includes("[redacted]")) {
|
||||
console.log(`self-test FAILED ${label.padEnd(44)} → ${redacted}`);
|
||||
return 1;
|
||||
}
|
||||
console.log(`self-test ok ${label.padEnd(44)} → ${redacted}`);
|
||||
return 0;
|
||||
}
|
||||
|
||||
async function selfTest() {
|
||||
const cases = [
|
||||
{ breaks: null, expect: "pass", clean: true },
|
||||
@@ -713,7 +729,7 @@ async function selfTest() {
|
||||
{ breaks: "delete: kept", expect: "fail", leg: "delete" },
|
||||
];
|
||||
|
||||
let failures = selfTestHostAllowlist();
|
||||
let failures = selfTestHostAllowlist() + selfTestRedaction();
|
||||
for (const testCase of cases) {
|
||||
const label = testCase.breaks ?? "nothing broken";
|
||||
const instance = await startMockInstance(testCase.breaks);
|
||||
@@ -752,7 +768,7 @@ async function selfTest() {
|
||||
return 1;
|
||||
}
|
||||
console.log(
|
||||
`\nself-test: ${cases.length} journey cases, every leg proven breakable; host allowlist proven`,
|
||||
`\nself-test: ${cases.length} journey cases, every leg proven breakable; host allowlist and redaction proven`,
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user