Skip to content

Commit

Permalink
do not modify the headers in jwsSigner (#220)
Browse files Browse the repository at this point in the history
Co-authored-by: Shashi <shashikant.hirugade@modusbox.com>
  • Loading branch information
shashi165 and Shashi authored May 13, 2020
1 parent f585d81 commit 463b819
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 112 deletions.
152 changes: 47 additions & 105 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mojaloop/central-services-shared",
"version": "10.1.1",
"version": "10.1.2",
"description": "Shared code for central services",
"main": "src/index.js",
"scripts": {
Expand Down Expand Up @@ -43,7 +43,7 @@
"dependencies": {
"@hapi/catbox": "11.1.0",
"@hapi/catbox-memory": "5.0.0",
"@mojaloop/central-services-error-handling": "10.1.0",
"@mojaloop/central-services-error-handling": "10.2.0",
"@mojaloop/central-services-logger": "9.5.1",
"@mojaloop/central-services-metrics": "9.5.0",
"@mojaloop/event-sdk": "9.5.2",
Expand All @@ -60,7 +60,7 @@
"@hapi/hapi": "19.1.1",
"@hapi/joi": "17.1.1",
"@mojaloop/sdk-standard-components": "10.1.0",
"chance": "1.1.4",
"chance": "1.1.5",
"faucet": "0.0.1",
"npm-audit-resolver": "2.2.0",
"npm-check-updates": "5.0.0",
Expand All @@ -70,7 +70,7 @@
"rc": "1.2.8",
"rewire": "5.0.0",
"sinon": "9.0.2",
"standard": "14.3.3",
"standard": "14.3.4",
"tap-xunit": "2.4.1",
"tape": "5.0.0",
"tapes": "4.1.0",
Expand Down
2 changes: 1 addition & 1 deletion src/util/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const sendRequest = async (url, headers, source, destination, method = enums.Htt
}
// if jwsSigner is passed then sign the request
if (jwsSigner != null && typeof (jwsSigner) === 'object') {
jwsSigner.sign(requestOptions)
requestOptions.headers['fspiop-signature'] = jwsSigner.getSignature(requestOptions)
}

if (span) {
Expand Down
4 changes: 2 additions & 2 deletions test/unit/util/request.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ Test('ParticipantEndpoint Model Test', modelTest => {
})
request = sandbox.stub().returns({ status: 200 })
Model = proxyquire('../../../src/util/request', { axios: request })
const signSpy = Sinon.spy(jwsSigner, 'sign')
const signSpy = Sinon.spy(jwsSigner, 'getSignature')
await Model.sendRequest(requestOptions.url, requestOptions.headers, Enum.Http.HeaderResources.SWITCH, fsp, requestOptions.method, payload, Enum.Http.ResponseTypes.JSON, undefined, jwsSigner)
test.ok(signSpy.calledOnce, 'JwsSigner.sign is called once')
test.ok('fspiop-signature' in signSpy.getCall(0).firstArg.headers, 'The header has fspiop-signature')
Expand All @@ -221,7 +221,7 @@ Test('ParticipantEndpoint Model Test', modelTest => {
})
request = sandbox.stub().returns({ status: 200 })
Model = proxyquire('../../../src/util/request', { axios: request })
const signSpy = Sinon.spy(jwsSigner, 'sign')
const signSpy = Sinon.spy(jwsSigner, 'getSignature')
await Model.sendRequest(requestOptions.url, requestOptions.headers, Enum.Http.HeaderResources.SWITCH, fsp, requestOptions.method, payload, Enum.Http.ResponseTypes.JSON, undefined, undefined)
test.equal(signSpy.callCount, 0, 'JwsSigner.sign is NOT called')
test.end()
Expand Down

0 comments on commit 463b819

Please sign in to comment.