Spaces:
Paused
Paused
Download src/proxy/dump.test.ts from bolikoto/zcode-daili: direct link, hf CLI and curl.
- Browser
- Download file 945 Bytes
-
https://huggingface.co/spaces/bolikoto/zcode-daili/resolve/main/src/proxy/dump.test.ts
- Command line
-
hf download hf://spaces/bolikoto/zcode-daili/src/proxy/dump.test.ts
-
curl -L -o dump.test.ts https://huggingface.co/spaces/bolikoto/zcode-daili/resolve/main/src/proxy/dump.test.ts
945 Bytes
| import { describe, expect, it } from "bun:test"; | |
| import { dumpHeaders } from "./dump.js"; | |
| describe("dumpHeaders", () => { | |
| it("masks routing JWT headers regardless of header-name casing", () => { | |
| const token = "Bearer synthetic.secret.jwt"; | |
| for (const name of ["X-ZCode-Authorization", "x-zcode-authorization", "X-ZCODE-AUTHORIZATION"]) { | |
| const dumped = dumpHeaders(new Headers({ [name]: token, "content-type": "application/json" })); | |
| expect(dumped["x-zcode-authorization"]).toBe("Bearer s….jwt (len=27)"); | |
| expect(JSON.stringify(dumped)).not.toContain(token); | |
| expect(JSON.stringify(dumped)).not.toContain("synthetic.secret.jwt"); | |
| expect(dumped["content-type"]).toBe("application/json"); | |
| } | |
| }); | |
| it("fully redacts short routing credentials", () => { | |
| expect(dumpHeaders(new Headers({ "X-ZCode-Authorization": "Bearer x" }))) | |
| .toEqual({ "x-zcode-authorization": "<redacted>" }); | |
| }); | |
| }); | |