mirror of
https://github.com/nicotsx/zerobyte.git
synced 2026-08-02 02:56:10 -04:00
* 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
22 lines
793 B
TypeScript
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);
|
|
});
|
|
});
|