// @vitest-environment node import { readFile } from "node:fs/promises"; import { describe, expect, it } from "vitest"; const root = process.cwd(); describe("Aegida Gate deployment contract", () => { it("configures only the server-side Gate origin and coordinated JWT claims", async () => { const [environment, compose, kubernetes, readme] = await Promise.all([ read(".env.example"), read("docker-compose.yml"), read("k8s/config.yaml"), read("README.md"), ]); expect(environment).toContain("AEGIDA_GATE_URL=http://localhost:8082"); expect(compose).toContain("AEGIDA_GATE_URL: http://host.docker.internal:8082"); expect(kubernetes).toContain( "AEGIDA_GATE_URL: http://aegida-gate.aegida-services.svc.cluster.local:8080", ); for (const content of [environment, compose, kubernetes]) { expect(content).toContain("JWT_ISSUER"); expect(content).toContain("JWT_AUDIENCE"); expect(content).toContain("AEGIDA_TENANT_ID"); expect(content).not.toContain("AI_GATEWAY_MOCK"); expect(content).not.toContain("AI_GATEWAY_URL"); expect(content).not.toContain("AI_GATEWAY_API_KEY"); expect(content).not.toMatch(/NEXT_PUBLIC_[A-Z_]*GATE/); } expect(readme).toContain("JWT_HS256_SECRET"); expect(readme).toContain("legacy"); expect(compose).not.toContain("minio/minio:latest"); }); it("keeps every Gate integration server-only and removes the shared gateway key", async () => { const sources = await Promise.all([ read("lib/chat/catalog.ts"), read("lib/chat/gateway.ts"), read("lib/chat/gate-files.ts"), read("lib/chat/quota.ts"), ]); for (const source of sources) { expect(source).toContain('import "server-only"'); expect(source).toContain("process.env.AEGIDA_GATE_URL"); expect(source).not.toContain("process.env.NEXT_PUBLIC_"); expect(source).not.toContain("AI_GATEWAY_API_KEY"); } }); }); function read(path: string): Promise { return readFile(`${root}/${path}`, "utf8"); }