Skip to content

Commit

Permalink
test: UserRefreshClient client for getIdTokenClient
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbankhead committed May 8, 2024
1 parent ea3dcdc commit 02f3d9c
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions test/test.googleauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1533,24 +1533,17 @@ describe('googleauth', () => {
assert(spy.calledOnce);
});

it('should fail when using UserRefreshClient', async () => {
it('should return a UserRefreshClient client for getIdTokenClient', async () => {
// Set up a mock to return path to a valid credentials file.
mockEnvVar(
'GOOGLE_APPLICATION_CREDENTIALS',
'./test/fixtures/refresh.json'
);
mockEnvVar('GOOGLE_CLOUD_PROJECT', 'some-project-id');

try {
await auth.getIdTokenClient('a-target-audience');
} catch (e) {
assert(e instanceof Error);
assert(
e.message.startsWith('Cannot fetch ID token in this environment')
);
return;
}
assert.fail('failed to throw');
const client = await auth.getIdTokenClient('a-target-audience');
assert(client instanceof IdTokenClient);
assert(client.idTokenProvider instanceof UserRefreshClient);
});

describe('getUniverseDomain', () => {
Expand Down

0 comments on commit 02f3d9c

Please sign in to comment.