@@ -25,6 +25,8 @@ const HEADERS = {
2525 [ 'metadata-flavor' ] : 'Google'
2626} ;
2727
28+ const HOST_ADDRESS = 'http://metadata.google.internal.' ;
29+
2830export function oauth2 < T extends { } = { } > ( validator ?: ( body : T ) => boolean ) :
2931 nock . Scope {
3032 validator = validator || accept ;
@@ -43,15 +45,15 @@ export function projectId(status: number|(() => string), reply?: () => string) {
4345 reply = status ;
4446 status = 200 ;
4547 }
46- return nock ( 'http://metadata.google.internal' )
48+ return nock ( HOST_ADDRESS )
4749 . get ( '/computeMetadata/v1/project/project-id' )
4850 . once ( )
4951 . reply ( status , reply , { 'Metadata-Flavor' : 'Google' } ) ;
5052}
5153
5254export function noDetectResource ( ) {
5355 const scopes = [
54- nock ( 'http://metadata.google.internal' )
56+ nock ( HOST_ADDRESS )
5557 . get ( '/computeMetadata/v1/instance' )
5658 . once ( )
5759 . replyWithError ( { code : 'ENOTFOUND' } ) ,
@@ -63,7 +65,7 @@ export function noDetectResource() {
6365}
6466
6567export function detectGceResource ( ) {
66- return nock ( 'http://metadata.google.internal' )
68+ return nock ( HOST_ADDRESS )
6769 . get ( '/computeMetadata/v1/instance' )
6870 . reply ( 200 , { } , HEADERS )
6971 . get ( '/computeMetadata/v1/project/project-id' )
@@ -80,7 +82,7 @@ export function instanceId(
8082 reply = status ;
8183 status = 200 ;
8284 }
83- return nock ( 'http://metadata.google.internal' )
85+ return nock ( HOST_ADDRESS )
8486 . get ( '/computeMetadata/v1/instance/id' )
8587 . once ( )
8688 . reply ( status , reply , { 'Metadata-Flavor' : 'Google' } ) ;
@@ -91,7 +93,7 @@ export function hostname(status: number|(() => string), reply?: () => string) {
9193 reply = status ;
9294 status = 200 ;
9395 }
94- return nock ( 'http://metadata.google.internal' )
96+ return nock ( HOST_ADDRESS )
9597 . get ( '/computeMetadata/v1/instance/hostname' )
9698 . once ( )
9799 . reply ( status , reply , { 'Metadata-Flavor' : 'Google' } ) ;
0 commit comments