feat: centralize application framework primitives
This commit is contained in:
@@ -4,6 +4,25 @@ import { MemoryAuthStore } from "../src/stores/memory.ts";
|
||||
import { generateTotp } from "../src/totp/index.ts";
|
||||
import type { AuthDeliveryMessage, PasskeyProvider } from "../src/types.ts";
|
||||
|
||||
test("authentication storage factories resolve lazily and only once", async () => {
|
||||
let calls = 0;
|
||||
const backing = new MemoryAuthStore();
|
||||
const engine = createAuthEngine({
|
||||
store: () => {
|
||||
calls++;
|
||||
return backing;
|
||||
},
|
||||
secret: "a secure test secret that is longer than thirty-two characters",
|
||||
});
|
||||
|
||||
expect(calls).toBe(0);
|
||||
expect(engine.store).toBeDefined();
|
||||
expect(calls).toBe(0);
|
||||
await engine.getUser("missing");
|
||||
await engine.getUser("still-missing");
|
||||
expect(calls).toBe(1);
|
||||
});
|
||||
|
||||
function fixture() {
|
||||
let time = 1_720_000_000_000;
|
||||
let seed = 11;
|
||||
|
||||
Reference in New Issue
Block a user