H-385: validate Clark CDP network event loop (#1)
This commit was merged in pull request #1.
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { randomUUID } from "node:crypto";
|
||||
import test from "node:test";
|
||||
|
||||
import { boundedBody, redactHeaders, safeUrl, shouldRetryStartup } from "../scripts/m0-spike.mjs";
|
||||
|
||||
test("export policy redacts credentials and bounds bodies", () => {
|
||||
const sensitive = randomUUID();
|
||||
assert.deepEqual(redactHeaders({ Cookie: sensitive, Authorization: sensitive, Referer: "https://example.test/private", "Set-Cookie": sensitive, Accept: "*/*" }), {
|
||||
accept: "*/*",
|
||||
authorization: "[REDACTED]",
|
||||
cookie: "[REDACTED]",
|
||||
referer: "[REDACTED]",
|
||||
"set-cookie": "[REDACTED]",
|
||||
});
|
||||
assert.equal(safeUrl("https://example.test/path?token=secret"), "https://example.test/path?<redacted>");
|
||||
assert.deepEqual(boundedBody(sensitive, false, 100), { state: "fetched", storage: "omitted", reason: "default_body_policy", bytes: Buffer.byteLength(sensitive) });
|
||||
assert(!JSON.stringify(boundedBody(sensitive, false, 100)).includes(sensitive));
|
||||
assert.deepEqual(boundedBody("hello!", false, 5), { state: "size_limit", storage: "omitted", bytes: 6 });
|
||||
assert(shouldRetryStartup("Render process gone."));
|
||||
assert(!shouldRetryStartup("Target closed."));
|
||||
assert(!shouldRetryStartup(undefined));
|
||||
});
|
||||
Reference in New Issue
Block a user