@mojaloop/sdk-scheme-adapter 11.18.6 → 11.18.11

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.
Files changed (30) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/InboundServer/api.yaml +2 -0
  3. package/InboundServer/handlers.js +0 -38
  4. package/InboundServer/middlewares.js +1 -1
  5. package/OutboundServer/api.yaml +23 -270
  6. package/OutboundServer/api_interfaces/openapi.d.ts +10 -127
  7. package/OutboundServer/api_template/openapi.yaml +0 -3
  8. package/OutboundServer/handlers.js +2 -40
  9. package/audit-resolve.json +174 -6
  10. package/lib/cache.js +23 -7
  11. package/lib/model/OutboundBulkQuotesModel.js +1 -0
  12. package/lib/model/OutboundBulkTransfersModel.js +1 -0
  13. package/lib/model/OutboundTransfersModel.js +1 -0
  14. package/lib/model/index.js +1 -3
  15. package/package.json +15 -15
  16. package/test/__mocks__/@mojaloop/sdk-standard-components.js +0 -2
  17. package/test/config/integration.env +0 -3
  18. package/test/unit/inboundApi/handlers.test.js +0 -46
  19. package/test/unit/outboundApi/handlers.test.js +1 -100
  20. package/OutboundServer/api_template/components/responses/authorizationPostSuccess.yaml +0 -5
  21. package/OutboundServer/api_template/components/responses/authorizationsServerError.yaml +0 -5
  22. package/OutboundServer/api_template/components/schemas/authorizationsPostRequest.yaml +0 -15
  23. package/OutboundServer/api_template/components/schemas/authorizationsPostResponse.yaml +0 -19
  24. package/OutboundServer/api_template/components/schemas/errorAuthorizationsResponse.yaml +0 -3
  25. package/OutboundServer/api_template/paths/authorizations.yaml +0 -19
  26. package/lib/model/AuthorizationsModel.js +0 -86
  27. package/test/integration/lib/Outbound/authorizations.test.js +0 -58
  28. package/test/integration/lib/Outbound/data/authorizationsPostRequest.json +0 -43
  29. package/test/unit/lib/model/AuthorizationsModel.test.js +0 -460
  30. 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
  };
@@ -30,22 +30,190 @@
30
30
  },
31
31
  "1500|@mojaloop/central-services-shared>widdershins>yargs>yargs-parser": {
32
32
  "decision": "ignore",
33
- "madeAt": 1628050789059,
34
- "expiresAt": 1630642771229
33
+ "madeAt": 1631785234887,
34
+ "expiresAt": 1632390016480
35
35
  },
36
36
  "1675|@mojaloop/central-services-shared>shins>sanitize-html": {
37
37
  "decision": "ignore",
38
- "madeAt": 1628050800637,
39
- "expiresAt": 1630642771229
38
+ "madeAt": 1631785236962,
39
+ "expiresAt": 1632390016480
40
40
  },
41
41
  "1676|@mojaloop/central-services-shared>shins>sanitize-html": {
42
42
  "decision": "ignore",
43
- "madeAt": 1628050800637,
44
- "expiresAt": 1630642771229
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
141
+ },
142
+ "1004946|@mojaloop/event-sdk>@grpc/proto-loader>yargs>string-width>strip-ansi>ansi-regex": {
143
+ "decision": "postpone",
144
+ "madeAt": 1637774978679
145
+ },
146
+ "1004946|@mojaloop/central-services-shared>widdershins>oas-resolver>yargs>string-width>strip-ansi>ansi-regex": {
147
+ "decision": "postpone",
148
+ "madeAt": 1637774978679
149
+ },
150
+ "1004946|@mojaloop/central-services-shared>widdershins>oas-resolver>yargs>cliui>string-width>strip-ansi>ansi-regex": {
151
+ "decision": "postpone",
152
+ "madeAt": 1637774978679
153
+ },
154
+ "1004946|@mojaloop/central-services-shared>widdershins>swagger2openapi>oas-resolver>yargs>cliui>string-width>strip-ansi>ansi-regex": {
155
+ "decision": "postpone",
156
+ "madeAt": 1637774978679
157
+ },
158
+ "1004946|@mojaloop/central-services-shared>widdershins>swagger2openapi>oas-validator>oas-resolver>yargs>cliui>string-width>strip-ansi>ansi-regex": {
159
+ "decision": "postpone",
160
+ "madeAt": 1637774978679
161
+ },
162
+ "1004946|@mojaloop/central-services-shared>widdershins>swagger2openapi>oas-validator>oas-resolver>yargs>cliui>wrap-ansi>string-width>strip-ansi>ansi-regex": {
163
+ "decision": "postpone",
164
+ "madeAt": 1637774978679
165
+ },
166
+ "1004946|@mojaloop/event-sdk>@grpc/proto-loader>yargs>cliui>wrap-ansi>strip-ansi>ansi-regex": {
167
+ "decision": "postpone",
168
+ "madeAt": 1637774978679
169
+ },
170
+ "1004946|@mojaloop/central-services-shared>widdershins>oas-resolver>yargs>cliui>wrap-ansi>strip-ansi>ansi-regex": {
171
+ "decision": "postpone",
172
+ "madeAt": 1637774978679
173
+ },
174
+ "1004946|@mojaloop/central-services-shared>widdershins>swagger2openapi>oas-resolver>yargs>cliui>wrap-ansi>strip-ansi>ansi-regex": {
175
+ "decision": "postpone",
176
+ "madeAt": 1637774978679
177
+ },
178
+ "1004946|@mojaloop/central-services-shared>widdershins>swagger2openapi>oas-validator>oas-resolver>yargs>cliui>wrap-ansi>strip-ansi>ansi-regex": {
179
+ "decision": "postpone",
180
+ "madeAt": 1637774978679
181
+ },
182
+ "1004946|@mojaloop/event-sdk>@grpc/proto-loader>yargs>cliui>strip-ansi>ansi-regex": {
183
+ "decision": "postpone",
184
+ "madeAt": 1637774978679
185
+ },
186
+ "1004854|@mojaloop/central-services-shared>widdershins>openapi-sampler>json-pointer": {
187
+ "decision": "postpone",
188
+ "madeAt": 1637774979253
189
+ },
190
+ "1004869|@mojaloop/central-services-shared>widdershins>swagger2openapi>better-ajv-errors>jsonpointer": {
191
+ "decision": "postpone",
192
+ "madeAt": 1637774979672
193
+ },
194
+ "1004869|@mojaloop/central-services-shared>widdershins>swagger2openapi>oas-validator>better-ajv-errors>jsonpointer": {
195
+ "decision": "postpone",
196
+ "madeAt": 1637774979672
197
+ },
198
+ "1004946|@mojaloop/central-services-shared>widdershins>yargs>string-width>strip-ansi>ansi-regex": {
199
+ "decision": "postpone",
200
+ "madeAt": 1637774980265
201
+ },
202
+ "1004946|@mojaloop/central-services-shared>widdershins>yargs>cliui>string-width>strip-ansi>ansi-regex": {
203
+ "decision": "postpone",
204
+ "madeAt": 1637774980265
205
+ },
206
+ "1005383|@mojaloop/central-services-shared>shins>sanitize-html": {
207
+ "decision": "postpone",
208
+ "madeAt": 1637774980738
209
+ },
210
+ "1005384|@mojaloop/central-services-shared>shins>sanitize-html": {
211
+ "decision": "postpone",
212
+ "madeAt": 1637774980738
213
+ },
214
+ "1005534|@mojaloop/central-services-shared>widdershins>yargs>yargs-parser": {
215
+ "decision": "postpone",
216
+ "madeAt": 1637774981266
49
217
  }
50
218
  },
51
219
  "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('Configuring Redis to emit keyevent events');
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('Error from REDIS client getting subscriber');
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(`Connected to REDIS at: ${this._config.host}:${this._config.port}`);
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
 
@@ -44,6 +44,7 @@ class OutboundBulkQuotesModel {
44
44
  jwsSign: config.jwsSign,
45
45
  jwsSigningKey: config.jwsSigningKey,
46
46
  wso2: config.wso2,
47
+ resourceVersions: config.resourceVersions,
47
48
  });
48
49
  }
49
50
 
@@ -43,6 +43,7 @@ class OutboundBulkTransfersModel {
43
43
  jwsSignPutParties: config.jwsSignPutParties,
44
44
  jwsSigningKey: config.jwsSigningKey,
45
45
  wso2: config.wso2,
46
+ resourceVersions: config.resourceVersions,
46
47
  });
47
48
  }
48
49
 
@@ -56,6 +56,7 @@ class OutboundTransfersModel {
56
56
  jwsSignPutParties: config.jwsSignPutParties,
57
57
  jwsSigningKey: config.jwsSigningKey,
58
58
  wso2: config.wso2,
59
+ resourceVersions: config.resourceVersions,
59
60
  });
60
61
 
61
62
  this._ilp = new Ilp({
@@ -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.6",
3
+ "version": "11.18.11",
4
4
  "description": "An adapter for connecting to Mojaloop API enabled switches.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -55,12 +55,12 @@
55
55
  "@mojaloop/central-services-health": "13.0.0",
56
56
  "@mojaloop/central-services-logger": "10.6.1",
57
57
  "@mojaloop/central-services-metrics": "11.0.0",
58
- "@mojaloop/central-services-shared": "13.4.1",
58
+ "@mojaloop/central-services-shared": "14.0.0",
59
59
  "@mojaloop/event-sdk": "10.7.1",
60
- "@mojaloop/sdk-standard-components": "15.12.0",
61
- "ajv": "8.6.2",
60
+ "@mojaloop/sdk-standard-components": "15.13.0",
61
+ "ajv": "8.6.3",
62
62
  "ajv-keywords": "5.0.0",
63
- "axios": "^0.21.1",
63
+ "axios": "^0.21.4",
64
64
  "co-body": "^6.1.0",
65
65
  "dotenv": "^10.0.0",
66
66
  "env-var": "^7.0.1",
@@ -70,29 +70,29 @@
70
70
  "koa": "^2.13.1",
71
71
  "koa-body": "^4.2.0",
72
72
  "koa2-oauth-server": "^1.0.0",
73
- "openapi-jsonschema-parameters": "^9.2.0",
73
+ "openapi-jsonschema-parameters": "^9.3.0",
74
74
  "promise-timeout": "^1.3.0",
75
75
  "redis": "^3.1.2",
76
76
  "uuidv4": "^6.2.12",
77
- "ws": "^7.5.3"
77
+ "ws": "^7.5.5"
78
78
  },
79
79
  "devDependencies": {
80
- "@babel/core": "^7.15.0",
81
- "@babel/preset-env": "^7.15.0",
82
- "@mojaloop/api-snippets": "^12.6.6",
83
- "@redocly/openapi-cli": "^1.0.0-beta.55",
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
84
  "@types/jest": "^27.0.1",
85
- "babel-jest": "^27.0.6",
85
+ "babel-jest": "^27.2.0",
86
86
  "eslint": "^7.32.0",
87
87
  "eslint-config-airbnb-base": "^14.2.1",
88
88
  "eslint-plugin-import": "^2.24.2",
89
89
  "eslint-plugin-jest": "^24.4.0",
90
- "jest": "^27.0.6",
90
+ "jest": "^27.2.0",
91
91
  "jest-junit": "^12.2.0",
92
92
  "nock": "^13.1.3",
93
93
  "npm-audit-resolver": "^2.3.1",
94
- "npm-check-updates": "^11.8.3",
95
- "openapi-response-validator": "^9.2.0",
94
+ "npm-check-updates": "^11.8.5",
95
+ "openapi-response-validator": "^9.3.0",
96
96
  "openapi-typescript": "^4.0.2",
97
97
  "redis-mock": "^0.56.3",
98
98
  "standard-version": "^9.3.1",
@@ -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,5 +0,0 @@
1
- description: Sync response from POST /authorizations
2
- content:
3
- application/json:
4
- schema:
5
- $ref: ../schemas/authorizationsPostResponse.yaml
@@ -1,5 +0,0 @@
1
- description: An error occurred processing the authorizations request
2
- content:
3
- application/json:
4
- schema:
5
- $ref: ../schemas/errorAuthorizationsResponse.yaml
@@ -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
-