@mojaloop/sdk-scheme-adapter 18.0.0 → 18.0.2

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 (119) hide show
  1. package/.dockerignore +18 -0
  2. package/.eslintignore +2 -0
  3. package/.ncurc.yaml +7 -0
  4. package/CHANGELOG.md +20 -0
  5. package/CODEOWNERS +31 -1
  6. package/README.md +1 -0
  7. package/audit-resolve.json +35 -0
  8. package/package.json +13 -13
  9. package/test/__mocks__/@mojaloop/sdk-standard-components.js +0 -151
  10. package/test/__mocks__/javascript-state-machine.js +0 -21
  11. package/test/__mocks__/redis.js +0 -78
  12. package/test/__mocks__/uuidv4.js +0 -16
  13. package/test/config/integration.env +0 -146
  14. package/test/integration/lib/Outbound/data/quotesPostRequest.json +0 -52
  15. package/test/integration/lib/Outbound/data/transfersPostRequest.json +0 -24
  16. package/test/integration/lib/Outbound/parties.test.js +0 -31
  17. package/test/integration/lib/Outbound/quotes.test.js +0 -62
  18. package/test/integration/lib/Outbound/simpleTransfers.test.js +0 -70
  19. package/test/integration/lib/cache.test.js +0 -79
  20. package/test/integration/testEnv.js +0 -4
  21. package/test/unit/ControlClient.test.js +0 -69
  22. package/test/unit/ControlServer/events.js +0 -41
  23. package/test/unit/ControlServer/index.js +0 -227
  24. package/test/unit/ControlServer.test.js +0 -66
  25. package/test/unit/InboundServer.test.js +0 -443
  26. package/test/unit/TestServer.test.js +0 -392
  27. package/test/unit/api/accounts/accounts.test.js +0 -128
  28. package/test/unit/api/accounts/data/postAccountsBody.json +0 -7
  29. package/test/unit/api/accounts/data/postAccountsErrorMojaloopResponse.json +0 -33
  30. package/test/unit/api/accounts/data/postAccountsErrorTimeoutResponse.json +0 -19
  31. package/test/unit/api/accounts/data/postAccountsSuccessResponse.json +0 -31
  32. package/test/unit/api/accounts/data/postAccountsSuccessResponseWithError1.json +0 -34
  33. package/test/unit/api/accounts/data/postAccountsSuccessResponseWithError2.json +0 -39
  34. package/test/unit/api/accounts/utils.js +0 -79
  35. package/test/unit/api/proxy/data/proxyConfig.yaml +0 -82
  36. package/test/unit/api/proxy/data/requestBody.json +0 -22
  37. package/test/unit/api/proxy/data/requestHeaders.json +0 -5
  38. package/test/unit/api/proxy/data/requestQuery.json +0 -6
  39. package/test/unit/api/proxy/data/responseBody.json +0 -21
  40. package/test/unit/api/proxy/data/responseHeaders.json +0 -5
  41. package/test/unit/api/proxy/proxy.test.js +0 -220
  42. package/test/unit/api/proxy/utils.js +0 -79
  43. package/test/unit/api/transfers/data/getTransfersCommittedResponse.json +0 -24
  44. package/test/unit/api/transfers/data/getTransfersErrorNotFound.json +0 -18
  45. package/test/unit/api/transfers/data/postQuotesBody.json +0 -52
  46. package/test/unit/api/transfers/data/postTransfersBadBody.json +0 -17
  47. package/test/unit/api/transfers/data/postTransfersBody.json +0 -24
  48. package/test/unit/api/transfers/data/postTransfersErrorMojaloopResponse.json +0 -62
  49. package/test/unit/api/transfers/data/postTransfersErrorTimeoutResponse.json +0 -48
  50. package/test/unit/api/transfers/data/postTransfersSimpleBody.json +0 -26
  51. package/test/unit/api/transfers/data/postTransfersSuccessResponse.json +0 -128
  52. package/test/unit/api/transfers/data/putPartiesBody.json +0 -20
  53. package/test/unit/api/transfers/data/putQuotesBody.json +0 -37
  54. package/test/unit/api/transfers/data/putTransfersBody.json +0 -17
  55. package/test/unit/api/transfers/transfers.test.js +0 -191
  56. package/test/unit/api/transfers/utils.js +0 -264
  57. package/test/unit/api/utils.js +0 -86
  58. package/test/unit/config.test.js +0 -119
  59. package/test/unit/data/commonHttpHeaders.json +0 -7
  60. package/test/unit/data/defaultConfig.json +0 -70
  61. package/test/unit/data/postQuotesBody.json +0 -52
  62. package/test/unit/data/putParticipantsBody.json +0 -12
  63. package/test/unit/data/putPartiesBody.json +0 -20
  64. package/test/unit/data/testFile.json +0 -29
  65. package/test/unit/data/testFile.yaml +0 -14
  66. package/test/unit/inboundApi/data/mockArguments.json +0 -117
  67. package/test/unit/inboundApi/data/mockTransactionRequest.json +0 -42
  68. package/test/unit/inboundApi/handlers.test.js +0 -786
  69. package/test/unit/index.test.js +0 -88
  70. package/test/unit/lib/cache.test.js +0 -145
  71. package/test/unit/lib/model/AccountsModel.test.js +0 -124
  72. package/test/unit/lib/model/InboundTransfersModel.test.js +0 -889
  73. package/test/unit/lib/model/OutboundBulkQuotesModel.test.js +0 -253
  74. package/test/unit/lib/model/OutboundBulkTransfersModel.test.js +0 -247
  75. package/test/unit/lib/model/OutboundRequestToPayModel.test.js +0 -166
  76. package/test/unit/lib/model/OutboundRequestToPayTransferModel.test.js +0 -245
  77. package/test/unit/lib/model/OutboundTransfersModel.test.js +0 -1579
  78. package/test/unit/lib/model/PartiesModel.test.js +0 -478
  79. package/test/unit/lib/model/QuotesModel.test.js +0 -477
  80. package/test/unit/lib/model/TransfersModel.test.js +0 -481
  81. package/test/unit/lib/model/common/PersistentStateMachine.test.js +0 -178
  82. package/test/unit/lib/model/data/authorizationsResponse.json +0 -13
  83. package/test/unit/lib/model/data/bulkQuoteRequest.json +0 -27
  84. package/test/unit/lib/model/data/bulkQuoteResponse.json +0 -35
  85. package/test/unit/lib/model/data/bulkTransferFulfil.json +0 -13
  86. package/test/unit/lib/model/data/bulkTransferRequest.json +0 -29
  87. package/test/unit/lib/model/data/defaultConfig.json +0 -59
  88. package/test/unit/lib/model/data/getBulkTransfersBackendResponse.json +0 -42
  89. package/test/unit/lib/model/data/getBulkTransfersMojaloopResponse.json +0 -22
  90. package/test/unit/lib/model/data/getTransfersBackendResponse.json +0 -34
  91. package/test/unit/lib/model/data/getTransfersMojaloopResponse.json +0 -17
  92. package/test/unit/lib/model/data/mockArguments.json +0 -188
  93. package/test/unit/lib/model/data/mockTxnRequestsArguments.json +0 -63
  94. package/test/unit/lib/model/data/notificationAbortedToPayee.json +0 -10
  95. package/test/unit/lib/model/data/notificationReservedToPayee.json +0 -10
  96. package/test/unit/lib/model/data/notificationToPayee.json +0 -10
  97. package/test/unit/lib/model/data/payeeParty.json +0 -18
  98. package/test/unit/lib/model/data/putQuotesResponse.json +0 -33
  99. package/test/unit/lib/model/data/putTransfersResponse.json +0 -5
  100. package/test/unit/lib/model/data/quoteResponse.json +0 -42
  101. package/test/unit/lib/model/data/requestToPayRequest.json +0 -20
  102. package/test/unit/lib/model/data/requestToPayTransferRequest.json +0 -27
  103. package/test/unit/lib/model/data/transactionRequestResponse.json +0 -18
  104. package/test/unit/lib/model/data/transferFulfil.json +0 -10
  105. package/test/unit/lib/model/data/transferRequest.json +0 -26
  106. package/test/unit/lib/model/mockedLibRequests.js +0 -74
  107. package/test/unit/mockLogger.js +0 -39
  108. package/test/unit/outboundApi/data/bulkQuoteRequest.json +0 -28
  109. package/test/unit/outboundApi/data/bulkTransferRequest.json +0 -28
  110. package/test/unit/outboundApi/data/mockBulkQuoteError.json +0 -45
  111. package/test/unit/outboundApi/data/mockBulkTransferError.json +0 -48
  112. package/test/unit/outboundApi/data/mockError.json +0 -41
  113. package/test/unit/outboundApi/data/mockGetPartiesError.json +0 -4
  114. package/test/unit/outboundApi/data/mockRequestToPayError.json +0 -32
  115. package/test/unit/outboundApi/data/mockRequestToPayTransferError.json +0 -39
  116. package/test/unit/outboundApi/data/requestToPay.json +0 -21
  117. package/test/unit/outboundApi/data/requestToPayTransferRequest.json +0 -20
  118. package/test/unit/outboundApi/data/transferRequest.json +0 -21
  119. package/test/unit/outboundApi/handlers.test.js +0 -887
@@ -1,264 +0,0 @@
1
- const nock = require('nock');
2
- const OpenAPIResponseValidator = require('openapi-response-validator').default;
3
-
4
- const { Logger } = require('@mojaloop/sdk-standard-components');
5
- const defaultConfig = require('../../data/defaultConfig');
6
- const postTransfersSimpleBody = require('./data/postTransfersSimpleBody');
7
-
8
- /**
9
- *
10
- * @param reqInbound
11
- * @param reqOutbound
12
- * @param apiSpecsOutbound
13
- * @returns Function(putBodyFn:function, responseCode:number, responseBody:object) => Promise
14
- */
15
- function createGetTransfersTester({ reqInbound, reqOutbound, apiSpecsOutbound }) {
16
- /**
17
- *
18
- * @param putBodyFn {function}
19
- * @param responseCode {number}
20
- * @param responseBody {object}
21
-
22
- * @return {Promise<any>}
23
- */
24
- return async (putBodyFn, responseCode, responseBody) => {
25
- const TRANSFER_ID = '00000000-0000-1000-8000-000000000001';
26
- const endpoint = new URL(`http://${defaultConfig.peerEndpoint}`).host;
27
- const switchEndpoint = `http://${endpoint}`;
28
-
29
- const sendPutTransfers = async () => {
30
- const putBody = await Promise.resolve(putBodyFn());
31
- let putUrl = `/transfers/${TRANSFER_ID}`;
32
- if (putBody.errorInformation) {
33
- putUrl += '/error';
34
- }
35
-
36
- return reqInbound.put(putUrl)
37
- .send(putBody)
38
- .set('content-type', 'application/vnd.interoperability.transfers+json;version=1.1')
39
- .set('Date', new Date().toISOString())
40
- .set('fspiop-source', 'mojaloop-sdk')
41
- .expect(200);
42
- };
43
-
44
- await nock(switchEndpoint)
45
- .get(`/transfers/${TRANSFER_ID}`)
46
- .reply(202, () => {
47
- sendPutTransfers().then();
48
- });
49
-
50
- const res = await reqOutbound.get(`/transfers/${TRANSFER_ID}`);
51
- const {body} = res;
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
- delete body.initiatedTimestamp;
58
- if (body.transferState) {
59
- delete body.transferState.initiatedTimestamp;
60
- if(body.transferState.quoteResponse) {
61
- delete body.transferState.quoteResponse.headers;
62
- }
63
- if(body.transferState.getPartiesResponse) {
64
- delete body.transferState.getPartiesResponse.headers;
65
- }
66
- if(body.transferState.fulfil) {
67
- delete body.transferState.fulfil.headers;
68
- }
69
- if(body.transferState.quoteRequest) {
70
- delete body.transferState.quoteRequest;
71
- }
72
- if(body.transferState.getPartiesRequest) {
73
- delete body.transferState.getPartiesRequest;
74
- }
75
- if(body.transferState.prepare) {
76
- delete body.transferState.prepare;
77
- }
78
- }
79
- if(body.quoteResponse) {
80
- delete body.quoteResponse.headers;
81
- }
82
- if(body.getPartiesResponse) {
83
- delete body.getPartiesResponse.headers;
84
- }
85
- if(body.fulfil) {
86
- delete body.fulfil.headers;
87
- }
88
- if(body.quoteRequest) {
89
- delete body.quoteRequest;
90
- }
91
- if(body.getPartiesRequest) {
92
- delete body.getPartiesRequest;
93
- }
94
- if(body.prepare) {
95
- delete body.prepare;
96
- }
97
- expect(body).toEqual(responseBody);
98
- const responseValidator = new OpenAPIResponseValidator(apiSpecsOutbound.paths['/transfers/{transferId}'].get);
99
- const err = responseValidator.validateResponse(responseCode, body);
100
- if (err) {
101
- throw err;
102
- }
103
- };
104
- }
105
-
106
- /**
107
- *
108
- * @param requestValidatorInbound
109
- * @param reqInbound
110
- * @param reqOutbound
111
- * @param apiSpecsOutbound
112
- * @returns Function(bodyFn:object, responseCode:number, responseBody:object) => Promise
113
- */
114
- function createPostTransfersTester(
115
- { requestValidatorInbound, reqInbound, reqOutbound, apiSpecsOutbound }) {
116
-
117
- const logger = new Logger.Logger({ context: { app: 'outbound-model-unit-tests' }, stringify: () => '' });
118
-
119
- /**
120
- *
121
- * @param bodyFn {Object}
122
- * @param responseCode {number}
123
- * @param bodyFn.parties {object}
124
- * @param bodyFn.parties.put {function}
125
- * @param bodyFn.quotes {object}
126
- * @param bodyFn.quotes.put {function}
127
- * @param bodyFn.quotes.post {function}
128
- * @param bodyFn.transfers {object}
129
- * @param bodyFn.transfers.put {function}
130
- * @param bodyFn.transfers.post {function}
131
- * @param responseBody {object}
132
-
133
- * @return {Promise<any>}
134
- */
135
- return async (bodyFn, responseCode, responseBody) => {
136
- let pendingRequest = Promise.resolve();
137
- let currentRequest = Promise.resolve();
138
- const handleRequest = async (req) => {
139
- const urlPath = req.path;
140
- const body = req.body && JSON.parse(req.body);
141
- const headers = req.headers;
142
- const method = req.method;
143
- let putBody;
144
- let putUrl;
145
- let contentType;
146
- requestValidatorInbound.validateRequest(
147
- {method, path: urlPath, request: {headers, body}}, logger);
148
- if (urlPath.startsWith('/parties/')) {
149
- putBody = await Promise.resolve(bodyFn.parties.put());
150
- putUrl = urlPath;
151
- contentType = 'application/vnd.interoperability.parties+json;version=1.1';
152
- } else if (urlPath === '/quotes') {
153
- expect(body).toEqual(bodyFn.quotes.post(body));
154
- putBody = await Promise.resolve(bodyFn.quotes.put(body));
155
- putUrl = `/quotes/${body.quoteId}`;
156
- contentType = 'application/vnd.interoperability.quotes+json;version=1.1';
157
- } else if (urlPath === '/transfers') {
158
- expect(body).toEqual(bodyFn.transfers.post(body));
159
- putBody = await Promise.resolve(bodyFn.transfers.put(body));
160
- putUrl = `/transfers/${body.transferId}`;
161
- contentType = 'application/vnd.interoperability.transfers+json;version=1.1';
162
- } else {
163
- throw new Error(`Unexpected url ${urlPath}`);
164
- }
165
- if (putBody.errorInformation) {
166
- putUrl += '/error';
167
- }
168
- // supertest experiencing issues handling simultaneous requests,
169
- // so just wait for the previous request to finish
170
- await currentRequest;
171
- currentRequest = reqInbound.put(putUrl)
172
- .send(putBody)
173
- .set('Date', new Date().toISOString())
174
- .set('content-type', contentType)
175
- .set('fspiop-source', 'mojaloop-sdk')
176
- .expect(200);
177
- return currentRequest;
178
- };
179
-
180
- function handleNockRequest(uri, body) {
181
- pendingRequest = handleRequest({
182
- method: this.method.toLowerCase(),
183
- path: uri,
184
- body,
185
- headers: this.req.headers,
186
- }).then();
187
- }
188
-
189
- const endpoint = new URL(`http://${defaultConfig.peerEndpoint}`).host;
190
- const switchEndpoint = `http://${endpoint}`;
191
-
192
- const nockMock = nock(switchEndpoint);
193
- if (bodyFn.parties) {
194
- nockMock.get(/^\/parties\//).reply(202, handleNockRequest);
195
- }
196
- if (bodyFn.quotes) {
197
- nockMock.post('/quotes').reply(202, handleNockRequest);
198
- }
199
- if (bodyFn.transfers) {
200
- nockMock.post('/transfers').reply(202, handleNockRequest);
201
- }
202
-
203
- const res = await reqOutbound.post('/transfers').send(postTransfersSimpleBody);
204
- const {body} = res;
205
-
206
- expect(res.statusCode).toEqual(responseCode);
207
-
208
- // remove elements of the response we do not want/need to compare for correctness.
209
- // timestamps on requests/responses for example will be set by the HTTP framework
210
- // and we dont want to compare against static values.
211
- delete body.initiatedTimestamp;
212
- if (body.transferState) {
213
- delete body.transferState.initiatedTimestamp;
214
- if(body.transferState.quoteResponse) {
215
- delete body.transferState.quoteResponse.headers;
216
- }
217
- if(body.transferState.getPartiesResponse) {
218
- delete body.transferState.getPartiesResponse.headers;
219
- }
220
- if(body.transferState.fulfil) {
221
- delete body.transferState.fulfil.headers;
222
- }
223
- if(body.transferState.quoteRequest) {
224
- delete body.transferState.quoteRequest;
225
- }
226
- if(body.transferState.getPartiesRequest) {
227
- delete body.transferState.getPartiesRequest;
228
- }
229
- if(body.transferState.prepare) {
230
- delete body.transferState.prepare;
231
- }
232
- }
233
- if(body.quoteResponse) {
234
- delete body.quoteResponse.headers;
235
- }
236
- if(body.getPartiesResponse) {
237
- delete body.getPartiesResponse.headers;
238
- }
239
- if(body.fulfil) {
240
- delete body.fulfil.headers;
241
- }
242
- if(body.quoteRequest) {
243
- delete body.quoteRequest;
244
- }
245
- if(body.getPartiesRequest) {
246
- delete body.getPartiesRequest;
247
- }
248
- if(body.prepare) {
249
- delete body.prepare;
250
- }
251
- expect(body).toEqual(responseBody);
252
- const responseValidator = new OpenAPIResponseValidator(apiSpecsOutbound.paths['/transfers'].post);
253
- const err = responseValidator.validateResponse(responseCode, body);
254
- if (err) {
255
- throw err;
256
- }
257
- await pendingRequest;
258
- };
259
- }
260
-
261
- module.exports = {
262
- createGetTransfersTester,
263
- createPostTransfersTester,
264
- };
@@ -1,86 +0,0 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
- const yaml = require('js-yaml');
4
- const supertest = require('supertest');
5
- const Validate = require('~/lib/validate');
6
-
7
- const InboundServer = require('~/InboundServer');
8
- const OutboundServer = require('~/OutboundServer');
9
- const { MetricsClient } = require('~/lib/metrics');
10
- const { Logger, WSO2Auth } = require('@mojaloop/sdk-standard-components');
11
- const Cache = require('~/lib/cache');
12
-
13
- /**
14
- * Get OpenAPI spec and Validator for specified server
15
- * @param serverType String
16
- * @return {Promise<{apiSpecs: Object, validator: Validator}>}
17
- */
18
- const readApiInfo = async (serverType) => {
19
- const specPath = path.join(__dirname, `../../../src/${serverType}/api.yaml`);
20
- const apiSpecs = yaml.load(fs.readFileSync(specPath));
21
- const validator = new Validate();
22
- await validator.initialise(apiSpecs);
23
- return {apiSpecs, validator};
24
- };
25
-
26
- const createValidators = async () => {
27
- const apiInfoOutbound = await readApiInfo('OutboundServer');
28
- const apiSpecsOutbound = apiInfoOutbound.apiSpecs;
29
- const requestValidatorOutbound = apiInfoOutbound.validator;
30
-
31
- const apiInfoInbound = await readApiInfo('InboundServer');
32
- const apiSpecsInbound = apiInfoInbound.apiSpecs;
33
- const requestValidatorInbound = apiInfoInbound.validator;
34
- return {
35
- apiSpecsOutbound,
36
- requestValidatorOutbound,
37
- apiSpecsInbound,
38
- requestValidatorInbound,
39
- };
40
- };
41
-
42
- const createTestServers = async (config) => {
43
- const logger = new Logger.Logger({ stringify: () => '' });
44
- const defConfig = JSON.parse(JSON.stringify(config));
45
- const cache = new Cache({
46
- cacheUrl: defConfig.cacheUrl,
47
- logger: logger.push({ component: 'cache' })
48
- });
49
- await cache.connect();
50
- defConfig.requestProcessingTimeoutSeconds = 2;
51
- const metricsClient = new MetricsClient();
52
- metricsClient._prometheusRegister.clear();
53
- const wso2 = {
54
- auth: new WSO2Auth({
55
- ...defConfig.wso2.auth,
56
- logger,
57
- tlsCreds: defConfig.outbound.tls.mutualTLS.enabled && defConfig.outbound.tls.creds,
58
- }),
59
- retryWso2AuthFailureTimes: defConfig.wso2.requestAuthFailureRetryTimes,
60
- };
61
- const serverOutbound = new OutboundServer(defConfig, logger, cache, metricsClient, wso2);
62
- await serverOutbound.start();
63
- const reqOutbound = supertest(serverOutbound._server);
64
-
65
- const serverInbound = new InboundServer(defConfig, logger, cache, wso2);
66
- await serverInbound.start();
67
- const reqInbound = supertest(serverInbound._server);
68
-
69
- return {
70
- serverOutbound,
71
- reqOutbound,
72
- serverInbound,
73
- reqInbound,
74
- };
75
- };
76
-
77
- const destroyTestServers = async (serversInfo) => {
78
- await serversInfo.serverOutbound.stop();
79
- await serversInfo.serverInbound.stop();
80
- };
81
-
82
- module.exports = {
83
- createValidators,
84
- createTestServers,
85
- destroyTestServers,
86
- };
@@ -1,119 +0,0 @@
1
- /**************************************************************************
2
- * (C) Copyright ModusBox Inc. 2019 - All rights reserved. *
3
- * *
4
- * This file is made available under the terms of the license agreement *
5
- * specified in the corresponding source code repository. *
6
- * *
7
- * ORIGINAL AUTHOR: *
8
- * James Bush - james.bush@modusbox.com *
9
- **************************************************************************/
10
-
11
- const fs = require('fs');
12
- const path = require('path');
13
- const os = require('os');
14
-
15
- const outErrorStatusKey = 'outErrorStatusKey';
16
-
17
- jest.mock('dotenv', () => ({
18
- config: jest.fn(),
19
- }));
20
-
21
- describe('config', () => {
22
- let certDir;
23
- let env;
24
-
25
- beforeEach(() => {
26
- env = { ...process.env };
27
- process.env.PEER_ENDPOINT = '172.17.0.3:4000';
28
- process.env.BACKEND_ENDPOINT = '172.17.0.5:4000';
29
- process.env.CACHE_URL = 'redis://172.17.0.2:6379';
30
- process.env.MGMT_API_WS_URL = '0.0.0.0';
31
- certDir = fs.mkdtempSync(path.join(os.tmpdir(), 'jest-'));
32
- });
33
-
34
- afterEach(() => {
35
- process.env = { ...env };
36
- fs.rmSync(certDir, { recursive: true });
37
- jest.resetModules();
38
- });
39
-
40
- it('correctly parses OUTBOUND_ERROR_STATUSCODE_EXTENSION_KEY when set', () => {
41
- process.env.OUTBOUND_ERROR_STATUSCODE_EXTENSION_KEY = outErrorStatusKey;
42
- const config = require('~/config');
43
- expect(config.outboundErrorStatusCodeExtensionKey).toEqual(outErrorStatusKey);
44
- });
45
-
46
- it('correctly parses OUTBOUND_ERROR_STATUSCODE_EXTENSION_KEY when NOT set', () => {
47
- delete process.env.OUTBOUND_ERROR_STATUSCODE_EXTENSION_KEY;
48
- const config = require('~/config');
49
- expect(config.outboundErrorStatusCodeExtensionKey).toBeUndefined();
50
- });
51
-
52
- it('correctly parses VALIDATE_INBOUND_PUT_PARTIES_JWS when NOT set', () => {
53
- delete process.env.VALIDATE_INBOUND_PUT_PARTIES_JWS;
54
- const config = require('~/config');
55
- expect(config.validateInboundPutPartiesJws).toBeFalsy();
56
- });
57
-
58
- it('correctly parses VALIDATE_INBOUND_PUT_PARTIES_JWS when set', () => {
59
- process.env.VALIDATE_INBOUND_PUT_PARTIES_JWS = 'true';
60
- const config = require('~/config');
61
- expect(config.validateInboundPutPartiesJws).toBeTruthy();
62
- });
63
-
64
- it('return single cert content from IN_SERVER_CERT_PATH', () => {
65
- const cert = path.join(certDir, 'cert.pem');
66
- const certContent = 'cert-data';
67
- fs.writeFileSync(cert, certContent);
68
- process.env.IN_SERVER_CERT_PATH = cert;
69
- const config = require('~/config');
70
- const content = config.inbound.tls.creds.cert.toString();
71
- expect(content).toBe(certContent);
72
- });
73
-
74
- it('return multiple cert content from IN_CA_CERT_PATH', () => {
75
- const certs = [
76
- path.join(certDir, 'cert1.pem'),
77
- path.join(certDir, 'cert2.pem'),
78
- ];
79
- const certContent = [
80
- 'cert1-data',
81
- 'cert2-data',
82
- ];
83
- certs.forEach((cert, index) => fs.writeFileSync(cert, certContent[index]));
84
- process.env.IN_CA_CERT_PATH = certs.join(',');
85
- const config = require('~/config');
86
- const content = config.inbound.tls.creds.ca.map(ca => ca.toString());
87
- expect(content).toStrictEqual(certContent);
88
- });
89
-
90
- it('should parse proxy config yaml file as json object', () => {
91
- process.env.PROXY_CONFIG_PATH = path.join(__dirname, './data/testFile.yaml');
92
- const config = require('~/config');
93
- const proxyConfig = require('./data/testFile');
94
- expect(config.proxyConfig).toEqual(proxyConfig);
95
- });
96
-
97
- it('should transform correctly resources versions to config', () => {
98
-
99
- const resourceVersions = {
100
- resourceOneName: {
101
- acceptVersion: '1',
102
- contentVersion: '1.0',
103
- },
104
- resourceTwoName: {
105
- acceptVersion: '1',
106
- contentVersion: '1.1',
107
- },
108
-
109
- };
110
- const parseResourceVersion = require('~/config').__parseResourceVersion;
111
- expect(parseResourceVersion('resourceOneName=1.0,resourceTwoName=1.1')).toEqual(resourceVersions);
112
- });
113
-
114
- it('should throw an err if the resource string is not correctly formed', () => {
115
- const parseResourceVersion = require('~/config').__parseResourceVersion;
116
- expect(() => parseResourceVersion('resourceOneName=1.0;resourceTwoName=1.1')).toThrowError(new Error('Resource versions format should be in format: "resourceOneName=1.0,resourceTwoName=1.1"'));
117
- });
118
-
119
- });
@@ -1,7 +0,0 @@
1
- {
2
- "content-type": "application/vnd.interoperability.parties+json;version=1.1",
3
- "fspiop-source": "other-dfsp",
4
- "fspiop-destination": "mojaloop-sdk",
5
- "fspiop-signature": "{\"signature\":\"aTTa1TTCBJA1K1VoEFgpSicWYU0q1VYXV-bjkk7uoeNicog7QSp9_AbwtYm4u8NJ1HFM_3mekE8wioAs5YNugnTlJ1k-q4Ouvp5Jo3ZnozoPVtnLaqdhxRMUBOHfDp0X8eCHEo7lETjKcCcH4r5_KT_9Vwx5TMytoG_y9Be8PpviJFkOqOV5jCeIl7XzL_pZQoY0pRJdkXDzYpXDu-HTYKr8ckxWQzx4HO-viJQd2ByQkbqPfQom9IQaAX1t4yztCCpOQn1LY9j9sbfEX9RPXG3UbY6UyDsNjUKYP9BAhXwI9pFWlgv2i9FvEtay2QYdwbW7XEpIiGZ_vi5d6yc12w\",\"protectedHeader\":\"eyJhbGciOiJSUzI1NiIsIkZTUElPUC1VUkkiOiIvcGFydGllcy9NU0lTRE4vMTIzNDU2Nzg5IiwiRlNQSU9QLUhUVFAtTWV0aG9kIjoiUFVUIiwiRlNQSU9QLVNvdXJjZSI6InNpbSIsIkZTUElPUC1EZXN0aW5hdGlvbiI6ImRmc3AiLCJEYXRlIjoiVGh1LCAzMSBPY3QgMjAxOSAxMTo0MTo0MyBHTVQifQ\"}",
6
- "accept": ""
7
- }
@@ -1,70 +0,0 @@
1
- {
2
- "control": {},
3
- "test": {
4
- "tls": {
5
- "mutualTLS": { "enabled": false },
6
- "creds": {
7
- "ca": null,
8
- "cert": null,
9
- "key": null
10
- }
11
- }
12
- },
13
- "inbound": {
14
- "tls": {
15
- "mutualTLS": { "enabled": false },
16
- "creds": {
17
- "ca": null,
18
- "cert": null,
19
- "key": null
20
- }
21
- }
22
- },
23
- "outbound": {
24
- "tls": {
25
- "mutualTLS": { "enabled": false },
26
- "creds": {
27
- "ca": null,
28
- "cert": null,
29
- "key": null
30
- }
31
- }
32
- },
33
- "peerEndpoint": "172.17.0.2:3001",
34
- "backendEndpoint": "172.17.0.2:3001",
35
- "alsEndpoint": "127.0.0.1:6500",
36
- "dfspId": "mojaloop-sdk",
37
- "ilpSecret": "mojaloop-sdk",
38
- "checkIlp": false,
39
- "expirySeconds": 60,
40
- "requestProcessingTimeoutSeconds": 30,
41
- "autoAcceptQuotes": true,
42
- "autoAcceptParty": true,
43
- "useQuoteSourceFSPAsTransferPayeeFSP": false,
44
- "tls": {
45
- },
46
- "validateInboundJws": false,
47
- "validateInboundPutPartiesJws": false,
48
- "jwsSign": false,
49
- "jwsSignPutParties": false,
50
- "jwsSigningKey": "/jwsSigningKey.key",
51
- "jwsVerificationKeysDirectory": null,
52
- "cacheUrl": "redis://localhost:6379",
53
- "enableTestFeatures": false,
54
- "oauthTestServer": {
55
- "enabled": false,
56
- "listenPort": 6000
57
- },
58
- "wso2": {
59
- "auth": {
60
- "refreshSeconds": 3600
61
- }
62
- },
63
- "rejectExpiredQuoteResponses": false,
64
- "rejectExpiredTransferFulfils": false,
65
- "rejectTransfersOnExpiredQuotes": false,
66
- "logIndent": 2,
67
- "metrics": {
68
- "port": 4004
69
- }
70
- }
@@ -1,52 +0,0 @@
1
- {
2
- "amount": {
3
- "amount": "100",
4
- "currency": "USD"
5
- },
6
- "amountType": "SEND",
7
- "expiration": "2020-01-20T11:31:49.325Z",
8
- "extensionList": {
9
- "extension": [
10
- {
11
- "key": "qreqkey1",
12
- "value": "qreqvalue1"
13
- },
14
- {
15
- "key": "qreqkey2",
16
- "value": "qreqvalue2"
17
- }
18
- ]
19
- },
20
- "note": "test payment",
21
- "payee": {
22
- "partyIdInfo": {
23
- "fspId": "sim",
24
- "partyIdType": "PERSONAL_ID",
25
- "partyIdentifier": "987654321",
26
- "partySubIdOrType": "PASSPORT"
27
- },
28
- "personalInfo": {
29
- "complexName": {
30
- "firstName": "John",
31
- "lastName": "Doe",
32
- "middleName": "Someone"
33
- },
34
- "dateOfBirth": "1980-01-01"
35
- }
36
- },
37
- "payer": {
38
- "name": "John Doe",
39
- "partyIdInfo": {
40
- "fspId": "mojaloop-sdk",
41
- "partyIdType": "MSISDN",
42
- "partyIdentifier": "123456789"
43
- }
44
- },
45
- "quoteId": "00000000-0000-1000-8000-000000000002",
46
- "transactionId": "00000000-0000-1000-8000-000000000001",
47
- "transactionType": {
48
- "initiator": "PAYER",
49
- "initiatorType": "CONSUMER",
50
- "scenario": "TRANSFER"
51
- }
52
- }
@@ -1,12 +0,0 @@
1
- {
2
- "partyList": [
3
- {
4
- "partyId": {
5
- "partyIdType": "MSISDN",
6
- "partyIdentifier": "123456789",
7
- "fspId": "sim"
8
- }
9
- }
10
- ],
11
- "currency": "USD"
12
- }
@@ -1,20 +0,0 @@
1
- {
2
- "party": {
3
- "partyIdInfo": {
4
- "partyIdType": "PERSONAL_ID",
5
- "partyIdentifier": "987654321",
6
- "partySubIdOrType": "PASSPORT",
7
- "fspId": "sim"
8
- },
9
- "personalInfo": {
10
- "complexName": {
11
- "firstName": "John",
12
- "middleName": "Someone",
13
- "lastName": "Doe"
14
- },
15
- "dateOfBirth": "1980-01-01"
16
- },
17
- "name": "John Doe",
18
- "merchantClassificationCode": "1234"
19
- }
20
- }
@@ -1,29 +0,0 @@
1
- {
2
- "version": 1,
3
- "routes": [
4
- {
5
- "description": "Routing by URL path as string",
6
- "match": [
7
- {
8
- "path": "/some/path"
9
- }
10
- ],
11
- "destination": {
12
- "path": "/switch-path-test-1"
13
- }
14
- },
15
- {
16
- "description": "Routing by URL path as regexp",
17
- "match": [
18
- {
19
- "path": {
20
- "regexp": "^\\/sdk-.*2$"
21
- }
22
- }
23
- ],
24
- "destination": {
25
- "path": "/switch-path-test-2"
26
- }
27
- }
28
- ]
29
- }
@@ -1,14 +0,0 @@
1
- version: 1.0
2
- routes:
3
- - description: 'Routing by URL path as string'
4
- match:
5
- - path: /some/path
6
- destination:
7
- path: '/switch-path-test-1'
8
-
9
- - description: 'Routing by URL path as regexp'
10
- match:
11
- - path:
12
- regexp: '^\/sdk-.*2$'
13
- destination:
14
- path: '/switch-path-test-2'