@@ -36,7 +36,7 @@ import {
36
36
} from '../../../src/app/index' ;
37
37
import {
38
38
RefreshTokenCredential , ServiceAccountCredential ,
39
- ComputeEngineCredential , getApplicationDefault , isApplicationDefault , ImpersonatedServiceAccountCredential
39
+ getApplicationDefault , isApplicationDefault , ImpersonatedServiceAccountCredential , ApplicationDefaultCredential
40
40
} from '../../../src/app/credential-internal' ;
41
41
import { HttpClient } from '../../../src/utils/api-request' ;
42
42
import { Agent } from 'https' ;
@@ -332,7 +332,7 @@ describe('Credential', () => {
332
332
const response = utils . responseFrom ( expected ) ;
333
333
httpStub . resolves ( response ) ;
334
334
335
- const c = new ComputeEngineCredential ( ) ;
335
+ const c = new ApplicationDefaultCredential ( ) ;
336
336
return c . getAccessToken ( ) . then ( ( token ) => {
337
337
expect ( token . access_token ) . to . equal ( 'anAccessToken' ) ;
338
338
expect ( token . expires_in ) . to . equal ( 42 ) ;
@@ -350,7 +350,7 @@ describe('Credential', () => {
350
350
const response = utils . responseFrom ( expected ) ;
351
351
httpStub . resolves ( response ) ;
352
352
353
- const c = new ComputeEngineCredential ( ) ;
353
+ const c = new ApplicationDefaultCredential ( ) ;
354
354
return c . getIDToken ( 'my-audience.cloudfunctions.net' ) . then ( ( token ) => {
355
355
expect ( token ) . to . equal ( expected ) ;
356
356
expect ( httpStub ) . to . have . been . calledOnce . and . calledWith ( {
@@ -367,7 +367,7 @@ describe('Credential', () => {
367
367
const response = utils . responseFrom ( expectedProjectId ) ;
368
368
httpStub . resolves ( response ) ;
369
369
370
- const c = new ComputeEngineCredential ( ) ;
370
+ const c = new ApplicationDefaultCredential ( ) ;
371
371
return c . getProjectId ( ) . then ( ( projectId ) => {
372
372
expect ( projectId ) . to . equal ( expectedProjectId ) ;
373
373
expect ( httpStub ) . to . have . been . calledOnce . and . calledWith ( {
@@ -384,7 +384,7 @@ describe('Credential', () => {
384
384
const response = utils . responseFrom ( expectedProjectId ) ;
385
385
httpStub . resolves ( response ) ;
386
386
387
- const c = new ComputeEngineCredential ( ) ;
387
+ const c = new ApplicationDefaultCredential ( ) ;
388
388
return c . getProjectId ( )
389
389
. then ( ( projectId ) => {
390
390
expect ( projectId ) . to . equal ( expectedProjectId ) ;
@@ -404,7 +404,7 @@ describe('Credential', () => {
404
404
it ( 'should reject when the metadata service is not available' , ( ) => {
405
405
httpStub . rejects ( new FirebaseAppError ( 'network-error' , 'Failed to connect' ) ) ;
406
406
407
- const c = new ComputeEngineCredential ( ) ;
407
+ const c = new ApplicationDefaultCredential ( ) ;
408
408
return c . getProjectId ( ) . should . eventually
409
409
. rejectedWith ( 'Failed to determine project ID: Failed to connect' )
410
410
. and . have . property ( 'code' , 'app/invalid-credential' ) ;
@@ -414,7 +414,7 @@ describe('Credential', () => {
414
414
const response = utils . errorFrom ( 'Unexpected error' ) ;
415
415
httpStub . rejects ( response ) ;
416
416
417
- const c = new ComputeEngineCredential ( ) ;
417
+ const c = new ApplicationDefaultCredential ( ) ;
418
418
return c . getProjectId ( ) . should . eventually
419
419
. rejectedWith ( 'Failed to determine project ID: Unexpected error' )
420
420
. and . have . property ( 'code' , 'app/invalid-credential' ) ;
@@ -562,7 +562,7 @@ describe('Credential', () => {
562
562
it ( 'should return a MetadataServiceCredential as a last resort' , ( ) => {
563
563
delete process . env . GOOGLE_APPLICATION_CREDENTIALS ;
564
564
fsStub = sinon . stub ( fs , 'readFileSync' ) . throws ( new Error ( 'no gcloud credential file' ) ) ;
565
- expect ( getApplicationDefault ( ) ) . to . be . an . instanceof ( ComputeEngineCredential ) ;
565
+ expect ( getApplicationDefault ( ) ) . to . be . an . instanceof ( ApplicationDefaultCredential ) ;
566
566
} ) ;
567
567
568
568
it ( 'should create access tokens' , ( ) => {
@@ -653,7 +653,7 @@ describe('Credential', () => {
653
653
delete process . env . GOOGLE_APPLICATION_CREDENTIALS ;
654
654
fsStub = sinon . stub ( fs , 'readFileSync' ) . throws ( new Error ( 'no gcloud credential file' ) ) ;
655
655
const c = getApplicationDefault ( ) ;
656
- expect ( c ) . to . be . an . instanceof ( ComputeEngineCredential ) ;
656
+ expect ( c ) . to . be . an . instanceof ( ApplicationDefaultCredential ) ;
657
657
expect ( isApplicationDefault ( c ) ) . to . be . true ;
658
658
} ) ;
659
659
@@ -720,7 +720,7 @@ describe('Credential', () => {
720
720
721
721
it ( 'ComputeEngineCredential should use the provided HTTP Agent' , ( ) => {
722
722
const agent = new Agent ( ) ;
723
- const c = new ComputeEngineCredential ( agent ) ;
723
+ const c = new ApplicationDefaultCredential ( agent ) ;
724
724
return c . getAccessToken ( ) . then ( ( token ) => {
725
725
expect ( token . access_token ) . to . equal ( expectedToken ) ;
726
726
expect ( stub ) . to . have . been . calledOnce ;
0 commit comments