auth-cookie-constant-sync.test.ts 897 B

1234567891011121314151617181920212223
  1. import { readFileSync } from "node:fs";
  2. import { join } from "node:path";
  3. import { describe, expect, it } from "vitest";
  4. import { AUTH_COOKIE_NAME } from "@/lib/auth";
  5. const readSource = (relativePath: string) =>
  6. readFileSync(join(process.cwd(), relativePath), "utf8");
  7. describe("auth cookie constant sync", () => {
  8. it("keeps AUTH_COOKIE_NAME stable", () => {
  9. expect(AUTH_COOKIE_NAME).toBe("auth-token");
  10. });
  11. it("removes hardcoded auth-token cookie literals from core auth layers", () => {
  12. const proxySource = readSource("src/proxy.ts");
  13. const actionAdapterSource = readSource("src/lib/api/action-adapter-openapi.ts");
  14. expect(proxySource).not.toMatch(/["']auth-token["']/);
  15. expect(actionAdapterSource).not.toMatch(/["']auth-token["']/);
  16. expect(proxySource).toContain("AUTH_COOKIE_NAME");
  17. expect(actionAdapterSource).toContain("AUTH_COOKIE_NAME");
  18. });
  19. });