mirror of
https://github.com/tale/headplane.git
synced 2026-07-26 15:58:14 +00:00
96f2721272
Closes HP-353.
38 lines
882 B
TypeScript
38 lines
882 B
TypeScript
import { drizzle } from "drizzle-orm/node-sqlite";
|
|
import { migrate } from "drizzle-orm/node-sqlite/migrator";
|
|
|
|
import { createAuthService } from "~/server/web/auth";
|
|
|
|
export function createTestAuth(
|
|
options: {
|
|
headscaleApiKey?: string;
|
|
proxyAuth?: {
|
|
enabled: boolean;
|
|
allowedCidrs?: string[];
|
|
trustedProxyCidrs?: string[];
|
|
ipHeader?: string;
|
|
userHeader?: string;
|
|
emailHeader?: string;
|
|
nameHeader?: string;
|
|
pictureHeader?: string;
|
|
};
|
|
} = {},
|
|
) {
|
|
const db = drizzle(":memory:");
|
|
migrate(db, { migrationsFolder: "./drizzle" });
|
|
|
|
const auth = createAuthService({
|
|
secret: "test-secret-key-for-unit-tests",
|
|
headscaleApiKey: options.headscaleApiKey,
|
|
proxyAuth: options.proxyAuth,
|
|
db,
|
|
cookie: {
|
|
name: "_hp_test",
|
|
secure: false,
|
|
maxAge: 3600,
|
|
},
|
|
});
|
|
|
|
return { auth, db };
|
|
}
|