fix(test): fully redact live media credentials (#112883)

This commit is contained in:
Peter Steinberger
2026-07-23 00:31:29 -04:00
committed by GitHub
parent b3e2af7eb2
commit aed2e6ff3f
3 changed files with 8 additions and 9 deletions

View File

@@ -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>");
});
});

View File

@@ -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". */

View File

@@ -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", () => {