@mojaloop/sdk-scheme-adapter 11.18.5 → 11.18.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/InboundServer/api.yaml +2 -0
- package/InboundServer/handlers.js +0 -38
- package/InboundServer/middlewares.js +1 -1
- package/OutboundServer/api.yaml +23 -270
- package/OutboundServer/api_interfaces/openapi.d.ts +10 -127
- package/OutboundServer/api_template/openapi.yaml +0 -3
- package/OutboundServer/handlers.js +2 -40
- package/audit-resolve.json +98 -6
- package/lib/cache.js +23 -7
- package/lib/model/index.js +1 -3
- package/package.json +30 -58
- package/test/__mocks__/@mojaloop/sdk-standard-components.js +0 -2
- package/test/config/integration.env +0 -3
- package/test/unit/inboundApi/handlers.test.js +0 -46
- package/test/unit/outboundApi/handlers.test.js +1 -100
- package/OutboundServer/api_template/components/responses/authorizationPostSuccess.yaml +0 -5
- package/OutboundServer/api_template/components/responses/authorizationsServerError.yaml +0 -5
- package/OutboundServer/api_template/components/schemas/authorizationsPostRequest.yaml +0 -15
- package/OutboundServer/api_template/components/schemas/authorizationsPostResponse.yaml +0 -19
- package/OutboundServer/api_template/components/schemas/errorAuthorizationsResponse.yaml +0 -3
- package/OutboundServer/api_template/paths/authorizations.yaml +0 -19
- package/lib/model/AuthorizationsModel.js +0 -86
- package/test/integration/lib/Outbound/authorizations.test.js +0 -58
- package/test/integration/lib/Outbound/data/authorizationsPostRequest.json +0 -43
- package/test/unit/lib/model/AuthorizationsModel.test.js +0 -460
- package/test/unit/lib/model/data/putAuthorizationsResponse.json +0 -10
|
@@ -23,8 +23,7 @@ const {
|
|
|
23
23
|
OutboundBulkQuotesModel,
|
|
24
24
|
PartiesModel,
|
|
25
25
|
QuotesModel,
|
|
26
|
-
TransfersModel
|
|
27
|
-
AuthorizationsModel
|
|
26
|
+
TransfersModel
|
|
28
27
|
} = require('../lib/model');
|
|
29
28
|
|
|
30
29
|
|
|
@@ -97,9 +96,6 @@ const handleRequestQuotesInformationError = (method, err, ctx) =>
|
|
|
97
96
|
const handleRequestSimpleTransfersInformationError = (method, err, ctx) =>
|
|
98
97
|
handleError(method, err, ctx, 'requestSimpleTransfersInformationState');
|
|
99
98
|
|
|
100
|
-
const handleRequestAuthorizationsInformationError = (method, err, ctx) =>
|
|
101
|
-
handleError(method, err, ctx, 'requestAuthorizationsInformationState');
|
|
102
|
-
|
|
103
99
|
/**
|
|
104
100
|
* Handler for outbound transfer request initiation
|
|
105
101
|
*/
|
|
@@ -538,37 +534,6 @@ const postSimpleTransfers = async (ctx) => {
|
|
|
538
534
|
}
|
|
539
535
|
};
|
|
540
536
|
|
|
541
|
-
const postAuthorizations = async (ctx) => {
|
|
542
|
-
|
|
543
|
-
const authorization = { ...ctx.request.body.authorizationsPostRequest };
|
|
544
|
-
const fspId = ctx.request.body.fspId;
|
|
545
|
-
const args = { transactionRequestId: authorization.transactionRequestId, fspId, authorization };
|
|
546
|
-
|
|
547
|
-
try {
|
|
548
|
-
// prepare config
|
|
549
|
-
const modelConfig = {
|
|
550
|
-
...ctx.state.conf,
|
|
551
|
-
cache: ctx.state.cache,
|
|
552
|
-
logger: ctx.state.logger,
|
|
553
|
-
wso2Auth: ctx.state.wso2Auth,
|
|
554
|
-
};
|
|
555
|
-
|
|
556
|
-
const cacheKey = AuthorizationsModel.generateKey(args);
|
|
557
|
-
|
|
558
|
-
// use the authorizations model to execute asynchronous stages with the switch
|
|
559
|
-
const model = await AuthorizationsModel.create({}, cacheKey, modelConfig);
|
|
560
|
-
|
|
561
|
-
// run model's workflow
|
|
562
|
-
const response = await model.run(args);
|
|
563
|
-
|
|
564
|
-
// return the result
|
|
565
|
-
ctx.response.status = 200;
|
|
566
|
-
ctx.response.body = response;
|
|
567
|
-
} catch (err) {
|
|
568
|
-
return handleRequestAuthorizationsInformationError('postAuthorizations', err, ctx);
|
|
569
|
-
}
|
|
570
|
-
};
|
|
571
|
-
|
|
572
537
|
module.exports = {
|
|
573
538
|
'/': {
|
|
574
539
|
get: healthCheck
|
|
@@ -615,8 +580,5 @@ module.exports = {
|
|
|
615
580
|
},
|
|
616
581
|
'/simpleTransfers': {
|
|
617
582
|
post: postSimpleTransfers
|
|
618
|
-
}
|
|
619
|
-
'/authorizations': {
|
|
620
|
-
post: postAuthorizations
|
|
621
|
-
}
|
|
583
|
+
}
|
|
622
584
|
};
|
package/audit-resolve.json
CHANGED
|
@@ -30,22 +30,114 @@
|
|
|
30
30
|
},
|
|
31
31
|
"1500|@mojaloop/central-services-shared>widdershins>yargs>yargs-parser": {
|
|
32
32
|
"decision": "ignore",
|
|
33
|
-
"madeAt":
|
|
34
|
-
"expiresAt":
|
|
33
|
+
"madeAt": 1631785234887,
|
|
34
|
+
"expiresAt": 1632390016480
|
|
35
35
|
},
|
|
36
36
|
"1675|@mojaloop/central-services-shared>shins>sanitize-html": {
|
|
37
37
|
"decision": "ignore",
|
|
38
|
-
"madeAt":
|
|
39
|
-
"expiresAt":
|
|
38
|
+
"madeAt": 1631785236962,
|
|
39
|
+
"expiresAt": 1632390016480
|
|
40
40
|
},
|
|
41
41
|
"1676|@mojaloop/central-services-shared>shins>sanitize-html": {
|
|
42
42
|
"decision": "ignore",
|
|
43
|
-
"madeAt":
|
|
44
|
-
"expiresAt":
|
|
43
|
+
"madeAt": 1631785236962,
|
|
44
|
+
"expiresAt": 1632390016480
|
|
45
45
|
},
|
|
46
46
|
"1766|@mojaloop/central-services-shared>widdershins>urijs": {
|
|
47
47
|
"decision": "fix",
|
|
48
48
|
"madeAt": 1627405029179
|
|
49
|
+
},
|
|
50
|
+
"1779|@mojaloop/event-sdk>grpc>@mapbox/node-pre-gyp>tar": {
|
|
51
|
+
"decision": "fix",
|
|
52
|
+
"madeAt": 1631785230676
|
|
53
|
+
},
|
|
54
|
+
"1780|@mojaloop/event-sdk>grpc>@mapbox/node-pre-gyp>tar": {
|
|
55
|
+
"decision": "fix",
|
|
56
|
+
"madeAt": 1631785230676
|
|
57
|
+
},
|
|
58
|
+
"1781|@mojaloop/event-sdk>grpc>@mapbox/node-pre-gyp>tar": {
|
|
59
|
+
"decision": "fix",
|
|
60
|
+
"madeAt": 1631785230676
|
|
61
|
+
},
|
|
62
|
+
"1002401|@mojaloop/event-sdk>@grpc/proto-loader>yargs>string-width>strip-ansi>ansi-regex": {
|
|
63
|
+
"decision": "ignore",
|
|
64
|
+
"madeAt": 1634716056413,
|
|
65
|
+
"expiresAt": 1637308004771
|
|
66
|
+
},
|
|
67
|
+
"1002401|@mojaloop/central-services-shared>widdershins>oas-resolver>yargs>string-width>strip-ansi>ansi-regex": {
|
|
68
|
+
"decision": "ignore",
|
|
69
|
+
"madeAt": 1634716056413,
|
|
70
|
+
"expiresAt": 1637308004771
|
|
71
|
+
},
|
|
72
|
+
"1002401|@mojaloop/central-services-shared>widdershins>oas-resolver>yargs>cliui>string-width>strip-ansi>ansi-regex": {
|
|
73
|
+
"decision": "ignore",
|
|
74
|
+
"madeAt": 1634716056413,
|
|
75
|
+
"expiresAt": 1637308004771
|
|
76
|
+
},
|
|
77
|
+
"1002401|@mojaloop/central-services-shared>widdershins>swagger2openapi>oas-resolver>yargs>cliui>string-width>strip-ansi>ansi-regex": {
|
|
78
|
+
"decision": "ignore",
|
|
79
|
+
"madeAt": 1634716056413,
|
|
80
|
+
"expiresAt": 1637308004771
|
|
81
|
+
},
|
|
82
|
+
"1002401|@mojaloop/central-services-shared>widdershins>swagger2openapi>oas-validator>oas-resolver>yargs>cliui>string-width>strip-ansi>ansi-regex": {
|
|
83
|
+
"decision": "ignore",
|
|
84
|
+
"madeAt": 1634716056413,
|
|
85
|
+
"expiresAt": 1637308004771
|
|
86
|
+
},
|
|
87
|
+
"1002401|@mojaloop/central-services-shared>widdershins>swagger2openapi>oas-validator>oas-resolver>yargs>cliui>wrap-ansi>string-width>strip-ansi>ansi-regex": {
|
|
88
|
+
"decision": "ignore",
|
|
89
|
+
"madeAt": 1634716056413,
|
|
90
|
+
"expiresAt": 1637308004771
|
|
91
|
+
},
|
|
92
|
+
"1002401|@mojaloop/event-sdk>@grpc/proto-loader>yargs>cliui>wrap-ansi>strip-ansi>ansi-regex": {
|
|
93
|
+
"decision": "ignore",
|
|
94
|
+
"madeAt": 1634716056413,
|
|
95
|
+
"expiresAt": 1637308004771
|
|
96
|
+
},
|
|
97
|
+
"1002401|@mojaloop/central-services-shared>widdershins>oas-resolver>yargs>cliui>wrap-ansi>strip-ansi>ansi-regex": {
|
|
98
|
+
"decision": "ignore",
|
|
99
|
+
"madeAt": 1634716056413,
|
|
100
|
+
"expiresAt": 1637308004771
|
|
101
|
+
},
|
|
102
|
+
"1002401|@mojaloop/central-services-shared>widdershins>swagger2openapi>oas-resolver>yargs>cliui>wrap-ansi>strip-ansi>ansi-regex": {
|
|
103
|
+
"decision": "ignore",
|
|
104
|
+
"madeAt": 1634716056413,
|
|
105
|
+
"expiresAt": 1637308004771
|
|
106
|
+
},
|
|
107
|
+
"1002401|@mojaloop/central-services-shared>widdershins>swagger2openapi>oas-validator>oas-resolver>yargs>cliui>wrap-ansi>strip-ansi>ansi-regex": {
|
|
108
|
+
"decision": "ignore",
|
|
109
|
+
"madeAt": 1634716056413,
|
|
110
|
+
"expiresAt": 1637308004771
|
|
111
|
+
},
|
|
112
|
+
"1002401|@mojaloop/event-sdk>@grpc/proto-loader>yargs>cliui>strip-ansi>ansi-regex": {
|
|
113
|
+
"decision": "ignore",
|
|
114
|
+
"madeAt": 1634716056413,
|
|
115
|
+
"expiresAt": 1637308004771
|
|
116
|
+
},
|
|
117
|
+
"1002401|@mojaloop/central-services-shared>widdershins>yargs>string-width>strip-ansi>ansi-regex": {
|
|
118
|
+
"decision": "ignore",
|
|
119
|
+
"madeAt": 1634716073663,
|
|
120
|
+
"expiresAt": 1637308004771
|
|
121
|
+
},
|
|
122
|
+
"1002401|@mojaloop/central-services-shared>widdershins>yargs>cliui>string-width>strip-ansi>ansi-regex": {
|
|
123
|
+
"decision": "ignore",
|
|
124
|
+
"madeAt": 1634716073664,
|
|
125
|
+
"expiresAt": 1637308004771
|
|
126
|
+
},
|
|
127
|
+
"1002865|@mojaloop/central-services-shared>shins>sanitize-html": {
|
|
128
|
+
"decision": "ignore",
|
|
129
|
+
"madeAt": 1634716077764,
|
|
130
|
+
"expiresAt": 1637308004771
|
|
131
|
+
},
|
|
132
|
+
"1002866|@mojaloop/central-services-shared>shins>sanitize-html": {
|
|
133
|
+
"decision": "ignore",
|
|
134
|
+
"madeAt": 1634716077764,
|
|
135
|
+
"expiresAt": 1637308004771
|
|
136
|
+
},
|
|
137
|
+
"1003019|@mojaloop/central-services-shared>widdershins>yargs>yargs-parser": {
|
|
138
|
+
"decision": "ignore",
|
|
139
|
+
"madeAt": 1634716081521,
|
|
140
|
+
"expiresAt": 1637308004771
|
|
49
141
|
}
|
|
50
142
|
},
|
|
51
143
|
"rules": {},
|
package/lib/cache.js
CHANGED
|
@@ -74,6 +74,7 @@ class Cache {
|
|
|
74
74
|
await this._inProgressDisconnection;
|
|
75
75
|
break;
|
|
76
76
|
}
|
|
77
|
+
|
|
77
78
|
this._connectionState = CONN_ST.CONNECTING;
|
|
78
79
|
this._inProgressConnection = Promise.all([this._getClient(), this._getClient()]);
|
|
79
80
|
[this._client, this._subscriptionClient] = await this._inProgressConnection;
|
|
@@ -81,10 +82,6 @@ class Cache {
|
|
|
81
82
|
// hook up our sub message handler
|
|
82
83
|
this._subscriptionClient.on('message', this._onMessage.bind(this));
|
|
83
84
|
|
|
84
|
-
if (this._config.enableTestFeatures) {
|
|
85
|
-
this.setTestMode(true);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
85
|
this._inProgressConnection = null;
|
|
89
86
|
this._connectionState = CONN_ST.CONNECTED;
|
|
90
87
|
}
|
|
@@ -103,7 +100,7 @@ class Cache {
|
|
|
103
100
|
const mode = enable ? 'Es$' : '';
|
|
104
101
|
this._logger
|
|
105
102
|
.push({ 'notify-keyspace-events': mode })
|
|
106
|
-
.log('
|
|
103
|
+
.log('REDIS client Configured to emit keyspace-events');
|
|
107
104
|
this._client.config('SET', 'notify-keyspace-events', mode);
|
|
108
105
|
}
|
|
109
106
|
|
|
@@ -231,14 +228,33 @@ class Cache {
|
|
|
231
228
|
const client = redis.createClient(this._config);
|
|
232
229
|
|
|
233
230
|
client.on('error', (err) => {
|
|
234
|
-
this._logger.push({ err }).log('
|
|
231
|
+
this._logger.push({ err }).log('REDIS client Error');
|
|
232
|
+
return reject(err);
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
client.on('reconnecting', (err) => {
|
|
236
|
+
this._logger.push({ err }).log('REDIS client Reconnecting');
|
|
235
237
|
return reject(err);
|
|
236
238
|
});
|
|
237
239
|
|
|
240
|
+
client.on('subscribe', (channel, count) => {
|
|
241
|
+
this._logger.push({ channel, count }).log('REDIS client subscribe');
|
|
242
|
+
// On a subscribe event, ensure that testFeatures are enabled.
|
|
243
|
+
// This is required here in the advent of a disconnect/reconnect event. Redis client will re-subscribe all subscriptions, but previously enabledTestFeatures will be lost.
|
|
244
|
+
// Handling this on the on subscribe event will ensure its always configured.
|
|
245
|
+
if (this._config.enableTestFeatures) {
|
|
246
|
+
this.setTestMode(true);
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
|
|
238
250
|
client.on('ready', () => {
|
|
239
|
-
this._logger.log(`
|
|
251
|
+
this._logger.log(`REDIS client ready at: ${this._config.host}:${this._config.port}`);
|
|
240
252
|
return resolve(client);
|
|
241
253
|
});
|
|
254
|
+
|
|
255
|
+
client.on('connect', () => {
|
|
256
|
+
this._logger.log(`REDIS client connected at: ${this._config.host}:${this._config.port}`);
|
|
257
|
+
});
|
|
242
258
|
});
|
|
243
259
|
}
|
|
244
260
|
|
package/lib/model/index.js
CHANGED
|
@@ -23,7 +23,6 @@ const { BackendError, PersistentStateMachine } = require('./common');
|
|
|
23
23
|
const PartiesModel = require('./PartiesModel');
|
|
24
24
|
const QuotesModel = require('./QuotesModel');
|
|
25
25
|
const TransfersModel = require('./TransfersModel');
|
|
26
|
-
const AuthorizationsModel = require('./AuthorizationsModel');
|
|
27
26
|
|
|
28
27
|
module.exports = {
|
|
29
28
|
AccountsModel,
|
|
@@ -38,6 +37,5 @@ module.exports = {
|
|
|
38
37
|
PersistentStateMachine,
|
|
39
38
|
PartiesModel,
|
|
40
39
|
QuotesModel,
|
|
41
|
-
TransfersModel
|
|
42
|
-
AuthorizationsModel
|
|
40
|
+
TransfersModel
|
|
43
41
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mojaloop/sdk-scheme-adapter",
|
|
3
|
-
"version": "11.18.
|
|
3
|
+
"version": "11.18.9",
|
|
4
4
|
"description": "An adapter for connecting to Mojaloop API enabled switches.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -51,10 +51,16 @@
|
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@koa/cors": "^3.1.0",
|
|
54
|
-
"@mojaloop/central-services-
|
|
55
|
-
"@mojaloop/
|
|
56
|
-
"
|
|
57
|
-
"
|
|
54
|
+
"@mojaloop/central-services-error-handling": "11.3.0",
|
|
55
|
+
"@mojaloop/central-services-health": "13.0.0",
|
|
56
|
+
"@mojaloop/central-services-logger": "10.6.1",
|
|
57
|
+
"@mojaloop/central-services-metrics": "11.0.0",
|
|
58
|
+
"@mojaloop/central-services-shared": "14.0.0",
|
|
59
|
+
"@mojaloop/event-sdk": "10.7.1",
|
|
60
|
+
"@mojaloop/sdk-standard-components": "15.13.0",
|
|
61
|
+
"ajv": "8.6.3",
|
|
62
|
+
"ajv-keywords": "5.0.0",
|
|
63
|
+
"axios": "^0.21.4",
|
|
58
64
|
"co-body": "^6.1.0",
|
|
59
65
|
"dotenv": "^10.0.0",
|
|
60
66
|
"env-var": "^7.0.1",
|
|
@@ -64,67 +70,33 @@
|
|
|
64
70
|
"koa": "^2.13.1",
|
|
65
71
|
"koa-body": "^4.2.0",
|
|
66
72
|
"koa2-oauth-server": "^1.0.0",
|
|
67
|
-
"openapi-jsonschema-parameters": "^9.0
|
|
73
|
+
"openapi-jsonschema-parameters": "^9.3.0",
|
|
68
74
|
"promise-timeout": "^1.3.0",
|
|
69
75
|
"redis": "^3.1.2",
|
|
70
|
-
"uuidv4": "^6.2.
|
|
71
|
-
"ws": "^7.
|
|
76
|
+
"uuidv4": "^6.2.12",
|
|
77
|
+
"ws": "^7.5.5"
|
|
72
78
|
},
|
|
73
79
|
"devDependencies": {
|
|
74
|
-
"@babel/core": "^7.
|
|
75
|
-
"@babel/preset-env": "^7.
|
|
76
|
-
"@mojaloop/api-snippets": "^
|
|
77
|
-
"@
|
|
78
|
-
"@
|
|
79
|
-
"
|
|
80
|
-
"@mojaloop/event-sdk": "10.7.1",
|
|
81
|
-
"@redocly/openapi-cli": "^1.0.0-beta.49",
|
|
82
|
-
"@types/jest": "^26.0.23",
|
|
83
|
-
"ajv": "8.6.0",
|
|
84
|
-
"ajv-keywords": "5.0.0",
|
|
85
|
-
"babel-jest": "^27.0.2",
|
|
80
|
+
"@babel/core": "^7.15.5",
|
|
81
|
+
"@babel/preset-env": "^7.15.6",
|
|
82
|
+
"@mojaloop/api-snippets": "^13.0.3",
|
|
83
|
+
"@redocly/openapi-cli": "^1.0.0-beta.59",
|
|
84
|
+
"@types/jest": "^27.0.1",
|
|
85
|
+
"babel-jest": "^27.2.0",
|
|
86
86
|
"eslint": "^7.32.0",
|
|
87
87
|
"eslint-config-airbnb-base": "^14.2.1",
|
|
88
|
-
"eslint-plugin-import": "^2.
|
|
89
|
-
"eslint-plugin-jest": "^24.
|
|
90
|
-
"jest": "^27.0
|
|
91
|
-
"jest-junit": "^12.
|
|
92
|
-
"nock": "^13.1.
|
|
88
|
+
"eslint-plugin-import": "^2.24.2",
|
|
89
|
+
"eslint-plugin-jest": "^24.4.0",
|
|
90
|
+
"jest": "^27.2.0",
|
|
91
|
+
"jest-junit": "^12.2.0",
|
|
92
|
+
"nock": "^13.1.3",
|
|
93
93
|
"npm-audit-resolver": "^2.3.1",
|
|
94
|
-
"npm-check-updates": "^11.
|
|
95
|
-
"openapi-response-validator": "^9.0
|
|
96
|
-
"openapi-typescript": "^4.0.
|
|
94
|
+
"npm-check-updates": "^11.8.5",
|
|
95
|
+
"openapi-response-validator": "^9.3.0",
|
|
96
|
+
"openapi-typescript": "^4.0.2",
|
|
97
97
|
"redis-mock": "^0.56.3",
|
|
98
|
-
"standard-version": "^9.3.
|
|
99
|
-
"supertest": "^6.1.
|
|
98
|
+
"standard-version": "^9.3.1",
|
|
99
|
+
"supertest": "^6.1.6",
|
|
100
100
|
"swagger-cli": "^4.0.4"
|
|
101
|
-
},
|
|
102
|
-
"peerDependencies": {
|
|
103
|
-
"@mojaloop/central-services-error-handling": "11.3.0",
|
|
104
|
-
"@mojaloop/central-services-logger": "10.6.1",
|
|
105
|
-
"@mojaloop/central-services-metrics": "11.0.0",
|
|
106
|
-
"@mojaloop/event-sdk": "10.7.1",
|
|
107
|
-
"ajv": "8.6.0",
|
|
108
|
-
"ajv-keywords": "5.0.0"
|
|
109
|
-
},
|
|
110
|
-
"peerDependenciesMeta": {
|
|
111
|
-
"@mojaloop/central-services-error-handling": {
|
|
112
|
-
"optional": false
|
|
113
|
-
},
|
|
114
|
-
"@mojaloop/central-services-logger": {
|
|
115
|
-
"optional": false
|
|
116
|
-
},
|
|
117
|
-
"@mojaloop/central-services-metrics": {
|
|
118
|
-
"optional": false
|
|
119
|
-
},
|
|
120
|
-
"@mojaloop/event-sdk": {
|
|
121
|
-
"optional": false
|
|
122
|
-
},
|
|
123
|
-
"ajv": {
|
|
124
|
-
"optional": false
|
|
125
|
-
},
|
|
126
|
-
"ajv-keyboards": {
|
|
127
|
-
"optional": false
|
|
128
|
-
}
|
|
129
101
|
}
|
|
130
102
|
}
|
|
@@ -26,7 +26,6 @@ class MockMojaloopRequests extends MojaloopRequests {
|
|
|
26
26
|
this.putQuotes = MockMojaloopRequests.__putQuotes;
|
|
27
27
|
this.putQuotesError = MockMojaloopRequests.__putQuotesError;
|
|
28
28
|
this.getAuthorizations = MockMojaloopRequests.__getAuthorizations;
|
|
29
|
-
this.postAuthorizations = MockMojaloopRequests.__postAuthorizations;
|
|
30
29
|
this.putAuthorizations = MockMojaloopRequests.__putAuthorizations;
|
|
31
30
|
this.getTransfers = MockMojaloopRequests.__getTransfers;
|
|
32
31
|
this.putTransactionRequests = MockMojaloopRequests.__putTransactionRequests;
|
|
@@ -50,7 +49,6 @@ MockMojaloopRequests.__postQuotes = jest.fn(() => Promise.resolve());
|
|
|
50
49
|
MockMojaloopRequests.__putQuotes = jest.fn(() => Promise.resolve());
|
|
51
50
|
MockMojaloopRequests.__putQuotesError = jest.fn(() => Promise.resolve());
|
|
52
51
|
MockMojaloopRequests.__getAuthorizations = jest.fn(() => Promise.resolve());
|
|
53
|
-
MockMojaloopRequests.__postAuthorizations = jest.fn(() => Promise.resolve());
|
|
54
52
|
MockMojaloopRequests.__putAuthorizations = jest.fn(() => Promise.resolve());
|
|
55
53
|
MockMojaloopRequests.__getTransfers = jest.fn(() => Promise.resolve());
|
|
56
54
|
MockMojaloopRequests.__putTransactionRequests = jest.fn(() => Promise.resolve());
|
|
@@ -127,9 +127,6 @@ QUOTES_ENDPOINT=ml-testing-toolkit:5000
|
|
|
127
127
|
# TRANSFERS_ENDPOINT
|
|
128
128
|
TRANSFERS_ENDPOINT=ml-testing-toolkit:5000
|
|
129
129
|
|
|
130
|
-
# Authorizations_ENDPOINT
|
|
131
|
-
TRANSACTION_REQUESTS_ENDPOINT=ml-testing-toolkit:5000
|
|
132
|
-
|
|
133
130
|
# To allow transfer without a previous quote request, set this value to true.
|
|
134
131
|
# The incoming transfer request should consists of an ILP packet and a matching condition in this case.
|
|
135
132
|
# The fulfilment will be generated from the provided ILP packet, and must hash to the provided condition.
|
|
@@ -17,7 +17,6 @@ const Model = require('../../../lib/model').InboundTransfersModel;
|
|
|
17
17
|
const QuotesModel = require('../../../lib/model').QuotesModel;
|
|
18
18
|
const PartiesModel = require('../../../lib/model').PartiesModel;
|
|
19
19
|
const TransfersModel = require('../../../lib/model').TransfersModel;
|
|
20
|
-
const AuthorizationsModel = require('../../../lib/model').AuthorizationsModel;
|
|
21
20
|
|
|
22
21
|
const mockArguments = require('./data/mockArguments');
|
|
23
22
|
const mockTransactionRequestData = require('./data/mockTransactionRequest');
|
|
@@ -527,51 +526,6 @@ describe('Inbound API handlers:', () => {
|
|
|
527
526
|
});
|
|
528
527
|
});
|
|
529
528
|
|
|
530
|
-
describe('PUT /authorizations', () => {
|
|
531
|
-
|
|
532
|
-
let mockContext;
|
|
533
|
-
|
|
534
|
-
beforeEach(() => {
|
|
535
|
-
mockContext = {
|
|
536
|
-
request: {
|
|
537
|
-
body: { the: 'mocked-body' },
|
|
538
|
-
headers: {
|
|
539
|
-
'fspiop-source': 'foo'
|
|
540
|
-
}
|
|
541
|
-
},
|
|
542
|
-
response: {},
|
|
543
|
-
state: {
|
|
544
|
-
conf: {},
|
|
545
|
-
path: {
|
|
546
|
-
params: {
|
|
547
|
-
'ID': '1234'
|
|
548
|
-
}
|
|
549
|
-
},
|
|
550
|
-
logger: new Logger.Logger({ context: { app: 'inbound-handlers-unit-test' }, stringify: () => '' }),
|
|
551
|
-
cache: {
|
|
552
|
-
publish: jest.fn(() => Promise.resolve(true))
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
};
|
|
556
|
-
|
|
557
|
-
});
|
|
558
|
-
|
|
559
|
-
test('calls `AuthorizationsModel.triggerDeferredJobSpy` with the expected arguments.', async () => {
|
|
560
|
-
const triggerDeferredJobSpy = jest.spyOn(AuthorizationsModel, 'triggerDeferredJob');
|
|
561
|
-
|
|
562
|
-
await expect(handlers['/authorizations/{ID}'].put(mockContext)).resolves.toBe(undefined);
|
|
563
|
-
|
|
564
|
-
expect(triggerDeferredJobSpy).toHaveBeenCalledTimes(1);
|
|
565
|
-
expect(triggerDeferredJobSpy).toBeCalledWith({
|
|
566
|
-
cache: mockContext.state.cache,
|
|
567
|
-
message: mockContext.request.body,
|
|
568
|
-
args: {
|
|
569
|
-
transactionRequestId: mockContext.state.path.params.ID
|
|
570
|
-
}
|
|
571
|
-
});
|
|
572
|
-
});
|
|
573
|
-
});
|
|
574
|
-
|
|
575
529
|
describe('PATCH /transfers/{ID}', () => {
|
|
576
530
|
let mockNotificationMessage;
|
|
577
531
|
|
|
@@ -35,8 +35,7 @@ const {
|
|
|
35
35
|
OutboundRequestToPayModel,
|
|
36
36
|
PartiesModel,
|
|
37
37
|
QuotesModel,
|
|
38
|
-
TransfersModel
|
|
39
|
-
AuthorizationsModel
|
|
38
|
+
TransfersModel
|
|
40
39
|
} = require('../../../lib/model');
|
|
41
40
|
|
|
42
41
|
/**
|
|
@@ -885,102 +884,4 @@ describe('Outbound API handlers:', () => {
|
|
|
885
884
|
});
|
|
886
885
|
});
|
|
887
886
|
});
|
|
888
|
-
describe('POST /authorizations', () => {
|
|
889
|
-
const mockContext = {
|
|
890
|
-
request: {
|
|
891
|
-
body: {
|
|
892
|
-
fspId: uuid(),
|
|
893
|
-
authorizationsPostRequest: {
|
|
894
|
-
transactionRequestId: uuid()
|
|
895
|
-
}
|
|
896
|
-
}
|
|
897
|
-
},
|
|
898
|
-
response: {},
|
|
899
|
-
state: {
|
|
900
|
-
conf: {},
|
|
901
|
-
wso2Auth: 'mocked wso2Auth',
|
|
902
|
-
logger: mockLogger({ app: 'outbound-api-handlers-test' }),
|
|
903
|
-
cache: {
|
|
904
|
-
subscribe: jest.fn(() => Promise.resolve())
|
|
905
|
-
}
|
|
906
|
-
},
|
|
907
|
-
};
|
|
908
|
-
test('happy flow', async () => {
|
|
909
|
-
|
|
910
|
-
// mock state machine
|
|
911
|
-
const mockedPSM = {
|
|
912
|
-
run: jest.fn(async () => ({ the: 'run response' }))
|
|
913
|
-
};
|
|
914
|
-
|
|
915
|
-
const createSpy = jest.spyOn(AuthorizationsModel, 'create')
|
|
916
|
-
.mockImplementationOnce(async () => mockedPSM);
|
|
917
|
-
|
|
918
|
-
// invoke handler
|
|
919
|
-
await handlers['/authorizations'].post(mockContext);
|
|
920
|
-
|
|
921
|
-
// PSM model creation
|
|
922
|
-
const state = mockContext.state;
|
|
923
|
-
const cacheKey = AuthorizationsModel.channelName({
|
|
924
|
-
transactionRequestId: mockContext.request.body.authorizationsPostRequest.transactionRequestId
|
|
925
|
-
});
|
|
926
|
-
const expectedConfig = {
|
|
927
|
-
cache: state.cache,
|
|
928
|
-
logger: state.logger,
|
|
929
|
-
wso2Auth: state.wso2Auth
|
|
930
|
-
};
|
|
931
|
-
expect(createSpy).toBeCalledWith({}, cacheKey, expectedConfig);
|
|
932
|
-
|
|
933
|
-
// run workflow
|
|
934
|
-
expect(mockedPSM.run).toBeCalledWith({
|
|
935
|
-
transactionRequestId: mockContext.request.body.authorizationsPostRequest.transactionRequestId,
|
|
936
|
-
fspId: mockContext.request.body.fspId,
|
|
937
|
-
authorization: mockContext.request.body.authorizationsPostRequest
|
|
938
|
-
});
|
|
939
|
-
|
|
940
|
-
// response
|
|
941
|
-
expect(mockContext.response.status).toBe(200);
|
|
942
|
-
expect(mockContext.response.body).toEqual({ the: 'run response' });
|
|
943
|
-
});
|
|
944
|
-
|
|
945
|
-
test('mojaloop error propagation for /authorizations/{ID}', async() => {
|
|
946
|
-
|
|
947
|
-
// mock state machine
|
|
948
|
-
const mockedPSM = {
|
|
949
|
-
run: jest.fn(async () => { throw { mocked: 'error' }; })
|
|
950
|
-
};
|
|
951
|
-
|
|
952
|
-
const createSpy = jest.spyOn(AuthorizationsModel, 'create')
|
|
953
|
-
.mockImplementationOnce(async () => mockedPSM);
|
|
954
|
-
|
|
955
|
-
// invoke handler
|
|
956
|
-
await handlers['/authorizations'].post(mockContext);
|
|
957
|
-
|
|
958
|
-
// PSM model creation
|
|
959
|
-
const state = mockContext.state;
|
|
960
|
-
const cacheKey = AuthorizationsModel.channelName({
|
|
961
|
-
transactionRequestId: mockContext.request.body.authorizationsPostRequest.transactionRequestId
|
|
962
|
-
});
|
|
963
|
-
const expectedConfig = {
|
|
964
|
-
cache: state.cache,
|
|
965
|
-
logger: state.logger,
|
|
966
|
-
wso2Auth: state.wso2Auth
|
|
967
|
-
};
|
|
968
|
-
expect(createSpy).toBeCalledWith({}, cacheKey, expectedConfig);
|
|
969
|
-
|
|
970
|
-
// run workflow
|
|
971
|
-
expect(mockedPSM.run).toBeCalledWith({
|
|
972
|
-
transactionRequestId: mockContext.request.body.authorizationsPostRequest.transactionRequestId,
|
|
973
|
-
fspId: mockContext.request.body.fspId,
|
|
974
|
-
authorization: mockContext.request.body.authorizationsPostRequest
|
|
975
|
-
});
|
|
976
|
-
|
|
977
|
-
// response
|
|
978
|
-
expect(mockContext.response.status).toBe(500);
|
|
979
|
-
expect(mockContext.response.body).toEqual({
|
|
980
|
-
message: 'Unspecified error',
|
|
981
|
-
requestAuthorizationsInformationState: {},
|
|
982
|
-
statusCode: '500',
|
|
983
|
-
});
|
|
984
|
-
});
|
|
985
|
-
});
|
|
986
887
|
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
title: AuthorizationsPostRequest
|
|
2
|
-
description: POST /authorizations Request object
|
|
3
|
-
type: object
|
|
4
|
-
properties:
|
|
5
|
-
fspId:
|
|
6
|
-
title: destination DFSP
|
|
7
|
-
$ref: >-
|
|
8
|
-
../../../../node_modules/@mojaloop/api-snippets/fspiop/v1_1/openapi3/components/schemas/FspId.yaml
|
|
9
|
-
authorizationsPostRequest:
|
|
10
|
-
$ref: >-
|
|
11
|
-
../../../../node_modules/@mojaloop/api-snippets/thirdparty/openapi3/components/schemas/AuthorizationsPostRequest.yaml
|
|
12
|
-
required:
|
|
13
|
-
- fspId
|
|
14
|
-
- authorizationsPostRequest
|
|
15
|
-
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
title: AuthorizationsPostResponse
|
|
2
|
-
description: POST /authorizations response object
|
|
3
|
-
type: object
|
|
4
|
-
properties:
|
|
5
|
-
authorizations:
|
|
6
|
-
type: object
|
|
7
|
-
properties:
|
|
8
|
-
authenticationInfo:
|
|
9
|
-
$ref: '../../../../node_modules/@mojaloop/api-snippets/thirdparty/openapi3/components/schemas/AuthenticationInfo.yaml'
|
|
10
|
-
responseType:
|
|
11
|
-
$ref: '../../../../node_modules/@mojaloop/api-snippets/thirdparty/openapi3/components/schemas/AuthorizationResponseType.yaml'
|
|
12
|
-
required:
|
|
13
|
-
- responseType
|
|
14
|
-
currentState:
|
|
15
|
-
$ref: ../schemas/async2SyncCurrentState.yaml
|
|
16
|
-
required:
|
|
17
|
-
- authorizations
|
|
18
|
-
- currentState
|
|
19
|
-
additionalProperties: false
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
post:
|
|
2
|
-
description: The HTTP request `POST /authorizations` is used to request the Payer to enter the applicable credentials in the PISP system.
|
|
3
|
-
summary: Authorizations endpoint
|
|
4
|
-
operationId: AuthorizationsPost
|
|
5
|
-
tags:
|
|
6
|
-
- authorizations
|
|
7
|
-
requestBody:
|
|
8
|
-
description: Perform authorization
|
|
9
|
-
required: true
|
|
10
|
-
content:
|
|
11
|
-
application/json:
|
|
12
|
-
schema:
|
|
13
|
-
$ref: '../components/schemas/authorizationsPostRequest.yaml'
|
|
14
|
-
responses:
|
|
15
|
-
200:
|
|
16
|
-
$ref: '../components/responses/authorizationPostSuccess.yaml'
|
|
17
|
-
500:
|
|
18
|
-
$ref: '../components/responses/authorizationsServerError.yaml'
|
|
19
|
-
|