mirror of
https://github.com/wahyd4/heygo.git
synced 2026-08-09 05:15:52 +10:00
44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import {
|
|
AUTH_DISABLED_PROVIDERS,
|
|
AUTH_ENABLED_PROVIDERS,
|
|
AUTH_SESSION_COOKIE_NAME,
|
|
getSessionCookieAttributes,
|
|
isAuthProviderEnabled,
|
|
} from '../worker/auth';
|
|
|
|
describe('auth configuration constants', () => {
|
|
it('enables Google and GitHub while keeping Apple disabled', () => {
|
|
expect(AUTH_ENABLED_PROVIDERS).toEqual(['google', 'github']);
|
|
expect(AUTH_DISABLED_PROVIDERS).toEqual(['apple']);
|
|
expect(isAuthProviderEnabled('google')).toBe(true);
|
|
expect(isAuthProviderEnabled('github')).toBe(true);
|
|
expect(isAuthProviderEnabled('apple')).toBe(false);
|
|
});
|
|
|
|
it('uses the canonical session cookie name', () => {
|
|
expect(AUTH_SESSION_COOKIE_NAME).toBe('heygo_session');
|
|
});
|
|
});
|
|
|
|
describe('session cookie policy', () => {
|
|
it('uses a shared heygo.cc cookie domain in production', () => {
|
|
expect(getSessionCookieAttributes('https://my.heygo.cc/app')).toEqual([
|
|
'HttpOnly',
|
|
'Secure',
|
|
'SameSite=Lax',
|
|
'Path=/',
|
|
'Domain=.heygo.cc',
|
|
]);
|
|
});
|
|
|
|
it('omits Domain for localhost development', () => {
|
|
expect(getSessionCookieAttributes('http://localhost:5173/app')).toEqual([
|
|
'HttpOnly',
|
|
'Secure',
|
|
'SameSite=Lax',
|
|
'Path=/',
|
|
]);
|
|
});
|
|
});
|