fix(gateway): 전용 데이터베이스 URL을 우선 사용한다
릴리스 프로세스가 전달한 GATEWAY_DATABASE_URL을 API와 orchestrator가 직접 사용하도록 고친다. 원시 POSTGRES_* 재조합으로 특수문자 비밀번호가 깨지는 회귀를 테스트한다.
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import { resolveGatewayPostgresConfigFromEnv } from '../src/gatewayPostgresConfig.js';
|
||||
|
||||
describe('resolveGatewayPostgresConfigFromEnv', () => {
|
||||
it('uses the encoded Gateway URL instead of rebuilding one from raw PostgreSQL credentials', () => {
|
||||
const config = resolveGatewayPostgresConfigFromEnv(
|
||||
{
|
||||
GATEWAY_DATABASE_URL: 'postgresql://sammo:encoded%23password@postgres:5432/sammo?schema=legacy',
|
||||
POSTGRES_USER: 'sammo',
|
||||
POSTGRES_PASSWORD: 'raw#password',
|
||||
POSTGRES_HOST: 'postgres',
|
||||
POSTGRES_PORT: '5432',
|
||||
POSTGRES_DB: 'sammo',
|
||||
POSTGRES_POOL_MAX: '4',
|
||||
},
|
||||
'public'
|
||||
);
|
||||
|
||||
const parsed = new URL(config.url);
|
||||
expect(parsed.password).toBe('encoded%23password');
|
||||
expect(parsed.searchParams.get('schema')).toBe('public');
|
||||
expect(config.maxConnections).toBe(4);
|
||||
});
|
||||
|
||||
it('keeps DATABASE_URL as the fallback for existing launchers', () => {
|
||||
const config = resolveGatewayPostgresConfigFromEnv({
|
||||
DATABASE_URL: 'postgresql://sammo:password@postgres:5432/sammo?schema=public',
|
||||
});
|
||||
|
||||
expect(config.url).toBe('postgresql://sammo:password@postgres:5432/sammo?schema=public');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user