35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import {
|
|
assertLocalAdminTarget,
|
|
localAdminSettings,
|
|
} from '../src/identity/local-admin-seed';
|
|
|
|
describe('local admin seed guard', () => {
|
|
it('accepts only development against loopback PostgreSQL', () => {
|
|
expect(() =>
|
|
assertLocalAdminTarget(
|
|
'development',
|
|
'postgresql://u:p@127.0.0.1:5432/local',
|
|
),
|
|
).not.toThrow();
|
|
expect(() =>
|
|
assertLocalAdminTarget('production', 'postgresql://u:p@127.0.0.1/local'),
|
|
).toThrow();
|
|
expect(() =>
|
|
assertLocalAdminTarget(
|
|
'development',
|
|
'postgresql://u:p@db.example.com/local',
|
|
),
|
|
).toThrow();
|
|
expect(() =>
|
|
assertLocalAdminTarget('development', 'https://localhost/local'),
|
|
).toThrow();
|
|
});
|
|
it('generates a unique strong password without a committed default', () => {
|
|
const first = localAdminSettings();
|
|
const second = localAdminSettings();
|
|
expect(first.OWNER_EMAIL).toBe('admin@manicandles.local');
|
|
expect(first.OWNER_PASSWORD.length).toBeGreaterThanOrEqual(40);
|
|
expect(first.OWNER_PASSWORD).not.toBe(second.OWNER_PASSWORD);
|
|
});
|
|
});
|