Skip to content

Commit

Permalink
update setter name
Browse files Browse the repository at this point in the history
  • Loading branch information
Alejandro-Gonzalez committed Dec 18, 2023
1 parent d2d71ce commit 4b940e3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ _Since 4.0.0_
_Since 5.1.0_

* `set apiKeyUserId()`
* `set apiKeyUser()`
Setter for add user id in api-key header

## Parameters
Expand Down
8 changes: 4 additions & 4 deletions lib/microservice-call.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ module.exports = class MicroServiceCall {

const servicePart = `service-${process.env.JANIS_SERVICE_NAME}`;

const userIdPart = this._apiKeyUserId ? `_user-${this._apiKeyUserId}` : '';
const userPart = this._apiKeyUser ? `_user-${this._apiKeyUser}` : '';

return {
'janis-api-key': `${servicePart}${userIdPart}`,
'janis-api-key': `${servicePart}${userPart}`,
'janis-api-secret': SecretFetcher.secretValue
};
}
Expand Down Expand Up @@ -101,8 +101,8 @@ module.exports = class MicroServiceCall {
* Set userId for make api-key header
* @param {string} userId User identifier
*/
set apiKeyUserId(userId) {
this._apiKeyUserId = userId;
set apiKeyUser(userId) {
this._apiKeyUser = userId;
}

/**
Expand Down
10 changes: 5 additions & 5 deletions tests/microservice-call.js
Original file line number Diff line number Diff line change
Expand Up @@ -1346,7 +1346,7 @@ describe('MicroService call', () => {
});
});

describe('Using apiKeyUserId setter', () => {
describe('Using apiKeyUser setter', () => {

beforeEach(() => {
process.env.JANIS_SERVICE_SECRET = 'insecure-secret';
Expand Down Expand Up @@ -1381,7 +1381,7 @@ describe('MicroService call', () => {
'janis-api-key': 'service-dummy-service_user-5f4adc8f9c4ae13ea8000000'
};

ms.apiKeyUserId = '5f4adc8f9c4ae13ea8000000';
ms.apiKeyUser = '5f4adc8f9c4ae13ea8000000';

mockRequest(reqheaders);

Expand All @@ -1397,7 +1397,7 @@ describe('MicroService call', () => {
'janis-api-key': 'service-dummy-service'
};

ms.apiKeyUserId = null;
ms.apiKeyUser = null;

mockRequest(reqheaders);

Expand All @@ -1413,13 +1413,13 @@ describe('MicroService call', () => {
'janis-api-key': 'service-dummy-service_user-5f4adc8f9c4ae13ea8000000'
};

ms.apiKeyUserId = '5f4adc8f9c4ae13ea8000000';
ms.apiKeyUser = '5f4adc8f9c4ae13ea8000000';

mockRequest(reqheaders);

await ms.call(...requestArgs);

ms.apiKeyUserId = null;
ms.apiKeyUser = null;

mockRequest({ ...reqheaders, 'janis-api-key': 'service-dummy-service' });

Expand Down

0 comments on commit 4b940e3

Please sign in to comment.