Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix for #29 ml-api-adapter does not support calling call-back end-points that are provided with untrusted certificates #30

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mojaloop/ml-api-adapter",
"version": "3.3.0-snapshot",
"version": "3.3.1-snapshot",
"description": "Convert from ML API to/from internal Central Services messaging format.",
"license": "Apache-2.0",
"private": true,
Expand Down Expand Up @@ -108,7 +108,7 @@
"proxyquire": "1.7.10",
"request": "^2.85.0",
"rewire": "^4.0.1",
"sinon": "^5.0.10",
"sinon": "^6.1.5",
"standard": "8.5.0",
"supertest": "2.0.1",
"tap-xunit": "1.4.0",
Expand Down
5 changes: 4 additions & 1 deletion src/handlers/notification/callbacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ const sendCallback = async (url, method, headers, message) => {
url,
method,
// headers,
body: JSON.stringify(message)
body: JSON.stringify(message),
agentOptions: {
rejectUnauthorized: false
}
}

return new Promise((resolve, reject) => {
Expand Down
10 changes: 8 additions & 2 deletions test/unit/handlers/notification/callbacks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,15 @@ Test('Callback Service tests', callbacksTest => {
const url = Config.DFSP_URLS['dfsp2'].transfers
const method = 'post'
const headers = {}
const agentOptions = {
rejectUnauthorized: false
}

const expected = 200

const body = JSON.stringify(message)

request.withArgs({ url, method, body }).yields(null, { statusCode: 200 }, null)
request.withArgs({ url, method, body, agentOptions }).yields(null, { statusCode: 200 }, null)

let result = await callback.sendCallback(url, method, headers, message)
test.equal(result, expected)
Expand Down Expand Up @@ -101,11 +104,14 @@ Test('Callback Service tests', callbacksTest => {
const url = Config.DFSP_URLS['dfsp2'].transfers
const method = 'post'
const headers = {}
const agentOptions = {
rejectUnauthorized: false
}

const body = JSON.stringify(message)
const error = new Error()

request.withArgs({ url, method, body }).yields(error, null, null)
request.withArgs({ url, method, body, agentOptions }).yields(error, null, null)

try {
await callback.sendCallback(url, method, headers, message)
Expand Down