@@ -28,6 +28,7 @@ import * as utils from './utils';
28
28
import * as mocks from '../resources/mocks' ;
29
29
30
30
import * as firebaseAdmin from '../../src/index' ;
31
+ import { ApplicationDefaultCredential } from '../../src/auth/credential' ;
31
32
32
33
chai . should ( ) ;
33
34
chai . use ( chaiAsPromised ) ;
@@ -55,25 +56,19 @@ describe('Firebase', () => {
55
56
} ) ;
56
57
57
58
describe ( '#initializeApp()' , ( ) => {
58
- const invalidOptions = [ null , NaN , 0 , 1 , true , false , '' , 'a' , [ ] , { } , _ . noop ] ;
59
- invalidOptions . forEach ( ( invalidOption ) => {
59
+ const invalidOptions = [ null , NaN , 0 , 1 , true , false , '' , 'a' , [ ] , _ . noop ] ;
60
+ invalidOptions . forEach ( ( invalidOption : any ) => {
60
61
it ( 'should throw given invalid options object: ' + JSON . stringify ( invalidOption ) , ( ) => {
61
62
expect ( ( ) => {
62
63
firebaseAdmin . initializeApp ( invalidOption ) ;
63
64
} ) . to . throw ( 'Invalid Firebase app options' ) ;
64
65
} ) ;
65
66
} ) ;
66
67
67
- it ( 'should throw given an options object that does not contain any of the required keys' , ( ) => {
68
- expect ( ( ) => {
69
- firebaseAdmin . initializeApp ( { a : 1 , b : true } as any ) ;
70
- } ) . to . throw ( 'Invalid Firebase app options' ) ;
71
- } ) ;
72
-
73
- it ( 'should throw given an options object containing no "credential" key' , ( ) => {
74
- expect ( ( ) => {
75
- firebaseAdmin . initializeApp ( mocks . appOptionsNoAuth ) ;
76
- } ) . to . throw ( 'Invalid Firebase app options' ) ;
68
+ it ( 'should use application default credentials when no credentials are explicitly specified' , ( ) => {
69
+ const app = firebaseAdmin . initializeApp ( mocks . appOptionsNoAuth ) ;
70
+ expect ( app . options ) . to . have . property ( 'credential' ) ;
71
+ expect ( app . options . credential ) . to . be . instanceOf ( ApplicationDefaultCredential ) ;
77
72
} ) ;
78
73
79
74
it ( 'should not modify the provided options object' , ( ) => {
0 commit comments