@@ -45,6 +45,7 @@ describe('test-config-credentials', function() {
4545 var config = extend ( { } , defaultConfig , {
4646 keyFilename : path . join ( 'test' , 'fixtures' , 'gcloud-credentials.json' )
4747 } ) ;
48+ var debug = require ( '../..' ) ( config ) ;
4849 var scope = nock ( 'https://accounts.google.com' )
4950 . post ( '/o/oauth2/token' , function ( body ) {
5051 assert . equal ( body . client_id , credentials . client_id ) ;
@@ -63,14 +64,15 @@ describe('test-config-credentials', function() {
6364 setImmediate ( done ) ;
6465 return true ;
6566 } ) . reply ( 200 ) ;
66- debuglet = new Debuglet ( config , logger . create ( logger . WARN , 'testing' ) ) ;
67+ debuglet = new Debuglet ( debug , config , logger . create ( logger . WARN , 'testing' ) ) ;
6768 debuglet . start ( ) ;
6869 } ) ;
6970
7071 it ( 'should use the credentials field of the config object' , function ( done ) {
7172 var config = extend ( { } , defaultConfig , {
7273 credentials : require ( '../fixtures/gcloud-credentials.json' )
7374 } ) ;
75+ var debug = require ( '../..' ) ( config ) ;
7476 var scope = nock ( 'https://accounts.google.com' )
7577 . post ( '/o/oauth2/token' , function ( body ) {
7678 assert . equal ( body . client_id , config . credentials . client_id ) ;
@@ -89,32 +91,34 @@ describe('test-config-credentials', function() {
8991 setImmediate ( done ) ;
9092 return true ;
9193 } ) . reply ( 200 ) ;
92- debuglet = new Debuglet ( config , logger . create ( undefined , 'testing' ) ) ;
94+ debuglet = new Debuglet ( debug , config , logger . create ( undefined , 'testing' ) ) ;
9395 debuglet . start ( ) ;
9496 } ) ;
9597
96- it ( 'should ignore credentials if keyFilename is provided' , function ( done ) {
97- var correctCredentials = require ( '../fixtures/gcloud-credentials.json' ) ;
98- var config = extend ( { } , defaultConfig , {
99- keyFilename : path . join ( 'test' , 'fixtures' , 'gcloud-credentials.json' ) ,
100- credentials : {
98+ it ( 'should ignore keyFilename if credentials is provided' , function ( done ) {
99+ var fileCredentials = require ( '../fixtures/gcloud-credentials.json' ) ;
100+ var credentials = {
101101 client_id : 'a' ,
102102 client_secret : 'b' ,
103103 refresh_token : 'c' ,
104104 type : 'authorized_user'
105- }
105+ } ;
106+ var config = extend ( { } , defaultConfig , {
107+ keyFilename : path . join ( 'test' , 'fixtures' , 'gcloud-credentials.json' ) ,
108+ credentials : credentials
106109 } ) ;
110+ var debug = require ( '../..' ) ( config ) ;
107111 [ 'client_id' , 'client_secret' , 'refresh_token' ] . forEach ( function ( field ) {
108- assert ( correctCredentials . hasOwnProperty ( field ) ) ;
112+ assert ( fileCredentials . hasOwnProperty ( field ) ) ;
109113 assert ( config . credentials . hasOwnProperty ( field ) ) ;
110114 assert . notEqual ( config . credentials [ field ] ,
111- correctCredentials [ field ] ) ;
115+ fileCredentials [ field ] ) ;
112116 } ) ;
113117 var scope = nock ( 'https://accounts.google.com' )
114118 . post ( '/o/oauth2/token' , function ( body ) {
115- assert . equal ( body . client_id , correctCredentials . client_id ) ;
116- assert . equal ( body . client_secret , correctCredentials . client_secret ) ;
117- assert . equal ( body . refresh_token , correctCredentials . refresh_token ) ;
119+ assert . equal ( body . client_id , credentials . client_id ) ;
120+ assert . equal ( body . client_secret , credentials . client_secret ) ;
121+ assert . equal ( body . refresh_token , credentials . refresh_token ) ;
118122 return true ;
119123 } ) . reply ( 200 , {
120124 refresh_token : 'hello' ,
@@ -128,7 +132,7 @@ describe('test-config-credentials', function() {
128132 setImmediate ( done ) ;
129133 return true ;
130134 } ) . reply ( 200 ) ;
131- debuglet = new Debuglet ( config , logger . create ( undefined , 'testing' ) ) ;
135+ debuglet = new Debuglet ( debug , config , logger . create ( undefined , 'testing' ) ) ;
132136 debuglet . start ( ) ;
133137 } ) ;
134138} ) ;
0 commit comments