@@ -1106,6 +1106,41 @@ describe('GoogleAuth', function() {
11061106 done ( ) ; 
11071107 } ) ; 
11081108 } ) ; 
1109+ 
1110+  it ( 'should also get project ID' ,  function  ( done )  { 
1111+  // We expect private.json to be the file that is used. 
1112+  var  fileContents  =  fs . readFileSync ( './test/fixtures/private.json' ,  'utf-8' ) ; 
1113+  var  json  =  JSON . parse ( fileContents ) ; 
1114+  var  testProjectId  =  'my-awesome-project' ; 
1115+ 
1116+  // Set up the creds. 
1117+  // * Environment variable is set up to point to private.json 
1118+  // * Well-known file is set up to point to private2.json 
1119+  // * Running on GCE is set to true. 
1120+  var  auth  =  new  GoogleAuth ( ) ; 
1121+  insertEnvironmentVariableIntoAuth ( auth ,  'GOOGLE_APPLICATION_CREDENTIALS' , 
1122+  './test/fixtures/private.json' ) ; 
1123+  insertEnvironmentVariableIntoAuth ( auth ,  'GCLOUD_PROJECT' ,  testProjectId ) ; 
1124+  insertEnvironmentVariableIntoAuth ( auth ,  'APPDATA' ,  'foo' ) ; 
1125+  auth . _pathJoin  =  pathJoin ; 
1126+  auth . _osPlatform  =  returns ( 'win32' ) ; 
1127+  auth . _fileExists  =  returns ( true ) ; 
1128+  auth . _checkIsGCE  =  callsBack ( true ) ; 
1129+  insertWellKnownFilePathIntoAuth ( auth ,  'foo:gcloud:application_default_credentials.json' , 
1130+  './test/fixtures/private2.json' ) ; 
1131+ 
1132+  // Execute. 
1133+  auth . getApplicationDefault ( function  ( err ,  result ,  projectId )  { 
1134+  assert . equal ( null ,  err ) ; 
1135+  assert . equal ( json . private_key ,  result . key ) ; 
1136+  assert . equal ( json . client_email ,  result . email ) ; 
1137+  assert . equal ( projectId ,  testProjectId ) ; 
1138+  assert . equal ( null ,  result . keyFile ) ; 
1139+  assert . equal ( null ,  result . subject ) ; 
1140+  assert . equal ( null ,  result . scope ) ; 
1141+  done ( ) ; 
1142+  } ) ; 
1143+  } ) ; 
11091144 } ) ; 
11101145
11111146 describe ( '._checkIsGCE' ,  function  ( )  { 
0 commit comments