@mojaloop/sdk-scheme-adapter 12.2.2 → 13.0.0
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/.env.example +3 -0
- package/CHANGELOG.md +26 -0
- package/audit-resolve.json +71 -1
- package/docker/ml-testing-toolkit/spec_files/api_definitions/fspiop_1.1/trigger_templates/transaction_request_followup.json +2 -2
- package/docker/ml-testing-toolkit/spec_files/rules_callback/default.json +7 -7
- package/docker/ml-testing-toolkit/spec_files/rules_response/default.json +16 -16
- package/docker/ml-testing-toolkit/spec_files/rules_response/default_pisp_rules.json +5 -5
- package/docker/ml-testing-toolkit/spec_files/rules_validation/default.json +10 -10
- package/package.json +4 -1
- package/src/ControlAgent/index.js +2 -3
- package/src/ControlServer/index.js +2 -2
- package/src/InboundServer/handlers.js +114 -52
- package/src/InboundServer/index.js +7 -7
- package/src/InboundServer/middlewares.js +2 -2
- package/src/OutboundServer/api.yaml +54 -3
- package/src/OutboundServer/api_interfaces/openapi.d.ts +24 -3
- package/src/OutboundServer/api_template/components/schemas/accountsResponse.yaml +9 -0
- package/src/OutboundServer/api_template/components/schemas/transferRequest.yaml +3 -0
- package/src/OutboundServer/api_template/components/schemas/transferResponse.yaml +28 -2
- package/src/OutboundServer/api_template/components/schemas/transferStatusResponse.yaml +8 -1
- package/src/OutboundServer/handlers.js +4 -1
- package/src/OutboundServer/index.js +10 -11
- package/src/config.js +29 -12
- package/src/index.js +198 -10
- package/src/lib/cache.js +110 -52
- package/src/lib/metrics.js +148 -0
- package/src/lib/model/AccountsModel.js +17 -12
- package/src/lib/model/Async2SyncModel.js +4 -1
- package/src/lib/model/InboundTransfersModel.js +170 -25
- package/src/lib/model/OutboundBulkQuotesModel.js +4 -1
- package/src/lib/model/OutboundBulkTransfersModel.js +4 -1
- package/src/lib/model/OutboundRequestToPayModel.js +9 -7
- package/src/lib/model/OutboundRequestToPayTransferModel.js +6 -3
- package/src/lib/model/OutboundTransfersModel.js +318 -53
- package/src/lib/model/PartiesModel.js +1 -1
- package/src/lib/model/ProxyModel/index.js +4 -2
- package/src/lib/model/common/BackendError.js +28 -4
- package/src/lib/model/common/index.js +2 -1
- package/src/lib/validate.js +2 -2
- package/test/__mocks__/@mojaloop/sdk-standard-components.js +3 -2
- package/test/__mocks__/redis.js +4 -0
- package/test/config/integration.env +5 -0
- package/test/integration/lib/Outbound/parties.test.js +1 -1
- package/test/unit/ControlServer/index.js +3 -3
- package/test/unit/InboundServer.test.js +10 -10
- package/test/unit/TestServer.test.js +11 -13
- package/test/unit/api/accounts/data/postAccountsErrorMojaloopResponse.json +11 -3
- package/test/unit/api/accounts/data/postAccountsSuccessResponse.json +14 -0
- package/test/unit/api/accounts/data/postAccountsSuccessResponseWithError1.json +13 -0
- package/test/unit/api/accounts/data/postAccountsSuccessResponseWithError2.json +18 -0
- package/test/unit/api/accounts/utils.js +15 -1
- package/test/unit/api/transfers/data/getTransfersCommittedResponse.json +18 -15
- package/test/unit/api/transfers/data/getTransfersErrorNotFound.json +1 -0
- package/test/unit/api/transfers/data/postTransfersErrorMojaloopResponse.json +9 -0
- package/test/unit/api/transfers/data/postTransfersErrorTimeoutResponse.json +1 -0
- package/test/unit/api/transfers/data/postTransfersSuccessResponse.json +74 -47
- package/test/unit/api/transfers/utils.js +85 -4
- package/test/unit/api/utils.js +4 -1
- package/test/unit/config.test.js +2 -2
- package/test/unit/data/commonHttpHeaders.json +1 -0
- package/test/unit/data/defaultConfig.json +23 -7
- package/test/unit/inboundApi/handlers.test.js +45 -14
- package/test/unit/index.test.js +95 -4
- package/test/unit/lib/model/AccountsModel.test.js +9 -6
- package/test/unit/lib/model/InboundTransfersModel.test.js +210 -30
- package/test/unit/lib/model/OutboundRequestToPayModel.test.js +1 -1
- package/test/unit/lib/model/OutboundRequestToPayTransferModel.test.js +3 -3
- package/test/unit/lib/model/OutboundTransfersModel.test.js +863 -158
- package/test/unit/lib/model/data/defaultConfig.json +25 -10
- package/test/unit/lib/model/data/mockArguments.json +97 -40
- package/test/unit/lib/model/data/payeeParty.json +13 -11
- package/test/unit/lib/model/data/quoteResponse.json +36 -25
- package/test/unit/lib/model/data/transferFulfil.json +5 -3
- package/src/lib/api/index.js +0 -12
- package/src/lib/randomphrase/index.js +0 -21
- package/src/lib/randomphrase/words.json +0 -3397
|
@@ -10,6 +10,17 @@
|
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
+
const TransferStateEnum = {
|
|
14
|
+
'WAITING_FOR_PARTY_ACCEPTANCE': 'WAITING_FOR_PARTY_ACCEPTANCE',
|
|
15
|
+
'QUOTE_REQUEST_RECEIVED': 'QUOTE_REQUEST_RECEIVED',
|
|
16
|
+
'WAITING_FOR_QUOTE_ACCEPTANCE': 'WAITING_FOR_QUOTE_ACCEPTANCE',
|
|
17
|
+
'PREPARE_RECEIVED': 'PREPARE_RECEIVED',
|
|
18
|
+
'ERROR_OCCURRED': 'ERROR_OCCURRED',
|
|
19
|
+
'COMPLETED': 'COMPLETED',
|
|
20
|
+
'ABORTED': 'ABORTED',
|
|
21
|
+
'RESERVED': 'RESERVED',
|
|
22
|
+
};
|
|
23
|
+
|
|
13
24
|
class BackendError extends Error {
|
|
14
25
|
constructor(msg, httpStatusCode) {
|
|
15
26
|
super(msg);
|
|
@@ -17,10 +28,23 @@ class BackendError extends Error {
|
|
|
17
28
|
}
|
|
18
29
|
|
|
19
30
|
toJSON() {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
31
|
+
const ret = {
|
|
32
|
+
httpStatusCode: this.httpStatusCode
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// copy across any other properties
|
|
36
|
+
for(let prop in this) {
|
|
37
|
+
if(this.hasOwnProperty(prop)) {
|
|
38
|
+
ret[prop] = this[prop];
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return ret;
|
|
23
43
|
}
|
|
24
44
|
}
|
|
25
45
|
|
|
26
|
-
|
|
46
|
+
|
|
47
|
+
module.exports = {
|
|
48
|
+
BackendError,
|
|
49
|
+
TransferStateEnum,
|
|
50
|
+
};
|
|
@@ -9,10 +9,11 @@
|
|
|
9
9
|
**************************************************************************/
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
|
-
const BackendError = require('./BackendError');
|
|
12
|
+
const { BackendError, TransferStateEnum } = require('./BackendError');
|
|
13
13
|
const PersistentStateMachine = require('./PersistentStateMachine');
|
|
14
14
|
|
|
15
15
|
module.exports = {
|
|
16
16
|
BackendError,
|
|
17
|
+
TransferStateEnum,
|
|
17
18
|
PersistentStateMachine
|
|
18
19
|
};
|
package/src/lib/validate.js
CHANGED
|
@@ -24,7 +24,7 @@ const { Errors } = require('@mojaloop/sdk-standard-components');
|
|
|
24
24
|
const Ajv = require('ajv');
|
|
25
25
|
const ajv = new Ajv({ allErrors: true, coerceTypes: true, strict: false });
|
|
26
26
|
|
|
27
|
-
const httpMethods = ['get', 'head', 'post', 'put', 'delete', '
|
|
27
|
+
const httpMethods = ['get', 'head', 'post', 'put', 'delete', 'connect', 'options', 'trace', 'patch'];
|
|
28
28
|
|
|
29
29
|
// Create a json schema in the format we've chosen to use
|
|
30
30
|
const createSchema = (pathValue, methodValue) => {
|
|
@@ -186,7 +186,7 @@ class Validator {
|
|
|
186
186
|
|
|
187
187
|
if(firstError.keyword === 'required') {
|
|
188
188
|
// this is a missing required property; there is a specific mojaloop api spec error code for this
|
|
189
|
-
err = new Errors.MojaloopFSPIOPError(firstError, util.format('Request failed validation',
|
|
189
|
+
err = new Errors.MojaloopFSPIOPError(firstError, util.format('Request failed validation',
|
|
190
190
|
validationResult), null, Errors.MojaloopApiErrorCodes.MISSING_ELEMENT);
|
|
191
191
|
|
|
192
192
|
// overwrite the defaul error message with something more useful
|
|
@@ -40,6 +40,7 @@ class MockMojaloopRequests extends MojaloopRequests {
|
|
|
40
40
|
this.postBulkTransfers = MockMojaloopRequests.__postBulkTransfers;
|
|
41
41
|
this.putBulkTransfers = MockMojaloopRequests.__putBulkTransfers;
|
|
42
42
|
this.putBulkTransfersError = MockMojaloopRequests.__putBulkTransfersError;
|
|
43
|
+
this.patchTransfers = MockMojaloopRequests.__patchTransfers;
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
MockMojaloopRequests.__postParticipants = jest.fn(() => Promise.resolve());
|
|
@@ -63,7 +64,7 @@ MockMojaloopRequests.__getBulkTransfers = jest.fn(() => Promise.resolve());
|
|
|
63
64
|
MockMojaloopRequests.__postBulkTransfers = jest.fn(() => Promise.resolve());
|
|
64
65
|
MockMojaloopRequests.__putBulkTransfers = jest.fn(() => Promise.resolve());
|
|
65
66
|
MockMojaloopRequests.__putBulkTransfersError = jest.fn(() => Promise.resolve());
|
|
66
|
-
|
|
67
|
+
MockMojaloopRequests.__patchTransfers = jest.fn(() => Promise.resolve());
|
|
67
68
|
|
|
68
69
|
class MockIlp {
|
|
69
70
|
constructor(config) {
|
|
@@ -146,5 +147,5 @@ module.exports = {
|
|
|
146
147
|
},
|
|
147
148
|
Errors,
|
|
148
149
|
WSO2Auth,
|
|
149
|
-
Logger
|
|
150
|
+
Logger,
|
|
150
151
|
};
|
package/test/__mocks__/redis.js
CHANGED
|
@@ -132,6 +132,11 @@ TRANSFERS_ENDPOINT=ml-testing-toolkit:5000
|
|
|
132
132
|
# The fulfilment will be generated from the provided ILP packet, and must hash to the provided condition.
|
|
133
133
|
ALLOW_TRANSFER_WITHOUT_QUOTE=false
|
|
134
134
|
|
|
135
|
+
# To enable request for notification on fulfiled transfer
|
|
136
|
+
RESERVE_NOTIFICATION=true
|
|
137
|
+
# resources API versions should be string in format: "resourceOneName=1.0,resourceTwoName=1.1"
|
|
138
|
+
RESOURCE_VERSIONS="transfers=1.1,participants=1.1"
|
|
139
|
+
|
|
135
140
|
# Management API websocket connection settings.
|
|
136
141
|
# The Management API uses this for exchanging connector management messages.
|
|
137
142
|
MGMT_API_WS_URL=127.0.0.1
|
|
@@ -13,7 +13,7 @@ describe('/parties', () => {
|
|
|
13
13
|
|
|
14
14
|
expect(res.status).toEqual(200);
|
|
15
15
|
expect(res.data.currentState).toEqual('COMPLETED');
|
|
16
|
-
expect(typeof res.data.party).toEqual('object');
|
|
16
|
+
expect(typeof res.data.body.party).toEqual('object');
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
test('get - timeout', (done) => {
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
const ws = require('ws');
|
|
13
13
|
const jsonPatch = require('fast-json-patch');
|
|
14
|
-
const
|
|
14
|
+
const { generateSlug } = require('random-word-slugs');
|
|
15
15
|
const { getInternalEventEmitter, INTERNAL_EVENTS } = require('./events');
|
|
16
16
|
|
|
17
17
|
const ControlServerEventEmitter = getInternalEventEmitter();
|
|
@@ -58,7 +58,7 @@ const deserialise = (msg) => {
|
|
|
58
58
|
};
|
|
59
59
|
|
|
60
60
|
|
|
61
|
-
const buildMsg = (verb, msg, data, id =
|
|
61
|
+
const buildMsg = (verb, msg, data, id = generateSlug(4)) => serialise({
|
|
62
62
|
verb,
|
|
63
63
|
msg,
|
|
64
64
|
data,
|
|
@@ -197,7 +197,7 @@ class Server extends ws.Server {
|
|
|
197
197
|
* @param {object} params Updated configuration
|
|
198
198
|
*/
|
|
199
199
|
async broadcastConfigChange(updatedConfig) {
|
|
200
|
-
const updateConfMsg = build.CONFIGURATION.PATCH({}, updatedConfig,
|
|
200
|
+
const updateConfMsg = build.CONFIGURATION.PATCH({}, updatedConfig, generateSlug(4));
|
|
201
201
|
const errorLogger = (socket, message) => (err) =>
|
|
202
202
|
this._logger
|
|
203
203
|
.push({ message, ip: this._clientData.get(socket).ip, err })
|
|
@@ -51,7 +51,7 @@ describe('Inbound Server', () => {
|
|
|
51
51
|
await supertest(svr._server)
|
|
52
52
|
.put('/parties/MSISDN/123456789')
|
|
53
53
|
.send(putPartiesBody)
|
|
54
|
-
.set('content-type', 'application/vnd.interoperability.parties+json;version=1.
|
|
54
|
+
.set('content-type', 'application/vnd.interoperability.parties+json;version=1.1')
|
|
55
55
|
.set('fspiop-http-method', 'PUT')
|
|
56
56
|
.set('fspiop-uri', '/parties/MSISDN/123456789')
|
|
57
57
|
.set('date', new Date().toISOString());
|
|
@@ -93,7 +93,7 @@ describe('Inbound Server', () => {
|
|
|
93
93
|
testPartiesJwsValidation(false, true, 0));
|
|
94
94
|
|
|
95
95
|
test('processes parties request with valid content-type headers successfully', async () => {
|
|
96
|
-
await testPartiesHeaderValidation('application/vnd.interoperability.parties+json;version=1.
|
|
96
|
+
await testPartiesHeaderValidation('application/vnd.interoperability.parties+json;version=1.1', 200);
|
|
97
97
|
});
|
|
98
98
|
|
|
99
99
|
test('returns error on invalid parties content-type headers', async () => {
|
|
@@ -108,7 +108,7 @@ describe('Inbound Server', () => {
|
|
|
108
108
|
}
|
|
109
109
|
);
|
|
110
110
|
await testPartiesHeaderValidation(
|
|
111
|
-
'application/vnd.interoperability.test+json;version=1.
|
|
111
|
+
'application/vnd.interoperability.test+json;version=1.1',
|
|
112
112
|
400,
|
|
113
113
|
{
|
|
114
114
|
'errorInformation': {
|
|
@@ -148,7 +148,7 @@ describe('Inbound Server', () => {
|
|
|
148
148
|
.post('/quotes')
|
|
149
149
|
.send(postQuotesBody)
|
|
150
150
|
.set(commonHttpHeaders)
|
|
151
|
-
.set('content-type', 'application/vnd.interoperability.quotes+json;version=1.
|
|
151
|
+
.set('content-type', 'application/vnd.interoperability.quotes+json;version=1.1')
|
|
152
152
|
.set('fspiop-http-method', 'POST')
|
|
153
153
|
.set('fspiop-uri', '/quotes')
|
|
154
154
|
.set('date', new Date().toISOString());
|
|
@@ -183,7 +183,7 @@ describe('Inbound Server', () => {
|
|
|
183
183
|
testQuotesJwsValidation(true, true, 1));
|
|
184
184
|
|
|
185
185
|
test('processes quotes request with valid content-type headers successfully', async () => {
|
|
186
|
-
await testQuotesHeaderValidation('application/vnd.interoperability.quotes+json;version=1.
|
|
186
|
+
await testQuotesHeaderValidation('application/vnd.interoperability.quotes+json;version=1.1', 202);
|
|
187
187
|
});
|
|
188
188
|
|
|
189
189
|
test('returns error on invalid quotes content-type headers', async () => {
|
|
@@ -198,7 +198,7 @@ describe('Inbound Server', () => {
|
|
|
198
198
|
}
|
|
199
199
|
);
|
|
200
200
|
await testQuotesHeaderValidation(
|
|
201
|
-
'application/vnd.interoperability.parties+json;version=1.
|
|
201
|
+
'application/vnd.interoperability.parties+json;version=1.1',
|
|
202
202
|
400,
|
|
203
203
|
{
|
|
204
204
|
'errorInformation': {
|
|
@@ -239,7 +239,7 @@ describe('Inbound Server', () => {
|
|
|
239
239
|
.put('/participants/00000000-0000-1000-a000-000000000002')
|
|
240
240
|
.send(putParticipantsBody)
|
|
241
241
|
.set(commonHttpHeaders)
|
|
242
|
-
.set('content-type', 'application/vnd.interoperability.participants+json;version=1.
|
|
242
|
+
.set('content-type', 'application/vnd.interoperability.participants+json;version=1.1')
|
|
243
243
|
.set('fspiop-http-method', 'PUT')
|
|
244
244
|
.set('fspiop-uri', '/participants/00000000-0000-1000-a000-000000000002')
|
|
245
245
|
.set('date', new Date().toISOString());
|
|
@@ -274,7 +274,7 @@ describe('Inbound Server', () => {
|
|
|
274
274
|
testParticipantsJwsValidation(false, false, 0));
|
|
275
275
|
|
|
276
276
|
test('processes participants request with valid content-type headers successfully', async () => {
|
|
277
|
-
await testParticipantsHeaderValidation('application/vnd.interoperability.participants+json;version=1.
|
|
277
|
+
await testParticipantsHeaderValidation('application/vnd.interoperability.participants+json;version=1.1', 200);
|
|
278
278
|
});
|
|
279
279
|
|
|
280
280
|
test('returns error on invalid participants content-type headers', async () => {
|
|
@@ -289,7 +289,7 @@ describe('Inbound Server', () => {
|
|
|
289
289
|
}
|
|
290
290
|
);
|
|
291
291
|
await testParticipantsHeaderValidation(
|
|
292
|
-
'application/vnd.interoperability.parties+json;version=1.
|
|
292
|
+
'application/vnd.interoperability.parties+json;version=1.1',
|
|
293
293
|
400,
|
|
294
294
|
{
|
|
295
295
|
'errorInformation': {
|
|
@@ -334,7 +334,7 @@ describe('Inbound Server', () => {
|
|
|
334
334
|
});
|
|
335
335
|
|
|
336
336
|
async function testTlsServer(enableTls) {
|
|
337
|
-
defConfig.mutualTLS.
|
|
337
|
+
defConfig.inbound.tls.mutualTLS.enabled = enableTls;
|
|
338
338
|
const logger = new Logger.Logger({ stringify: () => '' });
|
|
339
339
|
const cache = new Cache({ ...defConfig.cacheConfig, logger: logger.push({ component: 'cache' }) });
|
|
340
340
|
const server = new InboundServer(defConfig, logger, cache);
|
|
@@ -104,7 +104,7 @@ describe('Test Server', () => {
|
|
|
104
104
|
.put(`/parties/MSISDN/${MSISDN}`)
|
|
105
105
|
.send(putPartiesBody)
|
|
106
106
|
.set(commonHttpHeaders)
|
|
107
|
-
.set('content-type', 'application/vnd.interoperability.parties+json;version=1.
|
|
107
|
+
.set('content-type', 'application/vnd.interoperability.parties+json;version=1.1')
|
|
108
108
|
.set('fspiop-http-method', 'PUT')
|
|
109
109
|
.set('fspiop-uri', `/parties/MSISDN/${MSISDN}`)
|
|
110
110
|
.set('date', new Date().toISOString());
|
|
@@ -119,7 +119,7 @@ describe('Test Server', () => {
|
|
|
119
119
|
.post('/quotes')
|
|
120
120
|
.send(postQuotesBody)
|
|
121
121
|
.set(commonHttpHeaders)
|
|
122
|
-
.set('content-type', 'application/vnd.interoperability.quotes+json;version=1.
|
|
122
|
+
.set('content-type', 'application/vnd.interoperability.quotes+json;version=1.1')
|
|
123
123
|
.set('fspiop-http-method', 'POST')
|
|
124
124
|
.set('fspiop-uri', '/quotes')
|
|
125
125
|
.set('date', new Date().toISOString());
|
|
@@ -136,7 +136,7 @@ describe('Test Server', () => {
|
|
|
136
136
|
.put(`/participants/${participantId}`)
|
|
137
137
|
.send(putParticipantsBody)
|
|
138
138
|
.set(commonHttpHeaders)
|
|
139
|
-
.set('content-type', 'application/vnd.interoperability.participants+json;version=1.
|
|
139
|
+
.set('content-type', 'application/vnd.interoperability.participants+json;version=1.1')
|
|
140
140
|
.set('fspiop-http-method', 'PUT')
|
|
141
141
|
.set('fspiop-uri', `/participants/${participantId}`)
|
|
142
142
|
.set('date', new Date().toISOString());
|
|
@@ -159,7 +159,7 @@ describe('Test Server', () => {
|
|
|
159
159
|
|
|
160
160
|
const headers = {
|
|
161
161
|
...commonHttpHeaders,
|
|
162
|
-
'content-type': 'application/vnd.interoperability.participants+json;version=1.
|
|
162
|
+
'content-type': 'application/vnd.interoperability.participants+json;version=1.1',
|
|
163
163
|
'fspiop-http-method': 'PUT',
|
|
164
164
|
'fspiop-uri': `/participants/${participantId}`,
|
|
165
165
|
'date': new Date().toISOString(),
|
|
@@ -231,7 +231,7 @@ describe('Test Server', () => {
|
|
|
231
231
|
test('WebSocket /requests and / endpoint triggers send to client when callback received to inbound server', async () => {
|
|
232
232
|
const headers = {
|
|
233
233
|
...commonHttpHeaders,
|
|
234
|
-
'content-type': 'application/vnd.interoperability.quotes+json;version=1.
|
|
234
|
+
'content-type': 'application/vnd.interoperability.quotes+json;version=1.1',
|
|
235
235
|
'fspiop-http-method': 'POST',
|
|
236
236
|
'fspiop-uri': '/quotes',
|
|
237
237
|
'date': new Date().toISOString(),
|
|
@@ -270,8 +270,7 @@ describe('Test Server', () => {
|
|
|
270
270
|
.send(postQuotesBody)
|
|
271
271
|
.set(headers);
|
|
272
272
|
|
|
273
|
-
|
|
274
|
-
expect(inboundServer._api._cache.set).toHaveBeenCalledTimes(3);
|
|
273
|
+
expect(inboundServer._api._cache.set).toHaveBeenCalledTimes(4);
|
|
275
274
|
expect(inboundServer._api._cache.set).toHaveBeenCalledWith(
|
|
276
275
|
`${testServer._wsapi._cache.REQUEST_PREFIX}${postQuotesBody.quoteId}`,
|
|
277
276
|
{
|
|
@@ -304,7 +303,7 @@ describe('Test Server', () => {
|
|
|
304
303
|
test('Websocket / endpoint receives both callbacks and requests', async () => {
|
|
305
304
|
const quoteRequestHeaders = {
|
|
306
305
|
...commonHttpHeaders,
|
|
307
|
-
'content-type': 'application/vnd.interoperability.quotes+json;version=1.
|
|
306
|
+
'content-type': 'application/vnd.interoperability.quotes+json;version=1.1',
|
|
308
307
|
'fspiop-http-method': 'POST',
|
|
309
308
|
'fspiop-uri': '/quotes',
|
|
310
309
|
'date': new Date().toISOString(),
|
|
@@ -332,8 +331,7 @@ describe('Test Server', () => {
|
|
|
332
331
|
.send(postQuotesBody)
|
|
333
332
|
.set(quoteRequestHeaders);
|
|
334
333
|
|
|
335
|
-
|
|
336
|
-
expect(inboundServer._api._cache.set).toHaveBeenCalledTimes(3);
|
|
334
|
+
expect(inboundServer._api._cache.set).toHaveBeenCalledTimes(4);
|
|
337
335
|
expect(inboundServer._api._cache.set).toHaveBeenCalledWith(
|
|
338
336
|
`${testServer._wsapi._cache.REQUEST_PREFIX}${postQuotesBody.quoteId}`,
|
|
339
337
|
{
|
|
@@ -362,7 +360,7 @@ describe('Test Server', () => {
|
|
|
362
360
|
|
|
363
361
|
const putParticipantsHeaders = {
|
|
364
362
|
...commonHttpHeaders,
|
|
365
|
-
'content-type': 'application/vnd.interoperability.participants+json;version=1.
|
|
363
|
+
'content-type': 'application/vnd.interoperability.participants+json;version=1.1',
|
|
366
364
|
'fspiop-http-method': 'PUT',
|
|
367
365
|
'fspiop-uri': `/participants/${participantId}`,
|
|
368
366
|
'date': new Date().toISOString(),
|
|
@@ -375,8 +373,8 @@ describe('Test Server', () => {
|
|
|
375
373
|
|
|
376
374
|
// Called thrice for the quote request earlier in this test, another time now for the put
|
|
377
375
|
// participants request
|
|
378
|
-
expect(inboundServer._api._cache.set).toHaveBeenCalledTimes(
|
|
379
|
-
expect(inboundServer._api._cache.set.mock.calls[
|
|
376
|
+
expect(inboundServer._api._cache.set).toHaveBeenCalledTimes(5);
|
|
377
|
+
expect(inboundServer._api._cache.set.mock.calls[4]).toEqual([
|
|
380
378
|
`${testServer._wsapi._cache.CALLBACK_PREFIX}${participantId}`,
|
|
381
379
|
{
|
|
382
380
|
data: putParticipantsBody,
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
{
|
|
2
|
+
"message": "Got an error response creating accounts: {\n errorInformation: { errorCode: '3204', errorDescription: 'Party not found' }\n}",
|
|
3
|
+
"statusCode": "3204",
|
|
2
4
|
"executionState": {
|
|
5
|
+
"postAccountsResponse": {
|
|
6
|
+
"body": {
|
|
7
|
+
"errorInformation": {
|
|
8
|
+
"errorCode": "3204",
|
|
9
|
+
"errorDescription": "Party not found"
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
},
|
|
3
13
|
"accounts": [
|
|
4
14
|
{
|
|
5
15
|
"currency": "USD",
|
|
@@ -19,7 +29,5 @@
|
|
|
19
29
|
},
|
|
20
30
|
"modelId": "00000000-0000-1000-8000-000000000001",
|
|
21
31
|
"response": []
|
|
22
|
-
}
|
|
23
|
-
"message": "Got an error response creating accounts: {\n errorInformation: { errorCode: '3204', errorDescription: 'Party not found' }\n}",
|
|
24
|
-
"statusCode": "3204"
|
|
32
|
+
}
|
|
25
33
|
}
|
|
@@ -8,6 +8,20 @@
|
|
|
8
8
|
],
|
|
9
9
|
"currentState": "COMPLETED",
|
|
10
10
|
"modelId": "00000000-0000-1000-8000-000000000001",
|
|
11
|
+
"postAccountsResponse": {
|
|
12
|
+
"body": {
|
|
13
|
+
"currency": "USD",
|
|
14
|
+
"partyList": [
|
|
15
|
+
{
|
|
16
|
+
"partyId": {
|
|
17
|
+
"fspId": "mojaloop-sdk",
|
|
18
|
+
"partyIdType": "MSISDN",
|
|
19
|
+
"partyIdentifier": "123456789"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
},
|
|
11
25
|
"response": [
|
|
12
26
|
{
|
|
13
27
|
"idType": "MSISDN",
|
|
@@ -8,6 +8,19 @@
|
|
|
8
8
|
],
|
|
9
9
|
"currentState": "COMPLETED",
|
|
10
10
|
"modelId": "00000000-0000-1000-8000-000000000001",
|
|
11
|
+
"postAccountsResponse": {
|
|
12
|
+
"body": {
|
|
13
|
+
"partyList": [
|
|
14
|
+
{
|
|
15
|
+
"partyId": {
|
|
16
|
+
"fspId": "mojaloop-sdk",
|
|
17
|
+
"partyIdType": "MSISDN",
|
|
18
|
+
"partyIdentifier": "123456789"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
},
|
|
11
24
|
"response": [
|
|
12
25
|
{
|
|
13
26
|
"error": {
|
|
@@ -8,6 +8,24 @@
|
|
|
8
8
|
],
|
|
9
9
|
"currentState": "COMPLETED",
|
|
10
10
|
"modelId": "00000000-0000-1000-8000-000000000001",
|
|
11
|
+
"postAccountsResponse": {
|
|
12
|
+
"body": {
|
|
13
|
+
"currency": "USD",
|
|
14
|
+
"partyList": [
|
|
15
|
+
{
|
|
16
|
+
"errorInformation": {
|
|
17
|
+
"errorCode": "3204",
|
|
18
|
+
"errorDescription": "Party not found"
|
|
19
|
+
},
|
|
20
|
+
"partyId": {
|
|
21
|
+
"fspId": "mojaloop-sdk",
|
|
22
|
+
"partyIdType": "MSISDN",
|
|
23
|
+
"partyIdentifier": "123456789"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
},
|
|
11
29
|
"response": [
|
|
12
30
|
{
|
|
13
31
|
"error": {
|
|
@@ -36,7 +36,7 @@ function createPostAccountsTester({ reqInbound, reqOutbound, apiSpecsOutbound })
|
|
|
36
36
|
return reqInbound.put(putUrl)
|
|
37
37
|
.send(putBody)
|
|
38
38
|
.set('Date', new Date().toISOString())
|
|
39
|
-
.set('content-type', 'application/vnd.interoperability.participants+json;version=1.
|
|
39
|
+
.set('content-type', 'application/vnd.interoperability.participants+json;version=1.1')
|
|
40
40
|
.set('fspiop-source', 'mojaloop-sdk')
|
|
41
41
|
.expect(200);
|
|
42
42
|
};
|
|
@@ -50,6 +50,20 @@ function createPostAccountsTester({ reqInbound, reqOutbound, apiSpecsOutbound })
|
|
|
50
50
|
const res = await reqOutbound.post('/accounts').send(postAccountsBody);
|
|
51
51
|
const {body} = res;
|
|
52
52
|
expect(res.statusCode).toEqual(responseCode);
|
|
53
|
+
|
|
54
|
+
// remove elements of the response we do not want/need to compare for correctness.
|
|
55
|
+
// timestamps on requests/responses for example will be set by the HTTP framework
|
|
56
|
+
// and we dont want to compare against static values.
|
|
57
|
+
if (body.executionState) {
|
|
58
|
+
if(body.executionState.postAccountsResponse) {
|
|
59
|
+
delete body.executionState.postAccountsResponse.headers;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if(body.postAccountsResponse) {
|
|
64
|
+
delete body.postAccountsResponse.headers;
|
|
65
|
+
}
|
|
66
|
+
|
|
53
67
|
expect(body).toEqual(responseBody);
|
|
54
68
|
const responseValidator = new OpenAPIResponseValidator(apiSpecsOutbound.paths['/accounts'].post);
|
|
55
69
|
const err = responseValidator.validateResponse(responseCode, body);
|
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"currentState": "COMPLETED",
|
|
3
|
+
"direction": "OUTBOUND",
|
|
3
4
|
"fulfil": {
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
5
|
+
"body": {
|
|
6
|
+
"completedTimestamp": "2017-11-15T14:16:09.663+01:00",
|
|
7
|
+
"extensionList": {
|
|
8
|
+
"extension": [
|
|
9
|
+
{
|
|
10
|
+
"key": "treskey1",
|
|
11
|
+
"value": "tresvalue1"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"key": "treskey2",
|
|
15
|
+
"value": "tresvalue2"
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
},
|
|
19
|
+
"fulfilment": "87mm1reS3SAi8oIWXgBkLmgWc1MkZ_yLbFDX5XAdo5o",
|
|
20
|
+
"transferState": "COMMITTED"
|
|
21
|
+
}
|
|
19
22
|
},
|
|
20
23
|
"transferId": "00000000-0000-1000-8000-000000000001"
|
|
21
24
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
"message": "Got an error response resolving party: {\n errorInformation: { errorCode: '3204', errorDescription: 'Party not found' }\n}",
|
|
3
3
|
"statusCode": "3204",
|
|
4
4
|
"transferState": {
|
|
5
|
+
"direction": "OUTBOUND",
|
|
5
6
|
"amount": "100",
|
|
6
7
|
"amountType": "SEND",
|
|
7
8
|
"currency": "USD",
|
|
@@ -11,6 +12,14 @@
|
|
|
11
12
|
"idType": "MSISDN",
|
|
12
13
|
"idValue": "123456789"
|
|
13
14
|
},
|
|
15
|
+
"getPartiesResponse": {
|
|
16
|
+
"body": {
|
|
17
|
+
"errorInformation": {
|
|
18
|
+
"errorCode": "3204",
|
|
19
|
+
"errorDescription": "Party not found"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
},
|
|
14
23
|
"homeTransactionId": "123ABC",
|
|
15
24
|
"lastError": {
|
|
16
25
|
"httpStatusCode": 500,
|