Skip to content

Commit f755c9c

Browse files
committed
fix(IAM): renamed UserOptions iam_secret to iam_client_secret to be consistent with other cores
1 parent 922840b commit f755c9c

File tree

4 files changed

+24
-24
lines changed

4 files changed

+24
-24
lines changed

iam-token-manager/v1.ts

+14-14
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export type Options = {
3838
iamAccessToken?: string;
3939
iamUrl?: string;
4040
iamClientId?: string;
41-
iamSecret?: string;
41+
iamClientSecret?: string;
4242
}
4343

4444
// this interface is a representation of the response
@@ -60,7 +60,7 @@ export class IamTokenManagerV1 {
6060
private iamApikey: string;
6161
private userAccessToken: string;
6262
private iamClientId: string;
63-
private iamSecret: string;
63+
private iamClientSecret: string;
6464

6565
/**
6666
* IAM Token Manager Service
@@ -85,10 +85,10 @@ export class IamTokenManagerV1 {
8585
if (options.iamClientId) {
8686
this.iamClientId = options.iamClientId;
8787
}
88-
if (options.iamSecret) {
89-
this.iamSecret = options.iamSecret;
88+
if (options.iamClientSecret) {
89+
this.iamClientSecret = options.iamClientSecret;
9090
}
91-
if (onlyOne(options.iamClientId, options.iamSecret)) {
91+
if (onlyOne(options.iamClientId, options.iamClientSecret)) {
9292
// tslint:disable-next-line
9393
console.log(CLIENT_ID_SECRET_WARNING);
9494
}
@@ -127,20 +127,20 @@ export class IamTokenManagerV1 {
127127
}
128128

129129
/**
130-
* Set the IAM 'client_id' and 'secret' values.
130+
* Set the IAM 'client_id' and 'client_secret' values.
131131
* These values are used to compute the Authorization header used
132132
* when retrieving or refreshing the IAM access token.
133133
* If these values are not set, then a default Authorization header
134134
* will be used when interacting with the IAM token server.
135135
*
136136
* @param {string} iamClientId - The client id
137-
* @param {string} iamSecret - The secret
137+
* @param {string} iamClientSecret - The client secret
138138
* @returns {void}
139139
*/
140-
public setIamAuthorizationInfo(iamClientId: string, iamSecret: string): void {
140+
public setIamAuthorizationInfo(iamClientId: string, iamClientSecret: string): void {
141141
this.iamClientId = iamClientId;
142-
this.iamSecret = iamSecret;
143-
if (onlyOne(iamClientId, iamSecret)) {
142+
this.iamClientSecret = iamClientSecret;
143+
if (onlyOne(iamClientId, iamClientSecret)) {
144144
// tslint:disable-next-line
145145
console.log(CLIENT_ID_SECRET_WARNING);
146146
}
@@ -271,14 +271,14 @@ export class IamTokenManagerV1 {
271271
private computeIamAuthHeader(): string {
272272
// Use bx:bx as default auth header creds.
273273
let clientId = 'bx';
274-
let secret = 'bx';
274+
let clientSecret = 'bx';
275275

276276
// If both the clientId and secret were specified by the user, then use them.
277-
if (this.iamClientId && this.iamSecret) {
277+
if (this.iamClientId && this.iamClientSecret) {
278278
clientId = this.iamClientId;
279-
secret = this.iamSecret;
279+
clientSecret = this.iamClientSecret;
280280
}
281-
const encodedCreds = Buffer.from(`${clientId}:${secret}`).toString('base64');
281+
const encodedCreds = Buffer.from(`${clientId}:${clientSecret}`).toString('base64');
282282
return `Basic ${encodedCreds}`;
283283
}
284284
}

lib/base_service.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export interface UserOptions {
4040
iam_apikey?: string;
4141
iam_url?: string;
4242
iam_client_id?: string;
43-
iam_secret?: string;
43+
iam_client_secret?: string;
4444
disable_ssl_verification?: boolean;
4545
}
4646

@@ -126,7 +126,7 @@ export class BaseService {
126126
* @param {string} [options.iam_access_token] - iam access token provided and managed by user
127127
* @param {string} [options.iam_url] - url for iam service api, needed for services in staging
128128
* @param {string} [options.iam_client_id] - client id (username) for request to iam service
129-
* @param {string} [options.iam_secret] - secret (password) for request to iam service
129+
* @param {string} [options.iam_client_secret] - secret (password) for request to iam service
130130
* @param {string} [options.username] - required unless use_unauthenticated is set
131131
* @param {string} [options.password] - required unless use_unauthenticated is set
132132
* @param {boolean} [options.use_unauthenticated] - skip credential requirement
@@ -166,14 +166,14 @@ export class BaseService {
166166
iamAccessToken: _options.iam_access_token,
167167
iamUrl: _options.iam_url,
168168
iamClientId: _options.iam_client_id,
169-
iamSecret: _options.iam_secret
169+
iamClientSecret: _options.iam_client_secret
170170
});
171171
} else if (usesBasicForIam(_options)) {
172172
this.tokenManager = new IamTokenManagerV1({
173173
iamApikey: _options.password,
174174
iamUrl: _options.iam_url,
175175
iamClientId: _options.iam_client_id,
176-
iamSecret: _options.iam_secret
176+
iamClientSecret: _options.iam_client_secret
177177
});
178178
} else {
179179
this.tokenManager = null;

test/unit/baseService.test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ describe('BaseService', function() {
291291
iam_access_token: 'real-token-84',
292292
iam_url: 'iam.com/api',
293293
iam_client_id: 'abc',
294-
iam_secret: 'abc',
294+
iam_client_secret: 'abc',
295295
});
296296

297297
expect(instance.tokenManager).toBeDefined();
@@ -300,7 +300,7 @@ describe('BaseService', function() {
300300
expect(instance.tokenManager.userAccessToken).toBeDefined();
301301
expect(instance.tokenManager.iamUrl).toBeDefined();
302302
expect(instance.tokenManager.iamClientId).toBeDefined();
303-
expect(instance.tokenManager.iamSecret).toBeDefined();
303+
expect(instance.tokenManager.iamClientSecret).toBeDefined();
304304
});
305305

306306
it('should pass all credentials to token manager when given iam with basic', function() {
@@ -309,15 +309,15 @@ describe('BaseService', function() {
309309
password: 'key1234',
310310
iam_url: 'iam.com/api',
311311
iam_client_id: 'abc',
312-
iam_secret: 'abc',
312+
iam_client_secret: 'abc',
313313
});
314314

315315
expect(instance.tokenManager).toBeDefined();
316316
expect(instance.tokenManager).not.toBeNull();
317317
expect(instance.tokenManager.iamApikey).toBeDefined();
318318
expect(instance.tokenManager.iamUrl).toBeDefined();
319319
expect(instance.tokenManager.iamClientId).toBeDefined();
320-
expect(instance.tokenManager.iamSecret).toBeDefined();
320+
expect(instance.tokenManager.iamClientSecret).toBeDefined();
321321
});
322322

323323
it('should not fail if setAccessToken is called and token manager is null', function() {

test/unit/iamTokenManager.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ describe('iam_token_manager_v1', function() {
223223
const instance = new IamTokenManagerV1({
224224
iamApikey: 'abcd-1234',
225225
iamClientId: 'foo',
226-
iamSecret: 'bar',
226+
iamClientSecret: 'bar',
227227
});
228228

229229
requestWrapper.sendRequest.mockImplementation((parameters, _callback) => {
@@ -267,7 +267,7 @@ describe('iam_token_manager_v1', function() {
267267
jest.spyOn(console, 'log').mockImplementation(() => {});
268268
const instance = new IamTokenManagerV1({
269269
iamApikey: 'abcd-1234',
270-
iamSecret: 'bar',
270+
iamClientSecret: 'bar',
271271
});
272272

273273
// verify warning was triggered

0 commit comments

Comments
 (0)