Skip to content

Commit

Permalink
Merge pull request #275 from mdebarros/feature/#2151-helm-release-v12…
Browse files Browse the repository at this point in the history
….1.0

feat(2151): helm-release-v12.1.0
- Updated dependencies
- Fixes for updated dependencies
- Bump patch version
- Fixed lint issues
- Added dep:check/update scripts, and made update:check/update aliases
- Fixed unit & integration tests - some refactoring required as using "async-await" & "done-callbacks" are not compatible --> jestjs/jest#10529
- Added fix for 'SDK Scheme Adapter is not accepting PUT /parties with 1.1 content-type header': mojaloop/project#1891
  • Loading branch information
mdebarros committed Jun 9, 2021
2 parents 6798d3b + 86597e4 commit 40e3cfc
Show file tree
Hide file tree
Showing 12 changed files with 4,123 additions and 3,368 deletions.
3 changes: 2 additions & 1 deletion src/.eslintrc.json
Expand Up @@ -25,5 +25,6 @@
],
"no-console": 2,
"no-prototype-builtins": "off"
}
},
"plugins": ["jest"]
}
3 changes: 2 additions & 1 deletion src/InboundServer/middlewares.js
Expand Up @@ -161,6 +161,7 @@ const createRequestIdGenerator = () => async (ctx, next) => {
const createHeaderValidator = (logger) => async (ctx, next) => {
const validHeaders = new Set([
'application/vnd.interoperability.parties+json;version=1.0',
'application/vnd.interoperability.parties+json;version=1.1',
'application/vnd.interoperability.participants+json;version=1.0',
'application/vnd.interoperability.quotes+json;version=1.0',
'application/vnd.interoperability.quotes+json;version=1.1',
Expand All @@ -180,7 +181,7 @@ const createHeaderValidator = (logger) => async (ctx, next) => {
catch(err) {
// error parsing body
logger.push({ err }).log('Error parsing body');
ctx.response.status = 400;
ctx.response.status = Errors.MojaloopApiErrorCodes.MALFORMED_SYNTAX.httpStatusCode;
ctx.response.body = new Errors.MojaloopFSPIOPError(err, err.message, null,
Errors.MojaloopApiErrorCodes.MALFORMED_SYNTAX).toApiErrorObject();
return;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/validate.js
Expand Up @@ -22,7 +22,7 @@ const { Errors } = require('@mojaloop/sdk-standard-components');
// Don't stop at the first error, we'll let the user know what all their errors are. Also, when we
// validate, coerce types to those we're interested in where possible.
const Ajv = require('ajv');
const ajv = new Ajv({ allErrors: true, coerceTypes: true });
const ajv = new Ajv({ allErrors: true, coerceTypes: true, strict: false });

const httpMethods = ['get', 'head', 'post', 'put', 'delete', 'connnect', 'options', 'trace', 'patch'];

Expand Down
6,828 changes: 3,756 additions & 3,072 deletions src/package-lock.json

Large diffs are not rendered by default.

68 changes: 36 additions & 32 deletions src/package.json
@@ -1,6 +1,6 @@
{
"name": "@mojaloop/sdk-scheme-adapter",
"version": "11.16.2",
"version": "11.16.3",
"description": "An adapter for connecting to Mojaloop API enabled switches.",
"main": "index.js",
"types": "index.d.ts",
Expand All @@ -19,8 +19,10 @@
"validate:api": "npm run validate:api:in; npm run validate:api:out",
"validate:api:in": "swagger-cli validate ./InboundServer/api.yaml",
"validate:api:out": "swagger-cli validate ./OutboundServer/api.yaml",
"updates:check": "npm-check-updates",
"updates:update": "npm-check-updates -u && npm install",
"updates:check": "npm run dep:check",
"updates:update": "npm run dep:update && npm install",
"dep:check": "npx ncu -e 2",
"dep:update": "npx ncu -u",
"release": "standard-version --releaseCommitMessageFormat 'chore(release): {{currentTag}} [skip ci]'"
},
"author": "Matt Kingston, James Bush, ModusBox Inc.",
Expand All @@ -30,7 +32,8 @@
"Valentin Genev <valentin.genev@modusbox.com>",
"Shashikant Hirugade <shashikant.hirugade@modusbox.com>",
"Paweł Marzec <pawel.marzec@modusbox.com>",
"Kevin Leyow <kevin.leyow@modusbox.com"
"Kevin Leyow <kevin.leyow@modusbox.com",
"Miguel de Barros <miguel.debarros@modusbox.com>"
],
"license": "Apache-2.0",
"licenses": [
Expand All @@ -45,44 +48,45 @@
},
"dependencies": {
"@koa/cors": "^3.1.0",
"@mojaloop/sdk-standard-components": "15.0.1",
"ajv": "6.12.6",
"@mojaloop/sdk-standard-components": "15.10.4",
"ajv": "8.6.0",
"axios": "^0.21.1",
"co-body": "^6.1.0",
"dotenv": "^8.2.0",
"env-var": "^7.0.0",
"dotenv": "^10.0.0",
"env-var": "^7.0.1",
"javascript-state-machine": "^3.1.0",
"json-schema-ref-parser": "^6.0.3",
"json-schema-ref-parser": "^9.0.9",
"koa": "^2.13.1",
"koa-body": "^4.2.0",
"koa2-oauth-server": "^1.0.0",
"openapi-jsonschema-parameters": "^1.1.0",
"openapi-jsonschema-parameters": "^9.0.3",
"promise-timeout": "^1.3.0",
"redis": "^3.0.2",
"uuidv4": "^6.2.6",
"ws": "^7.4.2"
"redis": "^3.1.2",
"uuidv4": "^6.2.10",
"ws": "^7.4.6"
},
"devDependencies": {
"@babel/core": "^7.12.10",
"@babel/preset-env": "^7.12.11",
"@mojaloop/api-snippets": "^12.0.5",
"@redocly/openapi-cli": "^1.0.0-beta.31",
"@types/jest": "^26.0.20",
"babel-jest": "^26.6.3",
"eslint": "^7.18.0",
"@babel/core": "^7.14.3",
"@babel/preset-env": "^7.14.4",
"@mojaloop/api-snippets": "^12.4.2",
"@redocly/openapi-cli": "^1.0.0-beta.49",
"@types/jest": "^26.0.23",
"babel-jest": "^27.0.2",
"eslint": "^7.28.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-plugin-import": "^2.22.1",
"jest": "^26.6.3",
"jest-junit": "^12.0.0",
"js-yaml": "^3.14.1",
"nock": "^13.0.6",
"npm-audit-resolver": "^2.2.1",
"npm-check-updates": "^11.0.2",
"openapi-response-validator": "^7.2.3",
"openapi-typescript": "^2.4.2",
"redis-mock": "^0.49.0",
"standard-version": "^9.1.1",
"supertest": "^6.1.2",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-jest": "^24.3.6",
"jest": "^27.0.4",
"jest-junit": "^12.1.0",
"js-yaml": "^4.1.0",
"nock": "^13.1.0",
"npm-audit-resolver": "^2.3.1",
"npm-check-updates": "^11.6.0",
"openapi-response-validator": "^9.0.3",
"openapi-typescript": "^4.0.0",
"redis-mock": "^0.56.3",
"standard-version": "^9.3.0",
"supertest": "^6.1.3",
"swagger-cli": "^4.0.4"
}
}
6 changes: 3 additions & 3 deletions src/test/__mocks__/redis.js
Expand Up @@ -14,8 +14,8 @@ const redisMock = require('redis-mock');

// redis-mock currently ignores callback argument, the following class fix this
class RedisClient extends redisMock.RedisClient {
constructor() {
super();
constructor(options, stream, redisMock) {
super(options, stream, redisMock);
}

_executeCallback(...args) {
Expand Down Expand Up @@ -45,5 +45,5 @@ class RedisClient extends redisMock.RedisClient {


module.exports = {
createClient: () => new RedisClient(),
createClient: (options = {host: 'localhost', port: 6380}, stream, redisMock) => new RedisClient(options, stream, redisMock),
};
33 changes: 17 additions & 16 deletions src/test/integration/lib/Outbound/simpleTransfers.test.js
Expand Up @@ -41,26 +41,27 @@ describe('/simpleTransfers', () => {
expect(typeof res.data.transfer).toEqual('object');
});

test('post - timeout', async (done) => {
test('post - timeout', async () => {
const postTransfersURI = `${env.OutboundHostURI}/simpleTransfers`;
const transferId = uuid();
axios({
method: 'POST',
url: postTransfersURI,
data: {
fspId: 'timeout-fsp-id-transfer',
transfersPostRequest: {
...transfersPostRequest,
transferId
try {
await axios({
method: 'POST',
url: postTransfersURI,
data: {
fspId: 'timeout-fsp-id-transfer',
transfersPostRequest: {
...transfersPostRequest,
transferId
}
},
headers: {
'access-control-allow-origin': '*'
}
},
headers: {
'access-control-allow-origin': '*'
}
}).catch(err => {
});
} catch (err) {
expect(err.response.status).toEqual(500);
expect(err.response.data.message).toEqual('Timeout');
done();
});
}
});
});
9 changes: 7 additions & 2 deletions src/test/unit/api/transfers/transfers.test.js
Expand Up @@ -83,10 +83,15 @@ describe('Outbound Transfers API', () => {
serversInfo.reqOutbound.post('/transfers').
send(postTransfersBadBody).
expect(400, {
message: '.body.to.idType should be equal to one of the allowed values',
message: 'must be equal to one of the allowed values',
statusCode: 400,
}).
end(done);
end((err) => {
if (err) {
return done(err);
}
return done();
});
});

test('should return success response', () => {
Expand Down

0 comments on commit 40e3cfc

Please sign in to comment.