Skip to content

Commit

Permalink
Enhancement/tweaks (#143)
Browse files Browse the repository at this point in the history
* 1. enhance error logging for outbound model
2. add test for ignore jws on put parties config flag

* bump version

* fix linting - missing semicolon
  • Loading branch information
bushjames authored Apr 9, 2020
1 parent ef88167 commit 1156d7b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/lib/model/OutboundTransfersModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ class OutboundTransfersModel {

if(payee.errorInformation) {
// this is an error response to our GET /parties request
const err = new BackendError(`Got an error response resolving party: ${util.inspect(payee)}`, 500);
const err = new BackendError(`Got an error response resolving party: ${util.inspect(payee, { depth: Infinity })}`, 500);
err.mojaloopError = payee;

// cancel the timeout handler
Expand Down Expand Up @@ -315,7 +315,7 @@ class OutboundTransfersModel {
}
}
} else if (message.type === 'quoteResponseError') {
error = new BackendError(`Got an error response requesting quote: ${util.inspect(message.data)}`, 500);
error = new BackendError(`Got an error response requesting quote: ${util.inspect(message.data, { depth: Infinity })}`, 500);
error.mojaloopError = message.data;
}
else {
Expand Down Expand Up @@ -460,7 +460,7 @@ class OutboundTransfersModel {
}
}
} else if (message.type === 'transferError') {
error = new BackendError(`Got an error response preparing transfer: ${util.inspect(message.data)}`, 500);
error = new BackendError(`Got an error response preparing transfer: ${util.inspect(message.data, { depth: Infinity })}`, 500);
error.mojaloopError = message.data;
} else {
this._logger.push({ message }).log(`Ignoring cache notification for transfer ${transferKey}. Uknokwn message type ${message.type}.`);
Expand Down Expand Up @@ -541,7 +541,7 @@ class OutboundTransfersModel {
let message = JSON.parse(msg);

if (message.type === 'transferError') {
error = new BackendError(`Got an error response retrieving transfer: ${util.inspect(message.data)}`, 500);
error = new BackendError(`Got an error response retrieving transfer: ${util.inspect(message.data, { depth: Infinity })}`, 500);
error.mojaloopError = message.data;
} else if (message.type !== 'transferFulfil') {
this._logger.push({ message }).log(`Ignoring cache notification for transfer ${transferKey}. Uknokwn message type ${message.type}.`);
Expand Down
2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mojaloop/sdk-scheme-adapter",
"version": "9.4.4",
"version": "9.4.5",
"description": "An adapter for connecting to Mojaloop API enabled switches.",
"main": "index.js",
"scripts": {
Expand Down
11 changes: 11 additions & 0 deletions src/test/unit/config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ describe('config', () => {
expect(config.outboundErrorStatusCodeExtensionKey).toBeUndefined();
});

it('correctly parses VALIDATE_INBOUND_PUT_PARTIES_JWS when NOT set', () => {
delete process.env.VALIDATE_INBOUND_PUT_PARTIES_JWS;
const config = require('../../config');
expect(config.validateInboundPutPartiesJws).toBeFalsy();
});

it('correctly parses VALIDATE_INBOUND_PUT_PARTIES_JWS when set', () => {
process.env.VALIDATE_INBOUND_PUT_PARTIES_JWS = 'true';
const config = require('../../config');
expect(config.validateInboundPutPartiesJws).toBeTruthy();
});

it('return single cert content from IN_SERVER_CERT_PATH', () => {
const cert = path.join(certDir, 'cert.pem');
Expand Down

0 comments on commit 1156d7b

Please sign in to comment.