Skip to content

Commit

Permalink
fix: Disable Universe Domain Check (#1878)
Browse files Browse the repository at this point in the history
* fix: Disable Universe Domain Check

* chore: compodoc nonsense
  • Loading branch information
d-goog authored Oct 7, 2024
1 parent 66f60bc commit 8adb44c
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 17 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"ncp": "^2.0.0",
"nock": "^13.0.0",
"null-loader": "^4.0.0",
"pdfmake": "0.2.12",
"puppeteer": "^21.0.0",
"sinon": "^18.0.0",
"ts-loader": "^8.0.0",
Expand Down
6 changes: 0 additions & 6 deletions src/auth/googleauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -457,12 +457,6 @@ export class GoogleAuth<T extends AuthClient = JSONClient> {

// Determine if we're running on GCE.
if (await this._checkIsGCE()) {
// set universe domain for Compute client
if (!originalOrCamelOptions(options).get('universe_domain')) {
options.universeDomain =
await this.getUniverseDomainFromMetadataServer();
}

(options as ComputeOptions).scopes = this.getAnyScopes();
return await this.#prepareAndCacheClient(new Compute(options));
}
Expand Down
12 changes: 1 addition & 11 deletions test/test.googleauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1149,9 +1149,8 @@ describe('googleauth', () => {

it('getCredentials should get metadata from the server when running on GCE', async () => {
const clientEmail = 'test-creds@test-creds.iam.gserviceaccount.com';
const universeDomain = 'my-amazing-universe.com';
const scopes = [
nockIsGCE({universeDomain}),
nockIsGCE(),
createGetProjectIdNock(),
nock(host).get(svcAccountPath).reply(200, clientEmail, HEADERS),
];
Expand All @@ -1160,7 +1159,6 @@ describe('googleauth', () => {
const body = await auth.getCredentials();
assert.ok(body);
assert.strictEqual(body.client_email, clientEmail);
assert.strictEqual(body.universe_domain, universeDomain);
assert.strictEqual(body.private_key, undefined);
scopes.forEach(s => s.done());
});
Expand Down Expand Up @@ -1644,14 +1642,6 @@ describe('googleauth', () => {
assert.notEqual(universe_domain, DEFAULT_UNIVERSE);
assert.equal(await auth.getUniverseDomain(), universe_domain);
});

it('should use the metadata service if on GCP', async () => {
const universeDomain = 'my.universe.com';
const scope = nockIsGCE({universeDomain});

assert.equal(await auth.getUniverseDomain(), universeDomain);
await scope.done();
});
});

function mockApplicationDefaultCredentials(path: string) {
Expand Down

0 comments on commit 8adb44c

Please sign in to comment.