Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions packages/cli/src/config/auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ describe('validateAuthMethod', () => {
vi.stubEnv('GOOGLE_CLOUD_PROJECT', undefined);
vi.stubEnv('GOOGLE_CLOUD_LOCATION', undefined);
vi.stubEnv('GOOGLE_API_KEY', undefined);
vi.stubEnv('GOOGLE_GEMINI_BASE_URL', '');
});

afterEach(() => {
Expand Down Expand Up @@ -92,6 +93,22 @@ describe('validateAuthMethod', () => {
'• GOOGLE_API_KEY environment variable (if using express mode).\n' +
'Update your environment and try again (no reload needed if using .env)!',
},
{
description:
'should return null for GATEWAY if GOOGLE_GEMINI_BASE_URL is set',
authType: AuthType.GATEWAY,
envs: {
GOOGLE_GEMINI_BASE_URL: 'http://127.0.0.1:8080',
},
expected: null,
},
{
description:
'should return an error message for GATEWAY if GOOGLE_GEMINI_BASE_URL is not set',
authType: AuthType.GATEWAY,
envs: {},
expected: 'When using Gateway auth, GOOGLE_GEMINI_BASE_URL must be set.',
},
{
description: 'should return an error message for an invalid auth method',
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
8 changes: 8 additions & 0 deletions packages/cli/src/config/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,13 @@ export async function validateAuthMethod(
return null;
}

if (authMethod === AuthType.GATEWAY) {
if (!process.env['GOOGLE_GEMINI_BASE_URL']) {
return 'When using Gateway auth, GOOGLE_GEMINI_BASE_URL must be set.';
}

return null;
}

return 'Invalid auth method selected.';
}