24 lines
862 B
TypeScript
24 lines
862 B
TypeScript
import assert from "node:assert/strict";
|
|
import { readFile } from "node:fs/promises";
|
|
import { join } from "node:path";
|
|
import test from "node:test";
|
|
|
|
const authServerPath = join(process.cwd(), "lib", "auth-server.ts");
|
|
|
|
test("server auth utilities reuse valid Convex JWT cookies", async () => {
|
|
const source = await readFile(authServerPath, "utf8");
|
|
|
|
assert.match(source, /jwtCache:\s*\{/);
|
|
assert.match(source, /enabled:\s*true/);
|
|
assert.match(source, /isAuthError:\s*isConvexAuthError/);
|
|
});
|
|
|
|
test("server auth error predicate keeps stale token refresh possible", async () => {
|
|
const source = await readFile(authServerPath, "utf8");
|
|
|
|
assert.match(source, /function isConvexAuthError\(error: unknown\): boolean/);
|
|
assert.match(source, /Unauthenticated/);
|
|
assert.match(source, /Unauthorized/);
|
|
assert.doesNotMatch(source, /InvalidToken/);
|
|
});
|