diff --git a/package.json b/package.json index 2379b5066..5f96ddb7d 100644 --- a/package.json +++ b/package.json @@ -112,6 +112,7 @@ "@types/mime": "^2.0.0", "@types/mime-types": "^2.1.0", "@types/mocha": "^5.2.3", + "@types/nock": "^9.3.0", "@types/once": "^1.4.0", "@types/proxyquire": "^1.3.28", "@types/pumpify": "^1.4.1", @@ -129,6 +130,7 @@ "intelli-espower-loader": "^1.0.1", "jsdoc": "^3.5.4", "mocha": "^5.0.0", + "nock": "^10.0.1", "node-fetch": "^2.2.0", "normalize-newline": "^3.0.0", "nyc": "^13.0.0", diff --git a/system-test/storage.ts b/system-test/storage.ts index 4a456f9f7..17358602c 100644 --- a/system-test/storage.ts +++ b/system-test/storage.ts @@ -31,6 +31,13 @@ import * as uuid from 'uuid'; import {util, ApiError, InstanceResponseCallback, BodyResponseCallback} from '@google-cloud/common'; import {Storage, Bucket} from '../src'; import {DeleteBucketCallback} from '../src/bucket'; +import * as nock from 'nock'; + +// block all attempts to chat with the metadata server (kokoro runs on GCE) +nock('http://metadata.google.internal') + .get(url => true) + .replyWithError({code: 'ENOTFOUND'}) + .persist(); // tslint:disable-next-line:variable-name const PubSub = require('@google-cloud/pubsub'); @@ -113,7 +120,6 @@ describe('storage', () => { const {Storage} = require('../src'); storageWithoutAuth = new Storage(); - done(); }); });