test-config.helper.tsβ’1.42 kB
/**
* Sets up environment variables for tests
* Call this in test setup to ensure required MCP auth env vars are set
*/
export const setupTestEnvironment = () => {
process.env.NODE_ENV = 'development'
process.env.JWT_EXPIRES_IN = '3600'
process.env.ALLOWED_EMAILS = 'test@example.com,admin@test.com'
process.env.MCP_AUTH_CLIENT_ID = 'test-google-client-id'
process.env.MCP_AUTH_CLIENT_SECRET = 'test-google-client-secret'
process.env.MCP_AUTH_JWT_SECRET = 'test-secret-key-for-testing-only'
process.env.MCP_AUTH_SERVER_URL = 'http://localhost:3000'
}
/**
* Mock ConfigService for E2E and integration tests
* Provides all required configuration values for MCP auth and other services
*/
export const createMockConfigService = () => ({
get: (key: string, defaultValue?: string) => {
const config: Record<string, string> = {
// Node Environment
NODE_ENV: 'development',
// JWT Configuration
JWT_EXPIRES_IN: '3600',
// User Allowlist (for MCP authentication)
ALLOWED_EMAILS: 'test@example.com,admin@test.com',
// MCP Authentication Configuration (via @rekog/mcp-nest)
MCP_AUTH_CLIENT_ID: 'test-google-client-id',
MCP_AUTH_CLIENT_SECRET: 'test-google-client-secret',
MCP_AUTH_JWT_SECRET: 'test-secret-key-for-testing-only',
MCP_AUTH_SERVER_URL: 'http://localhost:3000',
}
return config[key] || defaultValue || ''
},
})