mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-12 07:20:45 +00:00
test: avoid detect-secrets churn in observation fixtures
This commit is contained in:
@@ -205,7 +205,7 @@
|
|||||||
"filename": "apps/macos/Sources/OpenClawProtocol/GatewayModels.swift",
|
"filename": "apps/macos/Sources/OpenClawProtocol/GatewayModels.swift",
|
||||||
"hashed_secret": "7990585255d25249fb1e6eac3d2bd6c37429b2cd",
|
"hashed_secret": "7990585255d25249fb1e6eac3d2bd6c37429b2cd",
|
||||||
"is_verified": false,
|
"is_verified": false,
|
||||||
"line_number": 1763
|
"line_number": 1859
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"apps/macos/Tests/OpenClawIPCTests/AnthropicAuthResolverTests.swift": [
|
"apps/macos/Tests/OpenClawIPCTests/AnthropicAuthResolverTests.swift": [
|
||||||
@@ -266,7 +266,7 @@
|
|||||||
"filename": "apps/shared/OpenClawKit/Sources/OpenClawProtocol/GatewayModels.swift",
|
"filename": "apps/shared/OpenClawKit/Sources/OpenClawProtocol/GatewayModels.swift",
|
||||||
"hashed_secret": "7990585255d25249fb1e6eac3d2bd6c37429b2cd",
|
"hashed_secret": "7990585255d25249fb1e6eac3d2bd6c37429b2cd",
|
||||||
"is_verified": false,
|
"is_verified": false,
|
||||||
"line_number": 1763
|
"line_number": 1859
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"docs/.i18n/zh-CN.tm.jsonl": [
|
"docs/.i18n/zh-CN.tm.jsonl": [
|
||||||
@@ -11659,7 +11659,7 @@
|
|||||||
"filename": "src/agents/tools/web-search.ts",
|
"filename": "src/agents/tools/web-search.ts",
|
||||||
"hashed_secret": "dfba7aade0868074c2861c98e2a9a92f3178a51b",
|
"hashed_secret": "dfba7aade0868074c2861c98e2a9a92f3178a51b",
|
||||||
"is_verified": false,
|
"is_verified": false,
|
||||||
"line_number": 292
|
"line_number": 291
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"src/agents/tools/web-tools.enabled-defaults.e2e.test.ts": [
|
"src/agents/tools/web-tools.enabled-defaults.e2e.test.ts": [
|
||||||
@@ -13013,5 +13013,5 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"generated_at": "2026-03-09T08:37:13Z"
|
"generated_at": "2026-03-10T03:11:06Z"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ import {
|
|||||||
sanitizeForConsole,
|
sanitizeForConsole,
|
||||||
} from "./pi-embedded-error-observation.js";
|
} from "./pi-embedded-error-observation.js";
|
||||||
|
|
||||||
|
const OBSERVATION_BEARER_TOKEN = "sk-redact-test-token";
|
||||||
|
const OBSERVATION_COOKIE_VALUE = "session-cookie-token";
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
vi.restoreAllMocks();
|
vi.restoreAllMocks();
|
||||||
});
|
});
|
||||||
@@ -29,27 +32,27 @@ describe("buildApiErrorObservationFields", () => {
|
|||||||
|
|
||||||
it("forces token redaction for observation previews", () => {
|
it("forces token redaction for observation previews", () => {
|
||||||
const observed = buildApiErrorObservationFields(
|
const observed = buildApiErrorObservationFields(
|
||||||
"Authorization: Bearer sk-abcdefghijklmnopqrstuvwxyz123456",
|
`Authorization: Bearer ${OBSERVATION_BEARER_TOKEN}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(observed.rawErrorPreview).not.toContain("sk-abcdefghijklmnopqrstuvwxyz123456");
|
expect(observed.rawErrorPreview).not.toContain(OBSERVATION_BEARER_TOKEN);
|
||||||
expect(observed.rawErrorPreview).toContain("sk-abc");
|
expect(observed.rawErrorPreview).toContain(OBSERVATION_BEARER_TOKEN.slice(0, 6));
|
||||||
expect(observed.rawErrorHash).toMatch(/^sha256:/);
|
expect(observed.rawErrorHash).toMatch(/^sha256:/);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("redacts observation-only header and cookie formats", () => {
|
it("redacts observation-only header and cookie formats", () => {
|
||||||
const observed = buildApiErrorObservationFields(
|
const observed = buildApiErrorObservationFields(
|
||||||
"x-api-key: sk-abcdefghijklmnopqrstuvwxyz123456 Cookie: session=abcdefghijklmnopqrstuvwxyz123456",
|
`x-api-key: ${OBSERVATION_BEARER_TOKEN} Cookie: session=${OBSERVATION_COOKIE_VALUE}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(observed.rawErrorPreview).not.toContain("abcdefghijklmnopqrstuvwxyz123456");
|
expect(observed.rawErrorPreview).not.toContain(OBSERVATION_COOKIE_VALUE);
|
||||||
expect(observed.rawErrorPreview).toContain("x-api-key: ***");
|
expect(observed.rawErrorPreview).toContain("x-api-key: ***");
|
||||||
expect(observed.rawErrorPreview).toContain("Cookie: session=");
|
expect(observed.rawErrorPreview).toContain("Cookie: session=");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("does not let cookie redaction consume unrelated fields on the same line", () => {
|
it("does not let cookie redaction consume unrelated fields on the same line", () => {
|
||||||
const observed = buildApiErrorObservationFields(
|
const observed = buildApiErrorObservationFields(
|
||||||
"Cookie: session=abcdefghijklmnopqrstuvwxyz123456 status=503 request_id=req_cookie",
|
`Cookie: session=${OBSERVATION_COOKIE_VALUE} status=503 request_id=req_cookie`,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(observed.rawErrorPreview).toContain("Cookie: session=");
|
expect(observed.rawErrorPreview).toContain("Cookie: session=");
|
||||||
|
|||||||
Reference in New Issue
Block a user