35 lines
1.7 KiB
TypeScript
35 lines
1.7 KiB
TypeScript
import { expect, test } from '@playwright/test';
|
|
import { assertLocalUrl } from '../../support/auth-config';
|
|
import { localDbConfig } from '../../support/db';
|
|
|
|
test.describe('E2E-Guards: Tests laufen nur gegen lokale Dienste', () => {
|
|
test('db.ts: lokale Hosts werden akzeptiert (inkl. IPv6 in Klammern)', () => {
|
|
for (const url of [
|
|
'postgresql://postgres:postgres@127.0.0.1:54322/postgres',
|
|
'postgresql://postgres:postgres@localhost:54322/postgres',
|
|
'postgresql://postgres:postgres@[::1]:54322/postgres',
|
|
]) {
|
|
expect(() => localDbConfig(url), url).not.toThrow();
|
|
}
|
|
});
|
|
|
|
test('db.ts: fremde Hosts werden abgelehnt', () => {
|
|
expect(() => localDbConfig('postgresql://u:p@db.example.com:5432/postgres')).toThrow(/nicht erlaubt/);
|
|
});
|
|
|
|
test('db.ts: ?host= kann den Guard nicht umgehen', () => {
|
|
expect(() => localDbConfig('postgresql://u:p@127.0.0.1:5432/postgres?host=db.example.com')).toThrow(/nicht erlaubt/);
|
|
expect(() => localDbConfig('postgresql://u:p@localhost/postgres?host=/var/run/postgresql,db.example.com')).toThrow();
|
|
});
|
|
|
|
test('db.ts: Host-Namen mit lokalem Praefix/Suffix gelten nicht als lokal', () => {
|
|
expect(() => localDbConfig('postgresql://u:p@localhost.evil.com:5432/postgres')).toThrow();
|
|
expect(() => localDbConfig('postgresql://u:p@127.0.0.1.evil.com:5432/postgres')).toThrow();
|
|
});
|
|
|
|
test('SUPABASE_URL/MAILPIT_URL: nur lokale Hosts', () => {
|
|
expect(() => assertLocalUrl('X', 'http://127.0.0.1:54321')).not.toThrow();
|
|
expect(() => assertLocalUrl('X', 'http://[::1]:54321')).not.toThrow();
|
|
expect(() => assertLocalUrl('X', 'https://abc.supabase.co')).toThrow(/nicht lokal/);
|
|
});
|
|
});
|