File size: 1,124 Bytes
fc93158 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | import { describe, expect, it } from "vitest";
import {
INVALID_EXEC_SECRET_REF_IDS,
VALID_EXEC_SECRET_REF_IDS,
} from "../test-utils/secret-ref-test-vectors.js";
import { isValidExecSecretRefId, validateExecSecretRefId } from "./ref-contract.js";
describe("exec secret ref id validation", () => {
it("accepts valid exec secret ref ids", () => {
for (const id of VALID_EXEC_SECRET_REF_IDS) {
expect(isValidExecSecretRefId(id), `expected valid id: ${id}`).toBe(true);
expect(validateExecSecretRefId(id)).toEqual({ ok: true });
}
});
it("rejects invalid exec secret ref ids", () => {
for (const id of INVALID_EXEC_SECRET_REF_IDS) {
expect(isValidExecSecretRefId(id), `expected invalid id: ${id}`).toBe(false);
expect(validateExecSecretRefId(id).ok).toBe(false);
}
});
it("reports traversal segment failures separately", () => {
expect(validateExecSecretRefId("a/../b")).toEqual({
ok: false,
reason: "traversal-segment",
});
expect(validateExecSecretRefId("a/./b")).toEqual({
ok: false,
reason: "traversal-segment",
});
});
});
|