Files
zerobyte/app/server/modules/auth/__tests__/auth.helpers.test.ts
Nico d24167b520 refactor(auth): mark desktop sessions with auth source (#990)
* refactor(auth): mark desktop sessions with auth source

Makes it easier to filter out on session type in backend paths that
behave differently depending on the context

* chore: fix un-used import

* fix(auth): align desktop session guards

* refactor(auth): gate desktop sessions by runtime features
2026-06-15 21:39:32 +02:00

22 lines
793 B
TypeScript

import { beforeEach, describe, expect, test } from "vitest";
import { config } from "~/server/core/config";
import { isPasswordAuthSupported, isSessionAuthSourceAllowed } from "../helpers";
describe("auth helpers", () => {
beforeEach(() => {
config.runtime = "server";
});
test("allows only the runtime session source and models password auth as a runtime feature", () => {
expect(isPasswordAuthSupported()).toBe(true);
expect(isSessionAuthSourceAllowed("browser-session")).toBe(true);
expect(isSessionAuthSourceAllowed("desktop-session")).toBe(false);
config.runtime = "desktop";
expect(isPasswordAuthSupported()).toBe(false);
expect(isSessionAuthSourceAllowed("browser-session")).toBe(false);
expect(isSessionAuthSourceAllowed("desktop-session")).toBe(true);
});
});