mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-23 19:44:30 -07:00
feat(auth): Add option for metadata server application default credentials without project override (#12948)
This commit is contained in:
@@ -318,7 +318,7 @@ describe('oauth2', () => {
|
||||
});
|
||||
|
||||
it('should use Compute to get a client if no cached credentials exist', async () => {
|
||||
await getOauthClient(AuthType.CLOUD_SHELL, mockConfig);
|
||||
await getOauthClient(AuthType.COMPUTE_ADC, mockConfig);
|
||||
|
||||
expect(Compute).toHaveBeenCalledWith({});
|
||||
expect(mockGetAccessToken).toHaveBeenCalled();
|
||||
@@ -329,7 +329,7 @@ describe('oauth2', () => {
|
||||
mockComputeClient.credentials = newCredentials;
|
||||
mockGetAccessToken.mockResolvedValue({ token: 'new-adc-token' });
|
||||
|
||||
await getOauthClient(AuthType.CLOUD_SHELL, mockConfig);
|
||||
await getOauthClient(AuthType.COMPUTE_ADC, mockConfig);
|
||||
|
||||
const credsPath = path.join(
|
||||
tempHomeDir,
|
||||
@@ -340,7 +340,7 @@ describe('oauth2', () => {
|
||||
});
|
||||
|
||||
it('should return the Compute client on successful ADC authentication', async () => {
|
||||
const client = await getOauthClient(AuthType.CLOUD_SHELL, mockConfig);
|
||||
const client = await getOauthClient(AuthType.COMPUTE_ADC, mockConfig);
|
||||
expect(client).toBe(mockComputeClient);
|
||||
});
|
||||
|
||||
@@ -349,9 +349,9 @@ describe('oauth2', () => {
|
||||
mockGetAccessToken.mockRejectedValue(testError);
|
||||
|
||||
await expect(
|
||||
getOauthClient(AuthType.CLOUD_SHELL, mockConfig),
|
||||
getOauthClient(AuthType.COMPUTE_ADC, mockConfig),
|
||||
).rejects.toThrow(
|
||||
'Could not authenticate using Cloud Shell credentials. Please select a different authentication method or ensure you are in a properly configured environment. Error: ADC Failed',
|
||||
'Could not authenticate using metadata server application default credentials. Please select a different authentication method or ensure you are in a properly configured environment. Error: ADC Failed',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user