fix: cache Convex JWT in server auth
This commit is contained in:
23
tests/auth-server-jwt-cache.test.ts
Normal file
23
tests/auth-server-jwt-cache.test.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
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/);
|
||||
});
|
||||
Reference in New Issue
Block a user