Oloka-Video-Dev / apps /server /src /kernel /app-key.unit.test.ts
phucsd's picture
Deploy GitHub commit 1aa2e3555f9cd297eaf994af95fb4d10c5b1aff1
ad2afbf verified
Raw History Blame Contribute Delete
557 Bytes
import { describe, expect, it } from "vitest";
import { decodeApplicationKey } from "./app-key.js";
describe("decodeApplicationKey", () => {
it("accepts only an unpadded base64url encoding of exactly 32 bytes", () => {
const encoded = Buffer.alloc(32, 7).toString("base64url");
expect(decodeApplicationKey(encoded)).toEqual(Buffer.alloc(32, 7));
expect(() => decodeApplicationKey(`${encoded}=`)).toThrow(/base64url/i);
expect(() =>
decodeApplicationKey(Buffer.alloc(31).toString("base64url")),
).toThrow(/32 bytes/i);
});
});