mirror of
https://github.com/wahyd4/heygo.git
synced 2026-08-09 05:15:52 +10:00
- Terraform configs for D1 databases, KV namespaces, Worker custom domains - wrangler.dev.jsonc and wrangler.prod.jsonc for environment-specific deployments - Worker code refactored to use env vars for host checking (PUBLIC_HOST, PRIVATE_HOST) - Configurable app URLs and cookie domain via env vars - Deploy and migrate npm scripts for dev/prod - Updated all tests with new env fixtures - Deployment guide in README
54 lines
1.6 KiB
TypeScript
54 lines
1.6 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 the configured cookie domain when one is supplied', () => {
|
|
expect(getSessionCookieAttributes('https://my.heygo.cc/app', '.heygo.cc')).toEqual([
|
|
'HttpOnly',
|
|
'Secure',
|
|
'SameSite=Lax',
|
|
'Path=/',
|
|
'Domain=.heygo.cc',
|
|
]);
|
|
});
|
|
|
|
it('omits Domain when the cookie domain env var is empty (localhost development)', () => {
|
|
expect(getSessionCookieAttributes('http://localhost:5173/app', '')).toEqual([
|
|
'HttpOnly',
|
|
'Secure',
|
|
'SameSite=Lax',
|
|
'Path=/',
|
|
]);
|
|
});
|
|
|
|
it('honors an arbitrary dev cookie domain such as .junv.cc', () => {
|
|
expect(getSessionCookieAttributes('https://my.dev.junv.cc/app', '.junv.cc')).toEqual([
|
|
'HttpOnly',
|
|
'Secure',
|
|
'SameSite=Lax',
|
|
'Path=/',
|
|
'Domain=.junv.cc',
|
|
]);
|
|
});
|
|
});
|