mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-02 09:01:33 +00:00
fix(test): fully redact live media credentials (#112883)
This commit is contained in:
committed by
GitHub
parent
b3e2af7eb2
commit
aed2e6ff3f
@@ -87,7 +87,8 @@ describe("image-generation live-test helpers", () => {
|
||||
|
||||
it("redacts live API keys for diagnostics", () => {
|
||||
expect(redactLiveApiKey(undefined)).toBe("none");
|
||||
expect(redactLiveApiKey("short-key")).toBe("short-key");
|
||||
expect(redactLiveApiKey("sk-proj-1234567890")).toBe("sk-proj-...7890");
|
||||
expect(redactLiveApiKey(" ")).toBe("none");
|
||||
expect(redactLiveApiKey("synthetic-12")).toBe("<redacted>");
|
||||
expect(redactLiveApiKey("synthetic-credential-value")).toBe("<redacted>");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -12,16 +12,13 @@ type LiveProviderModelConfig =
|
||||
}
|
||||
| undefined;
|
||||
|
||||
/** Redacts live API keys while preserving enough shape for diagnostics. */
|
||||
/** Redacts live API keys without retaining credential-derived text in test output. */
|
||||
export function redactLiveApiKey(value: string | undefined): string {
|
||||
const trimmed = value?.trim();
|
||||
if (!trimmed) {
|
||||
return "none";
|
||||
}
|
||||
if (trimmed.length <= 12) {
|
||||
return trimmed;
|
||||
}
|
||||
return `${trimmed.slice(0, 8)}...${trimmed.slice(-4)}`;
|
||||
return "<redacted>";
|
||||
}
|
||||
|
||||
/** Parses comma-separated live-test filters; null means "all". */
|
||||
|
||||
@@ -80,8 +80,9 @@ describe("video-generation live-test helpers", () => {
|
||||
|
||||
it("redacts live API keys for diagnostics", () => {
|
||||
expect(redactLiveApiKey(undefined)).toBe("none");
|
||||
expect(redactLiveApiKey("short-key")).toBe("short-key");
|
||||
expect(redactLiveApiKey("sk-proj-1234567890")).toBe("sk-proj-...7890");
|
||||
expect(redactLiveApiKey(" ")).toBe("none");
|
||||
expect(redactLiveApiKey("synthetic-12")).toBe("<redacted>");
|
||||
expect(redactLiveApiKey("synthetic-credential-value")).toBe("<redacted>");
|
||||
});
|
||||
|
||||
it("runs buffer-backed video-to-video only for supported providers/models", () => {
|
||||
|
||||
Reference in New Issue
Block a user