2026-04-24 17:03:57 +02:00
|
|
|
import { describe, it, expect } from 'vitest';
|
2026-04-24 16:59:50 +02:00
|
|
|
import { resolveAuthConfig } from './auth';
|
|
|
|
|
|
|
|
|
|
describe('resolveAuthConfig', () => {
|
|
|
|
|
it('returns both URLs and sales email from env', () => {
|
|
|
|
|
const cfg = resolveAuthConfig({
|
|
|
|
|
PUBLIC_AUTH_SIGNIN_URL: 'https://auth.cameleer.io/sign-in',
|
|
|
|
|
PUBLIC_AUTH_SIGNUP_URL: 'https://auth.cameleer.io/sign-in?first_screen=register',
|
|
|
|
|
PUBLIC_SALES_EMAIL: 'sales@cameleer.io',
|
|
|
|
|
});
|
|
|
|
|
expect(cfg.signInUrl).toBe('https://auth.cameleer.io/sign-in');
|
|
|
|
|
expect(cfg.signUpUrl).toBe('https://auth.cameleer.io/sign-in?first_screen=register');
|
|
|
|
|
expect(cfg.salesEmail).toBe('sales@cameleer.io');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('throws if PUBLIC_AUTH_SIGNIN_URL is missing', () => {
|
|
|
|
|
expect(() => resolveAuthConfig({
|
|
|
|
|
PUBLIC_AUTH_SIGNUP_URL: 'https://auth.cameleer.io/sign-in?first_screen=register',
|
|
|
|
|
PUBLIC_SALES_EMAIL: 'sales@cameleer.io',
|
|
|
|
|
})).toThrow(/PUBLIC_AUTH_SIGNIN_URL/);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('throws if a URL is not https', () => {
|
|
|
|
|
expect(() => resolveAuthConfig({
|
|
|
|
|
PUBLIC_AUTH_SIGNIN_URL: 'http://auth.cameleer.io/sign-in',
|
|
|
|
|
PUBLIC_AUTH_SIGNUP_URL: 'https://auth.cameleer.io/sign-in?first_screen=register',
|
|
|
|
|
PUBLIC_SALES_EMAIL: 'sales@cameleer.io',
|
|
|
|
|
})).toThrow(/must be https/);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('throws if sales email is not a valid mailto target', () => {
|
|
|
|
|
expect(() => resolveAuthConfig({
|
|
|
|
|
PUBLIC_AUTH_SIGNIN_URL: 'https://auth.cameleer.io/sign-in',
|
|
|
|
|
PUBLIC_AUTH_SIGNUP_URL: 'https://auth.cameleer.io/sign-in?first_screen=register',
|
|
|
|
|
PUBLIC_SALES_EMAIL: 'not-an-email',
|
|
|
|
|
})).toThrow(/PUBLIC_SALES_EMAIL/);
|
|
|
|
|
});
|
|
|
|
|
|
2026-04-24 17:03:57 +02:00
|
|
|
it('throws if PUBLIC_AUTH_SIGNUP_URL is missing', () => {
|
|
|
|
|
expect(() => resolveAuthConfig({
|
|
|
|
|
PUBLIC_AUTH_SIGNIN_URL: 'https://auth.cameleer.io/sign-in',
|
|
|
|
|
PUBLIC_SALES_EMAIL: 'sales@cameleer.io',
|
|
|
|
|
})).toThrow(/PUBLIC_AUTH_SIGNUP_URL/);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('throws if PUBLIC_AUTH_SIGNUP_URL is not https', () => {
|
|
|
|
|
expect(() => resolveAuthConfig({
|
|
|
|
|
PUBLIC_AUTH_SIGNIN_URL: 'https://auth.cameleer.io/sign-in',
|
|
|
|
|
PUBLIC_AUTH_SIGNUP_URL: 'http://auth.cameleer.io/sign-in?first_screen=register',
|
|
|
|
|
PUBLIC_SALES_EMAIL: 'sales@cameleer.io',
|
|
|
|
|
})).toThrow(/must be https/);
|
|
|
|
|
});
|
|
|
|
|
|
2026-04-24 16:59:50 +02:00
|
|
|
it('exposes signUpUrl distinct from signInUrl', () => {
|
|
|
|
|
const cfg = resolveAuthConfig({
|
|
|
|
|
PUBLIC_AUTH_SIGNIN_URL: 'https://auth.cameleer.io/sign-in',
|
|
|
|
|
PUBLIC_AUTH_SIGNUP_URL: 'https://auth.cameleer.io/sign-in?first_screen=register',
|
|
|
|
|
PUBLIC_SALES_EMAIL: 'sales@cameleer.io',
|
|
|
|
|
});
|
|
|
|
|
expect(cfg.signUpUrl).not.toBe(cfg.signInUrl);
|
|
|
|
|
});
|
|
|
|
|
});
|