@mojaloop/sdk-scheme-adapter 11.18.8

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 (277) hide show
  1. package/.env.example +140 -0
  2. package/.eslintignore +2 -0
  3. package/.eslintrc.json +30 -0
  4. package/.nvmrc +1 -0
  5. package/.versionrc +15 -0
  6. package/CHANGELOG.md +118 -0
  7. package/InboundServer/api.yaml +3594 -0
  8. package/InboundServer/api_template.yaml +69 -0
  9. package/InboundServer/handlers.js +940 -0
  10. package/InboundServer/index.js +205 -0
  11. package/InboundServer/middlewares.js +426 -0
  12. package/OAuthTestServer/index.js +66 -0
  13. package/OAuthTestServer/model.js +70 -0
  14. package/OutboundServer/api.yaml +2732 -0
  15. package/OutboundServer/api_interfaces/index.d.ts +117 -0
  16. package/OutboundServer/api_interfaces/openapi.d.ts +1475 -0
  17. package/OutboundServer/api_template/components/parameters/bulkQuoteId.yaml +9 -0
  18. package/OutboundServer/api_template/components/parameters/bulkTransferId.yaml +9 -0
  19. package/OutboundServer/api_template/components/parameters/requestToPayTransactionId.yaml +9 -0
  20. package/OutboundServer/api_template/components/parameters/transferId.yaml +9 -0
  21. package/OutboundServer/api_template/components/responses/accountsCreationCompleted.yaml +5 -0
  22. package/OutboundServer/api_template/components/responses/accountsCreationError.yaml +5 -0
  23. package/OutboundServer/api_template/components/responses/accountsCreationTimeout.yaml +5 -0
  24. package/OutboundServer/api_template/components/responses/authorizationPostSuccess.yaml +5 -0
  25. package/OutboundServer/api_template/components/responses/authorizationsServerError.yaml +5 -0
  26. package/OutboundServer/api_template/components/responses/bulkQuoteBadRequest.yaml +5 -0
  27. package/OutboundServer/api_template/components/responses/bulkQuoteServerError.yaml +5 -0
  28. package/OutboundServer/api_template/components/responses/bulkQuoteSuccess.yaml +5 -0
  29. package/OutboundServer/api_template/components/responses/bulkQuoteTimeout.yaml +5 -0
  30. package/OutboundServer/api_template/components/responses/bulkTransferBadRequest.yaml +5 -0
  31. package/OutboundServer/api_template/components/responses/bulkTransferServerError.yaml +5 -0
  32. package/OutboundServer/api_template/components/responses/bulkTransferSuccess.yaml +5 -0
  33. package/OutboundServer/api_template/components/responses/bulkTransferTimeout.yaml +5 -0
  34. package/OutboundServer/api_template/components/responses/partiesByIdError404.yaml +9 -0
  35. package/OutboundServer/api_template/components/responses/partiesByIdSuccess.yaml +5 -0
  36. package/OutboundServer/api_template/components/responses/quotesPostSuccess.yaml +5 -0
  37. package/OutboundServer/api_template/components/responses/quotesServerError.yaml +5 -0
  38. package/OutboundServer/api_template/components/responses/requestToPaySuccess.yaml +5 -0
  39. package/OutboundServer/api_template/components/responses/requestToPayTransferBadRequest.yaml +5 -0
  40. package/OutboundServer/api_template/components/responses/requestToPayTransferSuccess.yaml +5 -0
  41. package/OutboundServer/api_template/components/responses/simpleTransfersPostSuccess.yaml +5 -0
  42. package/OutboundServer/api_template/components/responses/simpleTransfersServerError.yaml +5 -0
  43. package/OutboundServer/api_template/components/responses/transferBadRequest.yaml +5 -0
  44. package/OutboundServer/api_template/components/responses/transferServerError.yaml +5 -0
  45. package/OutboundServer/api_template/components/responses/transferSuccess.yaml +5 -0
  46. package/OutboundServer/api_template/components/responses/transferTimeout.yaml +5 -0
  47. package/OutboundServer/api_template/components/schemas/accountCreationStatus.yaml +18 -0
  48. package/OutboundServer/api_template/components/schemas/accountsCreationState.yaml +4 -0
  49. package/OutboundServer/api_template/components/schemas/accountsRequest.yaml +20 -0
  50. package/OutboundServer/api_template/components/schemas/accountsResponse.yaml +15 -0
  51. package/OutboundServer/api_template/components/schemas/async2SyncCurrentState.yaml +5 -0
  52. package/OutboundServer/api_template/components/schemas/authorizationsPostRequest.yaml +15 -0
  53. package/OutboundServer/api_template/components/schemas/authorizationsPostResponse.yaml +19 -0
  54. package/OutboundServer/api_template/components/schemas/bulkQuoteErrorResponse.yaml +8 -0
  55. package/OutboundServer/api_template/components/schemas/bulkQuoteRequest.yaml +26 -0
  56. package/OutboundServer/api_template/components/schemas/bulkQuoteResponse.yaml +21 -0
  57. package/OutboundServer/api_template/components/schemas/bulkQuoteStatus.yaml +4 -0
  58. package/OutboundServer/api_template/components/schemas/bulkQuoteStatusResponse.yaml +17 -0
  59. package/OutboundServer/api_template/components/schemas/bulkTransferErrorResponse.yaml +8 -0
  60. package/OutboundServer/api_template/components/schemas/bulkTransferRequest.yaml +26 -0
  61. package/OutboundServer/api_template/components/schemas/bulkTransferResponse.yaml +16 -0
  62. package/OutboundServer/api_template/components/schemas/bulkTransferStatus.yaml +4 -0
  63. package/OutboundServer/api_template/components/schemas/bulkTransferStatusResponse.yaml +17 -0
  64. package/OutboundServer/api_template/components/schemas/errorAccountsResponse.yaml +8 -0
  65. package/OutboundServer/api_template/components/schemas/errorAuthorizationsResponse.yaml +3 -0
  66. package/OutboundServer/api_template/components/schemas/errorQuotesResponse.yaml +9 -0
  67. package/OutboundServer/api_template/components/schemas/errorResponse.yaml +8 -0
  68. package/OutboundServer/api_template/components/schemas/errorSimpleTransfersResponse.yaml +3 -0
  69. package/OutboundServer/api_template/components/schemas/errorTransferResponse.yaml +8 -0
  70. package/OutboundServer/api_template/components/schemas/extensionListEmptiable.yaml +6 -0
  71. package/OutboundServer/api_template/components/schemas/individualQuote.yaml +32 -0
  72. package/OutboundServer/api_template/components/schemas/individualQuoteResult.yaml +28 -0
  73. package/OutboundServer/api_template/components/schemas/individualTransfer.yaml +32 -0
  74. package/OutboundServer/api_template/components/schemas/individualTransferFulfilment.yaml +13 -0
  75. package/OutboundServer/api_template/components/schemas/individualTransferResult.yaml +41 -0
  76. package/OutboundServer/api_template/components/schemas/mojaloopError.yaml +5 -0
  77. package/OutboundServer/api_template/components/schemas/mojaloopTransactionRequestState.yaml +2 -0
  78. package/OutboundServer/api_template/components/schemas/partiesByIdResponse.yaml +13 -0
  79. package/OutboundServer/api_template/components/schemas/quote.yaml +3 -0
  80. package/OutboundServer/api_template/components/schemas/quoteError.yaml +16 -0
  81. package/OutboundServer/api_template/components/schemas/quotesPostRequest.yaml +13 -0
  82. package/OutboundServer/api_template/components/schemas/quotesPostResponse.yaml +48 -0
  83. package/OutboundServer/api_template/components/schemas/requestToPayRequest.yaml +39 -0
  84. package/OutboundServer/api_template/components/schemas/requestToPayResponse.yaml +41 -0
  85. package/OutboundServer/api_template/components/schemas/requestToPayTransferRequest.yaml +42 -0
  86. package/OutboundServer/api_template/components/schemas/requestToPayTransferResponse.yaml +58 -0
  87. package/OutboundServer/api_template/components/schemas/simpleTransferServerError.yaml +5 -0
  88. package/OutboundServer/api_template/components/schemas/simpleTransfersPostRequest.yaml +12 -0
  89. package/OutboundServer/api_template/components/schemas/simpleTransfersPostResponse.yaml +11 -0
  90. package/OutboundServer/api_template/components/schemas/transactionType.yaml +4 -0
  91. package/OutboundServer/api_template/components/schemas/transferContinuationAcceptOTP.yaml +9 -0
  92. package/OutboundServer/api_template/components/schemas/transferContinuationAcceptParty.yaml +8 -0
  93. package/OutboundServer/api_template/components/schemas/transferContinuationAcceptQuote.yaml +9 -0
  94. package/OutboundServer/api_template/components/schemas/transferError.yaml +16 -0
  95. package/OutboundServer/api_template/components/schemas/transferFulfilment.yaml +3 -0
  96. package/OutboundServer/api_template/components/schemas/transferParty.yaml +40 -0
  97. package/OutboundServer/api_template/components/schemas/transferRequest.yaml +37 -0
  98. package/OutboundServer/api_template/components/schemas/transferResponse.yaml +58 -0
  99. package/OutboundServer/api_template/components/schemas/transferStatus.yaml +6 -0
  100. package/OutboundServer/api_template/components/schemas/transferStatusResponse.yaml +13 -0
  101. package/OutboundServer/api_template/health.yaml +12 -0
  102. package/OutboundServer/api_template/openapi.yaml +55 -0
  103. package/OutboundServer/api_template/paths/accounts.yaml +26 -0
  104. package/OutboundServer/api_template/paths/authorizations.yaml +19 -0
  105. package/OutboundServer/api_template/paths/bulkQuotes.yaml +23 -0
  106. package/OutboundServer/api_template/paths/bulkQuotes_bulkQuoteId.yaml +24 -0
  107. package/OutboundServer/api_template/paths/bulkTransfers.yaml +23 -0
  108. package/OutboundServer/api_template/paths/bulkTransfers_bulkTransferId.yaml +24 -0
  109. package/OutboundServer/api_template/paths/parties_Type_ID.yaml +20 -0
  110. package/OutboundServer/api_template/paths/parties_Type_ID_SubId.yaml +22 -0
  111. package/OutboundServer/api_template/paths/quotes.yaml +20 -0
  112. package/OutboundServer/api_template/paths/requestToPay.yaml +22 -0
  113. package/OutboundServer/api_template/paths/requestToPayTransfer.yaml +57 -0
  114. package/OutboundServer/api_template/paths/requestToPayTransfer_requestToPayTransactionId.yaml +34 -0
  115. package/OutboundServer/api_template/paths/simpleTransfers.yaml +19 -0
  116. package/OutboundServer/api_template/paths/transfers.yaml +55 -0
  117. package/OutboundServer/api_template/paths/transfers_transferId.yaml +58 -0
  118. package/OutboundServer/handlers.js +622 -0
  119. package/OutboundServer/index.js +137 -0
  120. package/OutboundServer/middlewares.js +67 -0
  121. package/TestServer/api.yaml +62 -0
  122. package/TestServer/handlers.js +63 -0
  123. package/TestServer/index.js +215 -0
  124. package/audit-resolve.json +65 -0
  125. package/babel.config.js +3 -0
  126. package/config.js +158 -0
  127. package/index.d.ts +1 -0
  128. package/index.js +149 -0
  129. package/jest.config.js +15 -0
  130. package/lib/api/index.js +12 -0
  131. package/lib/cache.js +352 -0
  132. package/lib/check.js +25 -0
  133. package/lib/model/AccountsModel.js +396 -0
  134. package/lib/model/Async2SyncModel.js +283 -0
  135. package/lib/model/AuthorizationsModel.js +86 -0
  136. package/lib/model/InboundTransfersModel.js +730 -0
  137. package/lib/model/OutboundBulkQuotesModel.js +485 -0
  138. package/lib/model/OutboundBulkTransfersModel.js +479 -0
  139. package/lib/model/OutboundRequestToPayModel.js +517 -0
  140. package/lib/model/OutboundRequestToPayTransferModel.js +893 -0
  141. package/lib/model/OutboundTransfersModel.js +823 -0
  142. package/lib/model/PartiesModel.js +70 -0
  143. package/lib/model/ProxyModel/MatchRules/Expression.js +48 -0
  144. package/lib/model/ProxyModel/MatchRules/Headers.js +65 -0
  145. package/lib/model/ProxyModel/MatchRules/MatchRule.js +27 -0
  146. package/lib/model/ProxyModel/MatchRules/Path.js +36 -0
  147. package/lib/model/ProxyModel/MatchRules/Query.js +65 -0
  148. package/lib/model/ProxyModel/MatchRules/index.js +19 -0
  149. package/lib/model/ProxyModel/Route.js +82 -0
  150. package/lib/model/ProxyModel/configSchema.json +118 -0
  151. package/lib/model/ProxyModel/index.js +138 -0
  152. package/lib/model/QuotesModel.js +94 -0
  153. package/lib/model/TransfersModel.js +81 -0
  154. package/lib/model/common/BackendError.js +26 -0
  155. package/lib/model/common/PersistentStateMachine.js +93 -0
  156. package/lib/model/common/index.js +18 -0
  157. package/lib/model/index.js +43 -0
  158. package/lib/model/lib/deferredJob.js +113 -0
  159. package/lib/model/lib/index.js +9 -0
  160. package/lib/model/lib/requests/backendRequests.js +227 -0
  161. package/lib/model/lib/requests/common.js +76 -0
  162. package/lib/model/lib/requests/index.js +19 -0
  163. package/lib/model/lib/shared.js +468 -0
  164. package/lib/randomphrase/index.js +21 -0
  165. package/lib/randomphrase/words.json +3397 -0
  166. package/lib/router.js +28 -0
  167. package/lib/validate.js +205 -0
  168. package/package.json +102 -0
  169. package/test/__mocks__/@mojaloop/sdk-standard-components.js +152 -0
  170. package/test/__mocks__/javascript-state-machine.js +21 -0
  171. package/test/__mocks__/redis.js +49 -0
  172. package/test/__mocks__/uuidv4.js +16 -0
  173. package/test/config/integration.env +136 -0
  174. package/test/integration/lib/Outbound/authorizations.test.js +58 -0
  175. package/test/integration/lib/Outbound/data/authorizationsPostRequest.json +43 -0
  176. package/test/integration/lib/Outbound/data/quotesPostRequest.json +52 -0
  177. package/test/integration/lib/Outbound/data/transfersPostRequest.json +24 -0
  178. package/test/integration/lib/Outbound/parties.test.js +28 -0
  179. package/test/integration/lib/Outbound/quotes.test.js +58 -0
  180. package/test/integration/lib/Outbound/simpleTransfers.test.js +67 -0
  181. package/test/integration/lib/cache.test.js +80 -0
  182. package/test/integration/testEnv.js +7 -0
  183. package/test/unit/InboundServer.test.js +443 -0
  184. package/test/unit/TestServer.test.js +394 -0
  185. package/test/unit/api/accounts/accounts.test.js +128 -0
  186. package/test/unit/api/accounts/data/postAccountsBody.json +7 -0
  187. package/test/unit/api/accounts/data/postAccountsErrorMojaloopResponse.json +25 -0
  188. package/test/unit/api/accounts/data/postAccountsErrorTimeoutResponse.json +19 -0
  189. package/test/unit/api/accounts/data/postAccountsSuccessResponse.json +17 -0
  190. package/test/unit/api/accounts/data/postAccountsSuccessResponseWithError1.json +21 -0
  191. package/test/unit/api/accounts/data/postAccountsSuccessResponseWithError2.json +21 -0
  192. package/test/unit/api/accounts/utils.js +65 -0
  193. package/test/unit/api/proxy/data/proxyConfig.yaml +82 -0
  194. package/test/unit/api/proxy/data/requestBody.json +22 -0
  195. package/test/unit/api/proxy/data/requestHeaders.json +5 -0
  196. package/test/unit/api/proxy/data/requestQuery.json +6 -0
  197. package/test/unit/api/proxy/data/responseBody.json +21 -0
  198. package/test/unit/api/proxy/data/responseHeaders.json +5 -0
  199. package/test/unit/api/proxy/proxy.test.js +220 -0
  200. package/test/unit/api/proxy/utils.js +79 -0
  201. package/test/unit/api/transfers/data/getTransfersCommittedResponse.json +21 -0
  202. package/test/unit/api/transfers/data/getTransfersErrorNotFound.json +17 -0
  203. package/test/unit/api/transfers/data/postQuotesBody.json +52 -0
  204. package/test/unit/api/transfers/data/postTransfersBadBody.json +17 -0
  205. package/test/unit/api/transfers/data/postTransfersBody.json +24 -0
  206. package/test/unit/api/transfers/data/postTransfersErrorMojaloopResponse.json +53 -0
  207. package/test/unit/api/transfers/data/postTransfersErrorTimeoutResponse.json +47 -0
  208. package/test/unit/api/transfers/data/postTransfersSimpleBody.json +26 -0
  209. package/test/unit/api/transfers/data/postTransfersSuccessResponse.json +101 -0
  210. package/test/unit/api/transfers/data/putPartiesBody.json +20 -0
  211. package/test/unit/api/transfers/data/putQuotesBody.json +37 -0
  212. package/test/unit/api/transfers/data/putTransfersBody.json +17 -0
  213. package/test/unit/api/transfers/transfers.test.js +191 -0
  214. package/test/unit/api/transfers/utils.js +183 -0
  215. package/test/unit/api/utils.js +75 -0
  216. package/test/unit/config.test.js +119 -0
  217. package/test/unit/data/commonHttpHeaders.json +6 -0
  218. package/test/unit/data/defaultConfig.json +58 -0
  219. package/test/unit/data/postQuotesBody.json +52 -0
  220. package/test/unit/data/putParticipantsBody.json +12 -0
  221. package/test/unit/data/putPartiesBody.json +20 -0
  222. package/test/unit/data/testFile.json +29 -0
  223. package/test/unit/data/testFile.yaml +14 -0
  224. package/test/unit/inboundApi/data/mockArguments.json +117 -0
  225. package/test/unit/inboundApi/data/mockTransactionRequest.json +42 -0
  226. package/test/unit/inboundApi/handlers.test.js +799 -0
  227. package/test/unit/index.test.js +55 -0
  228. package/test/unit/lib/cache.test.js +146 -0
  229. package/test/unit/lib/model/AccountsModel.test.js +121 -0
  230. package/test/unit/lib/model/AuthorizationsModel.test.js +460 -0
  231. package/test/unit/lib/model/InboundTransfersModel.test.js +628 -0
  232. package/test/unit/lib/model/OutboundBulkQuotesModel.test.js +249 -0
  233. package/test/unit/lib/model/OutboundBulkTransfersModel.test.js +244 -0
  234. package/test/unit/lib/model/OutboundRequestToPayModel.test.js +166 -0
  235. package/test/unit/lib/model/OutboundRequestToPayTransferModel.test.js +245 -0
  236. package/test/unit/lib/model/OutboundTransfersModel.test.js +836 -0
  237. package/test/unit/lib/model/PartiesModel.test.js +468 -0
  238. package/test/unit/lib/model/QuotesModel.test.js +470 -0
  239. package/test/unit/lib/model/TransfersModel.test.js +474 -0
  240. package/test/unit/lib/model/common/PersistentStateMachine.test.js +179 -0
  241. package/test/unit/lib/model/data/authorizationsResponse.json +13 -0
  242. package/test/unit/lib/model/data/bulkQuoteRequest.json +27 -0
  243. package/test/unit/lib/model/data/bulkQuoteResponse.json +35 -0
  244. package/test/unit/lib/model/data/bulkTransferFulfil.json +13 -0
  245. package/test/unit/lib/model/data/bulkTransferRequest.json +29 -0
  246. package/test/unit/lib/model/data/defaultConfig.json +47 -0
  247. package/test/unit/lib/model/data/getBulkTransfersBackendResponse.json +42 -0
  248. package/test/unit/lib/model/data/getBulkTransfersMojaloopResponse.json +22 -0
  249. package/test/unit/lib/model/data/getTransfersBackendResponse.json +34 -0
  250. package/test/unit/lib/model/data/getTransfersMojaloopResponse.json +17 -0
  251. package/test/unit/lib/model/data/mockArguments.json +131 -0
  252. package/test/unit/lib/model/data/mockTxnRequestsArguments.json +63 -0
  253. package/test/unit/lib/model/data/notificationToPayee.json +10 -0
  254. package/test/unit/lib/model/data/payeeParty.json +16 -0
  255. package/test/unit/lib/model/data/putAuthorizationsResponse.json +10 -0
  256. package/test/unit/lib/model/data/putQuotesResponse.json +33 -0
  257. package/test/unit/lib/model/data/putTransfersResponse.json +5 -0
  258. package/test/unit/lib/model/data/quoteResponse.json +31 -0
  259. package/test/unit/lib/model/data/requestToPayRequest.json +20 -0
  260. package/test/unit/lib/model/data/requestToPayTransferRequest.json +27 -0
  261. package/test/unit/lib/model/data/transactionRequestResponse.json +18 -0
  262. package/test/unit/lib/model/data/transferFulfil.json +8 -0
  263. package/test/unit/lib/model/data/transferRequest.json +26 -0
  264. package/test/unit/lib/model/mockedLibRequests.js +74 -0
  265. package/test/unit/mockLogger.js +39 -0
  266. package/test/unit/outboundApi/data/bulkQuoteRequest.json +28 -0
  267. package/test/unit/outboundApi/data/bulkTransferRequest.json +28 -0
  268. package/test/unit/outboundApi/data/mockBulkQuoteError.json +45 -0
  269. package/test/unit/outboundApi/data/mockBulkTransferError.json +48 -0
  270. package/test/unit/outboundApi/data/mockError.json +41 -0
  271. package/test/unit/outboundApi/data/mockGetPartiesError.json +4 -0
  272. package/test/unit/outboundApi/data/mockRequestToPayError.json +32 -0
  273. package/test/unit/outboundApi/data/mockRequestToPayTransferError.json +39 -0
  274. package/test/unit/outboundApi/data/requestToPay.json +21 -0
  275. package/test/unit/outboundApi/data/requestToPayTransferRequest.json +20 -0
  276. package/test/unit/outboundApi/data/transferRequest.json +21 -0
  277. package/test/unit/outboundApi/handlers.test.js +986 -0
@@ -0,0 +1,75 @@
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 { Logger } = require('@mojaloop/sdk-standard-components');
10
+ const Cache = require('../../../lib/cache');
11
+
12
+ /**
13
+ * Get OpenAPI spec and Validator for specified server
14
+ * @param serverType String
15
+ * @return {Promise<{apiSpecs: Object, validator: Validator}>}
16
+ */
17
+ const readApiInfo = async (serverType) => {
18
+ const specPath = path.join(__dirname, `../../../${serverType}/api.yaml`);
19
+ const apiSpecs = yaml.load(fs.readFileSync(specPath));
20
+ const validator = new Validate();
21
+ await validator.initialise(apiSpecs);
22
+ return {apiSpecs, validator};
23
+ };
24
+
25
+ const createValidators = async () => {
26
+ const apiInfoOutbound = await readApiInfo('OutboundServer');
27
+ const apiSpecsOutbound = apiInfoOutbound.apiSpecs;
28
+ const requestValidatorOutbound = apiInfoOutbound.validator;
29
+
30
+ const apiInfoInbound = await readApiInfo('InboundServer');
31
+ const apiSpecsInbound = apiInfoInbound.apiSpecs;
32
+ const requestValidatorInbound = apiInfoInbound.validator;
33
+ return {
34
+ apiSpecsOutbound,
35
+ requestValidatorOutbound,
36
+ apiSpecsInbound,
37
+ requestValidatorInbound,
38
+ };
39
+ };
40
+
41
+ const createTestServers = async (config) => {
42
+ const logger = new Logger.Logger({ stringify: () => '' });
43
+ const defConfig = JSON.parse(JSON.stringify(config));
44
+ const cache = new Cache({
45
+ ...defConfig.cacheConfig,
46
+ logger: logger.push({ component: 'cache' })
47
+ });
48
+ await cache.connect();
49
+ defConfig.requestProcessingTimeoutSeconds = 2;
50
+ const serverOutbound = new OutboundServer(defConfig, logger, cache);
51
+ await serverOutbound.start();
52
+ const reqOutbound = supertest(serverOutbound._server);
53
+
54
+ const serverInbound = new InboundServer(defConfig, logger, cache);
55
+ await serverInbound.start();
56
+ const reqInbound = supertest(serverInbound._server);
57
+
58
+ return {
59
+ serverOutbound,
60
+ reqOutbound,
61
+ serverInbound,
62
+ reqInbound,
63
+ };
64
+ };
65
+
66
+ const destroyTestServers = async (serversInfo) => {
67
+ await serversInfo.serverOutbound.stop();
68
+ await serversInfo.serverInbound.stop();
69
+ };
70
+
71
+ module.exports = {
72
+ createValidators,
73
+ createTestServers,
74
+ destroyTestServers,
75
+ };
@@ -0,0 +1,119 @@
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_HOST = '172.17.0.2';
30
+ process.env.CACHE_PORT = '6379';
31
+ certDir = fs.mkdtempSync(path.join(os.tmpdir(), 'jest-'));
32
+ });
33
+
34
+ afterEach(() => {
35
+ process.env = { ...env };
36
+ fs.rmdirSync(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.mutualTLS.inboundRequests.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.mutualTLS.inboundRequests.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: "resouceOneName=1.0,resourceTwoName=1.1"'));
117
+ });
118
+
119
+ });
@@ -0,0 +1,6 @@
1
+ {
2
+ "fspiop-source": "other-dfsp",
3
+ "fspiop-destination": "mojaloop-sdk",
4
+ "fspiop-signature": "{\"signature\":\"aTTa1TTCBJA1K1VoEFgpSicWYU0q1VYXV-bjkk7uoeNicog7QSp9_AbwtYm4u8NJ1HFM_3mekE8wioAs5YNugnTlJ1k-q4Ouvp5Jo3ZnozoPVtnLaqdhxRMUBOHfDp0X8eCHEo7lETjKcCcH4r5_KT_9Vwx5TMytoG_y9Be8PpviJFkOqOV5jCeIl7XzL_pZQoY0pRJdkXDzYpXDu-HTYKr8ckxWQzx4HO-viJQd2ByQkbqPfQom9IQaAX1t4yztCCpOQn1LY9j9sbfEX9RPXG3UbY6UyDsNjUKYP9BAhXwI9pFWlgv2i9FvEtay2QYdwbW7XEpIiGZ_vi5d6yc12w\",\"protectedHeader\":\"eyJhbGciOiJSUzI1NiIsIkZTUElPUC1VUkkiOiIvcGFydGllcy9NU0lTRE4vMTIzNDU2Nzg5IiwiRlNQSU9QLUhUVFAtTWV0aG9kIjoiUFVUIiwiRlNQSU9QLVNvdXJjZSI6InNpbSIsIkZTUElPUC1EZXN0aW5hdGlvbiI6ImRmc3AiLCJEYXRlIjoiVGh1LCAzMSBPY3QgMjAxOSAxMTo0MTo0MyBHTVQifQ\"}",
5
+ "accept": ""
6
+ }
@@ -0,0 +1,58 @@
1
+ {
2
+ "mutualTLS": {
3
+ "inboundRequests": {
4
+ "enabled": false,
5
+ "creds": {
6
+ "ca": null,
7
+ "cert": null,
8
+ "key": null
9
+ }
10
+ },
11
+ "outboundRequests": {
12
+ "enabled": false,
13
+ "creds": {
14
+ "ca": null,
15
+ "cert": null,
16
+ "key": null
17
+ }
18
+ }
19
+ },
20
+ "peerEndpoint": "172.17.0.2:3001",
21
+ "backendEndpoint": "172.17.0.2:3001",
22
+ "alsEndpoint": "127.0.0.1:6500",
23
+ "dfspId": "mojaloop-sdk",
24
+ "ilpSecret": "mojaloop-sdk",
25
+ "checkIlp": false,
26
+ "expirySeconds": 60,
27
+ "requestProcessingTimeoutSeconds": 30,
28
+ "autoAcceptQuotes": true,
29
+ "autoAcceptParty": true,
30
+ "useQuoteSourceFSPAsTransferPayeeFSP": false,
31
+ "tls": {
32
+ },
33
+ "validateInboundJws": false,
34
+ "validateInboundPutPartiesJws": false,
35
+ "jwsSign": false,
36
+ "jwsSignPutParties": false,
37
+ "jwsSigningKey": "/jwsSigningKey.key",
38
+ "jwsVerificationKeysDirectory": null,
39
+ "cacheConfig": {
40
+ "host": "localhost",
41
+ "port": 6379
42
+ },
43
+ "enableTestFeatures": false,
44
+ "testingDisableWSO2AuthStart": true,
45
+ "oauthTestServer": {
46
+ "enabled": false,
47
+ "listenPort": 6000
48
+ },
49
+ "wso2": {
50
+ "auth": {
51
+ "refreshSeconds": 3600
52
+ }
53
+ },
54
+ "rejectExpiredQuoteResponses": false,
55
+ "rejectExpiredTransferFulfils": false,
56
+ "rejectTransfersOnExpiredQuotes": false,
57
+ "logIndent": 2
58
+ }
@@ -0,0 +1,52 @@
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
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "partyList": [
3
+ {
4
+ "partyId": {
5
+ "partyIdType": "MSISDN",
6
+ "partyIdentifier": "123456789",
7
+ "fspId": "sim"
8
+ }
9
+ }
10
+ ],
11
+ "currency": "USD"
12
+ }
@@ -0,0 +1,20 @@
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
+ }
@@ -0,0 +1,29 @@
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
+ }
@@ -0,0 +1,14 @@
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'
@@ -0,0 +1,117 @@
1
+ {
2
+ "quoteRequest": {
3
+ "quoteId": "fake-quote-id",
4
+ "transactionId": "fake-transaction-id",
5
+ "amountType": "SEND",
6
+ "amount": {
7
+ "currency": "XOF",
8
+ "amount": 10
9
+ },
10
+ "expiration": "2019-06-04T04:02:10.378Z",
11
+ "payer": {
12
+ "partyIdInfo": {
13
+ "partyIdType": "MSISDN",
14
+ "partyIdentifier": "17855501914",
15
+ "fspId": "mojaloop-sdk"
16
+ },
17
+ "personalInfo": {
18
+ "complexName": {
19
+ "firstName": "Murthy",
20
+ "lastName": "Kakarlamudi"
21
+ },
22
+ "dateOfBirth": "2010-10-10"
23
+ },
24
+ "name": "Murthy Kakarlamudi",
25
+ "merchantClassificationCode": "123"
26
+ }
27
+ },
28
+ "bulkQuoteRequest": {
29
+ "bulkQuoteId": "fake-bulk-quote-id",
30
+ "payer": {
31
+ "partyIdInfo": {
32
+ "partyIdType": "MSISDN",
33
+ "partyIdentifier": "17855501914",
34
+ "fspId": "mojaloop-sdk"
35
+ },
36
+ "personalInfo": {
37
+ "complexName": {
38
+ "firstName": "Donald",
39
+ "lastName": "Trump"
40
+ },
41
+ "dateOfBirth": "2010-10-10"
42
+ },
43
+ "name": "Donald Trump",
44
+ "merchantClassificationCode": "123"
45
+ },
46
+ "individualQuotes": [
47
+ {
48
+ "quoteId": "fake-bulk-quote-id",
49
+ "transactionId": "fake-transaction-id",
50
+ "payee": {
51
+ "partyIdInfo": {
52
+ "partyIdType": "MSISDN",
53
+ "partyIdentifier": "17855508275",
54
+ "fspId": "mojaloop-sdk"
55
+ },
56
+ "personalInfo": {
57
+ "complexName": {
58
+ "firstName": "Justin",
59
+ "lastName": "Trudeau"
60
+ },
61
+ "dateOfBirth": "2010-10-10"
62
+ },
63
+ "name": "Justin Trudeau",
64
+ "merchantClassificationCode": "123"
65
+ },
66
+ "amountType": "SEND",
67
+ "amount": {
68
+ "currency": "XOF",
69
+ "amount": 10
70
+ },
71
+ "transactionType": {
72
+ "scenario": "TRANSFER",
73
+ "initiator": "PAYER",
74
+ "initiatorType": "CONSUMER"
75
+ }
76
+ }
77
+ ],
78
+ "expiration": "2019-06-04T04:02:10.378Z"
79
+ },
80
+ "bulkQuotePutRequest": {
81
+ "expiration": "2019-06-04T04:02:10.378Z",
82
+ "individualQuoteResults": [
83
+ {
84
+ "quoteId": "fake-bulk-transfer-id",
85
+ "ilpPacket": "WLctttbu2HvTsa1XWvUoGRcQozHsqeu9Ahl2JW9Bsu8",
86
+ "condition": "fake-condition"
87
+ }
88
+ ]
89
+ },
90
+ "bulkTransferRequest": {
91
+ "bulkTransferId": "fake-bulk-transfer-id",
92
+ "bulkQuoteId": "fake-bulk-quote-id",
93
+ "payerFsp": "fake-payer-fsp",
94
+ "payeeFsp": "fake-payee-fsp",
95
+ "expiration": "2019-06-04T04:02:10.378Z",
96
+ "individualTransfers": [
97
+ {
98
+ "transferId": "fake-bulk-transfer-id",
99
+ "transferAmount": {
100
+ "currency": "XOF",
101
+ "amount": 10
102
+ },
103
+ "ilpPacket": "AYIBgQAAAAAAAASwNGxldmVsb25lLmRmc3AxLm1lci45T2RTOF81MDdqUUZERmZlakgyOVc4bXFmNEpLMHlGTFGCAUBQU0svMS4wCk5vbmNlOiB1SXlweUYzY3pYSXBFdzVVc05TYWh3CkVuY3J5cHRpb246IG5vbmUKUGF5bWVudC1JZDogMTMyMzZhM2ItOGZhOC00MTYzLTg0NDctNGMzZWQzZGE5OGE3CgpDb250ZW50LUxlbmd0aDogMTM1CkNvbnRlbnQtVHlwZTogYXBwbGljYXRpb24vanNvbgpTZW5kZXItSWRlbnRpZmllcjogOTI4MDYzOTEKCiJ7XCJmZWVcIjowLFwidHJhbnNmZXJDb2RlXCI6XCJpbnZvaWNlXCIsXCJkZWJpdE5hbWVcIjpcImFsaWNlIGNvb3BlclwiLFwiY3JlZGl0TmFtZVwiOlwibWVyIGNoYW50XCIsXCJkZWJpdElkZW50aWZpZXJcIjpcIjkyODA2MzkxXCJ9IgA",
104
+ "condition": "f5sqb7tBTWPd5Y8BDFdMm9BJR_MNI4isf8p8n4D5pHA"
105
+ }
106
+ ]
107
+ },
108
+ "bulkTransferPutRequest": {
109
+ "completedTimestamp": "2019-06-04T04:02:10.378Z",
110
+ "individualTransferResults": [
111
+ {
112
+ "transferId": "fake-bulk-transfer-id",
113
+ "fulfilment": "WLctttbu2HvTsa1XWvUoGRcQozHsqeu9Ahl2JW9Bsu8"
114
+ }
115
+ ]
116
+ }
117
+ }