Skip to content

Commit 3d44561

Browse files
committed
RAB endpoints changed from staging to prod; Removed RAB env variable gate; updated tests.
1 parent 42631e3 commit 3d44561

10 files changed

Lines changed: 48 additions & 51 deletions

File tree

core/packages/google-auth-library-nodejs/src/auth/authclient.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import {log as makeLog} from 'google-logging-utils';
2121

2222
import {PRODUCT_NAME, USER_AGENT} from '../shared.cjs';
2323
import {
24-
isRegionalAccessBoundaryEnabled,
2524
RegionalAccessBoundaryData,
2625
RegionalAccessBoundaryManager,
2726
} from './regionalaccessboundary';
@@ -237,7 +236,6 @@ export abstract class AuthClient
237236
eagerRefreshThresholdMillis = DEFAULT_EAGER_REFRESH_THRESHOLD_MILLIS;
238237
forceRefreshOnFailure = false;
239238
universeDomain = DEFAULT_UNIVERSE;
240-
regionalAccessBoundaryEnabled: boolean;
241239
protected regionalAccessBoundaryManager: RegionalAccessBoundaryManager;
242240

243241
/**
@@ -261,7 +259,6 @@ export abstract class AuthClient
261259
this.quotaProjectId = options.get('quota_project_id');
262260
this.credentials = options.get('credentials') ?? {};
263261
this.universeDomain = options.get('universe_domain') ?? DEFAULT_UNIVERSE;
264-
this.regionalAccessBoundaryEnabled = isRegionalAccessBoundaryEnabled();
265262

266263
// Shared client options
267264
this.transporter = opts.transporter ?? new Gaxios(opts.transporterOptions);

core/packages/google-auth-library-nodejs/src/auth/idtokenclient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,4 @@ export class IdTokenClient extends OAuth2Client {
8585
return payload.exp * 1000;
8686
}
8787
}
88-
}
88+
}

core/packages/google-auth-library-nodejs/src/auth/regionalaccessboundary.ts

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ import {log as makeLog} from 'google-logging-utils';
1818
const log = makeLog('auth');
1919

2020
export const SERVICE_ACCOUNT_LOOKUP_ENDPOINT =
21-
'https://staging-iamcredentials.sandbox.googleapis.com/v1/projects/-/serviceAccounts/{service_account_email}/allowedLocations';
21+
'https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/{service_account_email}/allowedLocations';
2222

2323
export const WORKLOAD_LOOKUP_ENDPOINT =
24-
'https://staging-iamcredentials.sandbox.googleapis.com/v1/projects/{project_id}/locations/global/workloadIdentityPools/{pool_id}/allowedLocations';
24+
'https://iamcredentials.googleapis.com/v1/projects/{project_id}/locations/global/workloadIdentityPools/{pool_id}/allowedLocations';
2525

2626
export const WORKFORCE_LOOKUP_ENDPOINT =
27-
'https://staging-iamcredentials.sandbox.googleapis.com/v1/locations/global/workforcePools/{pool_id}/allowedLocations';
27+
'https://iamcredentials.googleapis.com/v1/locations/global/workforcePools/{pool_id}/allowedLocations';
2828

2929
/**
3030
* RAB is considered valid for 6 hours.
@@ -63,18 +63,6 @@ export interface RegionalAccessBoundaryData {
6363
encodedLocations: string;
6464
}
6565

66-
export function isRegionalAccessBoundaryEnabled() {
67-
const rabEnabled =
68-
process.env['GOOGLE_AUTH_TRUST_BOUNDARY_ENABLE_EXPERIMENT'];
69-
if (rabEnabled === undefined || rabEnabled === null) {
70-
return false;
71-
}
72-
const lowercasedRabEnabled = rabEnabled.toLowerCase();
73-
if (lowercasedRabEnabled === 'true' || rabEnabled === '1') {
74-
return true;
75-
}
76-
return false;
77-
}
7866

7967
export interface RegionalAccessBoundaryManagerOptions {
8068
transporter: Gaxios;
@@ -94,9 +82,6 @@ export class RegionalAccessBoundaryManager {
9482
this.options = options;
9583
}
9684

97-
get enabled(): boolean {
98-
return isRegionalAccessBoundaryEnabled();
99-
}
10085

10186
/**
10287
* @internal
@@ -122,7 +107,7 @@ export class RegionalAccessBoundaryManager {
122107
url: string | URL | undefined,
123108
headers: Headers,
124109
): string | null {
125-
if (!this.enabled || !this.options.isUniverseDomainDefault()) {
110+
if (!this.options.isUniverseDomainDefault()) {
126111
return null;
127112
}
128113

@@ -275,4 +260,4 @@ export class RegionalAccessBoundaryManager {
275260

276261
return regionalAccessBoundaryData;
277262
}
278-
}
263+
}

core/packages/google-auth-library-nodejs/src/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,4 +336,4 @@ export function getWorkloadPoolIdFromAudience(audience: string): string | null {
336336
/\/workloadIdentityPools\/(?<workloadPool>[^/]+)\/providers\//,
337337
)?.groups?.workloadPool ?? null
338338
);
339-
}
339+
}

core/packages/google-auth-library-nodejs/test/test.authclient.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -417,14 +417,6 @@ describe('AuthClient', () => {
417417
);
418418
}
419419

420-
beforeEach(() => {
421-
process.env['GOOGLE_AUTH_TRUST_BOUNDARY_ENABLE_EXPERIMENT'] = 'true';
422-
});
423-
424-
afterEach(() => {
425-
delete process.env['GOOGLE_AUTH_TRUST_BOUNDARY_ENABLE_EXPERIMENT'];
426-
});
427-
428420
it('should trigger asynchronous background refresh and not block', async () => {
429421
const compute = new Compute({
430422
serviceAccountEmail: SERVICE_ACCOUNT_EMAIL,
@@ -613,4 +605,4 @@ describe('AuthClient', () => {
613605
});
614606
});
615607
});
616-
});
608+
});

core/packages/google-auth-library-nodejs/test/test.baseexternalclient.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,20 @@ describe('BaseExternalAccountClient', () => {
162162
'//iam.googleapis.com/projects_suffix/123456',
163163
];
164164

165+
let sandbox: sinon.SinonSandbox;
166+
beforeEach(() => {
167+
sandbox = sinon.createSandbox();
168+
sandbox
169+
.stub(BaseExternalAccountClient.prototype, 'getRegionalAccessBoundaryUrl')
170+
.resolves(undefined);
171+
});
172+
165173
afterEach(() => {
166174
nock.cleanAll();
167175
if (clock) {
168176
clock.restore();
169177
}
178+
sandbox.restore();
170179
});
171180

172181
describe('Constructor', () => {
@@ -2723,11 +2732,13 @@ describe('BaseExternalAccountClient', () => {
27232732
};
27242733

27252734
beforeEach(() => {
2726-
process.env['GOOGLE_AUTH_TRUST_BOUNDARY_ENABLE_EXPERIMENT'] = 'true';
2735+
(
2736+
BaseExternalAccountClient.prototype
2737+
.getRegionalAccessBoundaryUrl as sinon.SinonStub
2738+
).restore();
27272739
});
27282740

27292741
afterEach(() => {
2730-
delete process.env['GOOGLE_AUTH_TRUST_BOUNDARY_ENABLE_EXPERIMENT'];
27312742
nock.cleanAll();
27322743
});
27332744

core/packages/google-auth-library-nodejs/test/test.compute.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {describe, it, beforeEach, afterEach} from 'mocha';
1717
import {BASE_PATH, HEADERS, HOST_ADDRESS} from 'gcp-metadata';
1818
import * as nock from 'nock';
1919
import * as sinon from 'sinon';
20-
import { Compute, gcpMetadata } from '../src';
20+
import {Compute, gcpMetadata} from '../src';
2121
import {
2222
SERVICE_ACCOUNT_LOOKUP_ENDPOINT,
2323
RegionalAccessBoundaryData,
@@ -48,6 +48,9 @@ describe('compute', () => {
4848
let compute: Compute;
4949
beforeEach(() => {
5050
compute = new Compute();
51+
sandbox
52+
.stub(Compute.prototype, 'getRegionalAccessBoundaryUrl')
53+
.resolves(undefined);
5154
});
5255

5356
afterEach(() => {
@@ -284,7 +287,7 @@ describe('compute', () => {
284287
.get(tokenPath)
285288
.reply(
286289
200,
287-
{ access_token: MOCK_ACCESS_TOKEN, expires_in: 10000 },
290+
{access_token: MOCK_ACCESS_TOKEN, expires_in: 10000},
288291
HEADERS,
289292
);
290293
}
@@ -305,11 +308,12 @@ describe('compute', () => {
305308

306309
beforeEach(() => {
307310
sandbox = sinon.createSandbox();
308-
process.env['GOOGLE_AUTH_TRUST_BOUNDARY_ENABLE_EXPERIMENT'] = 'true';
311+
(
312+
Compute.prototype.getRegionalAccessBoundaryUrl as sinon.SinonStub
313+
).restore();
309314
});
310315

311316
afterEach(() => {
312-
delete process.env['GOOGLE_AUTH_TRUST_BOUNDARY_ENABLE_EXPERIMENT'];
313317
sandbox.restore();
314318
nock.cleanAll();
315319
});

core/packages/google-auth-library-nodejs/test/test.externalaccountauthorizeduserclient.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -909,11 +909,9 @@ describe('ExternalAccountAuthorizedUserClient', () => {
909909

910910
beforeEach(() => {
911911
clock.restore();
912-
process.env['GOOGLE_AUTH_TRUST_BOUNDARY_ENABLE_EXPERIMENT'] = 'true';
913912
});
914913

915914
afterEach(() => {
916-
delete process.env['GOOGLE_AUTH_TRUST_BOUNDARY_ENABLE_EXPERIMENT'];
917915
nock.cleanAll();
918916
});
919917

core/packages/google-auth-library-nodejs/test/test.impersonated.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,15 @@ interface ImpersonatedCredentialRequest {
7474
}
7575

7676
describe('impersonated', () => {
77+
beforeEach(() => {
78+
sinon
79+
.stub(Impersonated.prototype, 'getRegionalAccessBoundaryUrl')
80+
.resolves(undefined);
81+
});
82+
7783
afterEach(() => {
7884
nock.cleanAll();
85+
sinon.restore();
7986
});
8087

8188
it('should request impersonated credentials on first request', async () => {
@@ -622,11 +629,12 @@ describe('impersonated', () => {
622629

623630
beforeEach(() => {
624631
sandbox = sinon.createSandbox();
625-
process.env['GOOGLE_AUTH_TRUST_BOUNDARY_ENABLE_EXPERIMENT'] = 'true';
632+
(
633+
Impersonated.prototype.getRegionalAccessBoundaryUrl as sinon.SinonStub
634+
).restore();
626635
});
627636

628637
afterEach(() => {
629-
delete process.env['GOOGLE_AUTH_TRUST_BOUNDARY_ENABLE_EXPERIMENT'];
630638
sandbox.restore();
631639
nock.cleanAll();
632640
});

core/packages/google-auth-library-nodejs/test/test.jwt.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ describe('jwt', () => {
7272
json = createJSON();
7373
jwt = new JWT();
7474
sandbox = sinon.createSandbox();
75+
sandbox
76+
.stub(JWT.prototype, 'getRegionalAccessBoundaryUrl')
77+
.resolves(undefined);
7578
});
7679

7780
afterEach(() => {
@@ -1277,11 +1280,10 @@ describe('jwt', () => {
12771280

12781281
beforeEach(() => {
12791282
sandbox = sinon.createSandbox();
1280-
process.env['GOOGLE_AUTH_TRUST_BOUNDARY_ENABLE_EXPERIMENT'] = 'true';
1283+
(JWT.prototype.getRegionalAccessBoundaryUrl as sinon.SinonStub).restore();
12811284
});
12821285

12831286
afterEach(() => {
1284-
delete process.env['GOOGLE_AUTH_TRUST_BOUNDARY_ENABLE_EXPERIMENT'];
12851287
sandbox.restore();
12861288
nock.cleanAll();
12871289
});
@@ -1293,9 +1295,9 @@ describe('jwt', () => {
12931295
scopes: ['http://bar', 'http://foo'],
12941296
subject: 'bar@subjectaccount.com',
12951297
});
1296-
jwt.credentials = { refresh_token: 'jwt-placeholder' };
1298+
jwt.credentials = {refresh_token: 'jwt-placeholder'};
12971299

1298-
const tokenScope = createGTokenMock({ access_token: MOCK_ACCESS_TOKEN });
1300+
const tokenScope = createGTokenMock({access_token: MOCK_ACCESS_TOKEN});
12991301

13001302
let rabLookupCalled = false;
13011303
const rabScope = setupRegionalAccessBoundaryNock(SERVICE_ACCOUNT_EMAIL);
@@ -1335,7 +1337,7 @@ describe('jwt', () => {
13351337
email: SERVICE_ACCOUNT_EMAIL,
13361338
key: keys.private,
13371339
});
1338-
jwt.credentials = { refresh_token: 'jwt-placeholder' };
1340+
jwt.credentials = {refresh_token: 'jwt-placeholder'};
13391341

13401342
const lookupUrl = SERVICE_ACCOUNT_LOOKUP_ENDPOINT.replace(
13411343
'{service_account_email}',
@@ -1379,13 +1381,13 @@ describe('jwt', () => {
13791381
const jwt = new JWT({
13801382
email: SERVICE_ACCOUNT_EMAIL,
13811383
key: PEM_CONTENTS,
1382-
additionalClaims: { target_audience: 'some-audience' },
1384+
additionalClaims: {target_audience: 'some-audience'},
13831385
});
13841386

13851387
// Setup a RAB lookup mock that should NOT be hit
13861388
const rabScope = setupRegionalAccessBoundaryNock(SERVICE_ACCOUNT_EMAIL);
13871389

1388-
const scope = createGTokenMock({ id_token: 'id-token-abc' });
1390+
const scope = createGTokenMock({id_token: 'id-token-abc'});
13891391
const headers = await jwt.getRequestHeaders(
13901392
'https://pubsub.googleapis.com',
13911393
);

0 commit comments

Comments
 (0)