Files
OmniRoute/tests/unit/catalog-cache-auth-fingerprint.test.ts
Ravi Tharuma 611466b419 fix(api): hash API keys in the v1 models catalog cache key
Validated in local merge-train-equivalent focused gate on release/v3.8.50 tip 9081b57146: catalog fingerprint regression + existing catalog-cache callers, 8 tests passed.
2026-08-17 09:50:52 -03:00

16 lines
645 B
TypeScript

import assert from "node:assert/strict";
import { test } from "node:test";
import { fingerprintCatalogAuthKey } from "../../src/app/api/v1/models/catalogCache.ts";
test("fingerprintCatalogAuthKey never returns the raw API key", () => {
const raw = "sk-test-super-secret-catalog-key";
const finger = fingerprintCatalogAuthKey(raw);
assert.equal(finger.length, 16);
assert.equal(finger.includes(raw), false);
assert.equal(finger.includes("sk-test"), false);
assert.equal(fingerprintCatalogAuthKey(raw), finger);
assert.notEqual(fingerprintCatalogAuthKey("sk-other"), finger);
assert.equal(fingerprintCatalogAuthKey(""), "");
});