@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.
- package/.env.example +140 -0
- package/.eslintignore +2 -0
- package/.eslintrc.json +30 -0
- package/.nvmrc +1 -0
- package/.versionrc +15 -0
- package/CHANGELOG.md +118 -0
- package/InboundServer/api.yaml +3594 -0
- package/InboundServer/api_template.yaml +69 -0
- package/InboundServer/handlers.js +940 -0
- package/InboundServer/index.js +205 -0
- package/InboundServer/middlewares.js +426 -0
- package/OAuthTestServer/index.js +66 -0
- package/OAuthTestServer/model.js +70 -0
- package/OutboundServer/api.yaml +2732 -0
- package/OutboundServer/api_interfaces/index.d.ts +117 -0
- package/OutboundServer/api_interfaces/openapi.d.ts +1475 -0
- package/OutboundServer/api_template/components/parameters/bulkQuoteId.yaml +9 -0
- package/OutboundServer/api_template/components/parameters/bulkTransferId.yaml +9 -0
- package/OutboundServer/api_template/components/parameters/requestToPayTransactionId.yaml +9 -0
- package/OutboundServer/api_template/components/parameters/transferId.yaml +9 -0
- package/OutboundServer/api_template/components/responses/accountsCreationCompleted.yaml +5 -0
- package/OutboundServer/api_template/components/responses/accountsCreationError.yaml +5 -0
- package/OutboundServer/api_template/components/responses/accountsCreationTimeout.yaml +5 -0
- package/OutboundServer/api_template/components/responses/authorizationPostSuccess.yaml +5 -0
- package/OutboundServer/api_template/components/responses/authorizationsServerError.yaml +5 -0
- package/OutboundServer/api_template/components/responses/bulkQuoteBadRequest.yaml +5 -0
- package/OutboundServer/api_template/components/responses/bulkQuoteServerError.yaml +5 -0
- package/OutboundServer/api_template/components/responses/bulkQuoteSuccess.yaml +5 -0
- package/OutboundServer/api_template/components/responses/bulkQuoteTimeout.yaml +5 -0
- package/OutboundServer/api_template/components/responses/bulkTransferBadRequest.yaml +5 -0
- package/OutboundServer/api_template/components/responses/bulkTransferServerError.yaml +5 -0
- package/OutboundServer/api_template/components/responses/bulkTransferSuccess.yaml +5 -0
- package/OutboundServer/api_template/components/responses/bulkTransferTimeout.yaml +5 -0
- package/OutboundServer/api_template/components/responses/partiesByIdError404.yaml +9 -0
- package/OutboundServer/api_template/components/responses/partiesByIdSuccess.yaml +5 -0
- package/OutboundServer/api_template/components/responses/quotesPostSuccess.yaml +5 -0
- package/OutboundServer/api_template/components/responses/quotesServerError.yaml +5 -0
- package/OutboundServer/api_template/components/responses/requestToPaySuccess.yaml +5 -0
- package/OutboundServer/api_template/components/responses/requestToPayTransferBadRequest.yaml +5 -0
- package/OutboundServer/api_template/components/responses/requestToPayTransferSuccess.yaml +5 -0
- package/OutboundServer/api_template/components/responses/simpleTransfersPostSuccess.yaml +5 -0
- package/OutboundServer/api_template/components/responses/simpleTransfersServerError.yaml +5 -0
- package/OutboundServer/api_template/components/responses/transferBadRequest.yaml +5 -0
- package/OutboundServer/api_template/components/responses/transferServerError.yaml +5 -0
- package/OutboundServer/api_template/components/responses/transferSuccess.yaml +5 -0
- package/OutboundServer/api_template/components/responses/transferTimeout.yaml +5 -0
- package/OutboundServer/api_template/components/schemas/accountCreationStatus.yaml +18 -0
- package/OutboundServer/api_template/components/schemas/accountsCreationState.yaml +4 -0
- package/OutboundServer/api_template/components/schemas/accountsRequest.yaml +20 -0
- package/OutboundServer/api_template/components/schemas/accountsResponse.yaml +15 -0
- package/OutboundServer/api_template/components/schemas/async2SyncCurrentState.yaml +5 -0
- package/OutboundServer/api_template/components/schemas/authorizationsPostRequest.yaml +15 -0
- package/OutboundServer/api_template/components/schemas/authorizationsPostResponse.yaml +19 -0
- package/OutboundServer/api_template/components/schemas/bulkQuoteErrorResponse.yaml +8 -0
- package/OutboundServer/api_template/components/schemas/bulkQuoteRequest.yaml +26 -0
- package/OutboundServer/api_template/components/schemas/bulkQuoteResponse.yaml +21 -0
- package/OutboundServer/api_template/components/schemas/bulkQuoteStatus.yaml +4 -0
- package/OutboundServer/api_template/components/schemas/bulkQuoteStatusResponse.yaml +17 -0
- package/OutboundServer/api_template/components/schemas/bulkTransferErrorResponse.yaml +8 -0
- package/OutboundServer/api_template/components/schemas/bulkTransferRequest.yaml +26 -0
- package/OutboundServer/api_template/components/schemas/bulkTransferResponse.yaml +16 -0
- package/OutboundServer/api_template/components/schemas/bulkTransferStatus.yaml +4 -0
- package/OutboundServer/api_template/components/schemas/bulkTransferStatusResponse.yaml +17 -0
- package/OutboundServer/api_template/components/schemas/errorAccountsResponse.yaml +8 -0
- package/OutboundServer/api_template/components/schemas/errorAuthorizationsResponse.yaml +3 -0
- package/OutboundServer/api_template/components/schemas/errorQuotesResponse.yaml +9 -0
- package/OutboundServer/api_template/components/schemas/errorResponse.yaml +8 -0
- package/OutboundServer/api_template/components/schemas/errorSimpleTransfersResponse.yaml +3 -0
- package/OutboundServer/api_template/components/schemas/errorTransferResponse.yaml +8 -0
- package/OutboundServer/api_template/components/schemas/extensionListEmptiable.yaml +6 -0
- package/OutboundServer/api_template/components/schemas/individualQuote.yaml +32 -0
- package/OutboundServer/api_template/components/schemas/individualQuoteResult.yaml +28 -0
- package/OutboundServer/api_template/components/schemas/individualTransfer.yaml +32 -0
- package/OutboundServer/api_template/components/schemas/individualTransferFulfilment.yaml +13 -0
- package/OutboundServer/api_template/components/schemas/individualTransferResult.yaml +41 -0
- package/OutboundServer/api_template/components/schemas/mojaloopError.yaml +5 -0
- package/OutboundServer/api_template/components/schemas/mojaloopTransactionRequestState.yaml +2 -0
- package/OutboundServer/api_template/components/schemas/partiesByIdResponse.yaml +13 -0
- package/OutboundServer/api_template/components/schemas/quote.yaml +3 -0
- package/OutboundServer/api_template/components/schemas/quoteError.yaml +16 -0
- package/OutboundServer/api_template/components/schemas/quotesPostRequest.yaml +13 -0
- package/OutboundServer/api_template/components/schemas/quotesPostResponse.yaml +48 -0
- package/OutboundServer/api_template/components/schemas/requestToPayRequest.yaml +39 -0
- package/OutboundServer/api_template/components/schemas/requestToPayResponse.yaml +41 -0
- package/OutboundServer/api_template/components/schemas/requestToPayTransferRequest.yaml +42 -0
- package/OutboundServer/api_template/components/schemas/requestToPayTransferResponse.yaml +58 -0
- package/OutboundServer/api_template/components/schemas/simpleTransferServerError.yaml +5 -0
- package/OutboundServer/api_template/components/schemas/simpleTransfersPostRequest.yaml +12 -0
- package/OutboundServer/api_template/components/schemas/simpleTransfersPostResponse.yaml +11 -0
- package/OutboundServer/api_template/components/schemas/transactionType.yaml +4 -0
- package/OutboundServer/api_template/components/schemas/transferContinuationAcceptOTP.yaml +9 -0
- package/OutboundServer/api_template/components/schemas/transferContinuationAcceptParty.yaml +8 -0
- package/OutboundServer/api_template/components/schemas/transferContinuationAcceptQuote.yaml +9 -0
- package/OutboundServer/api_template/components/schemas/transferError.yaml +16 -0
- package/OutboundServer/api_template/components/schemas/transferFulfilment.yaml +3 -0
- package/OutboundServer/api_template/components/schemas/transferParty.yaml +40 -0
- package/OutboundServer/api_template/components/schemas/transferRequest.yaml +37 -0
- package/OutboundServer/api_template/components/schemas/transferResponse.yaml +58 -0
- package/OutboundServer/api_template/components/schemas/transferStatus.yaml +6 -0
- package/OutboundServer/api_template/components/schemas/transferStatusResponse.yaml +13 -0
- package/OutboundServer/api_template/health.yaml +12 -0
- package/OutboundServer/api_template/openapi.yaml +55 -0
- package/OutboundServer/api_template/paths/accounts.yaml +26 -0
- package/OutboundServer/api_template/paths/authorizations.yaml +19 -0
- package/OutboundServer/api_template/paths/bulkQuotes.yaml +23 -0
- package/OutboundServer/api_template/paths/bulkQuotes_bulkQuoteId.yaml +24 -0
- package/OutboundServer/api_template/paths/bulkTransfers.yaml +23 -0
- package/OutboundServer/api_template/paths/bulkTransfers_bulkTransferId.yaml +24 -0
- package/OutboundServer/api_template/paths/parties_Type_ID.yaml +20 -0
- package/OutboundServer/api_template/paths/parties_Type_ID_SubId.yaml +22 -0
- package/OutboundServer/api_template/paths/quotes.yaml +20 -0
- package/OutboundServer/api_template/paths/requestToPay.yaml +22 -0
- package/OutboundServer/api_template/paths/requestToPayTransfer.yaml +57 -0
- package/OutboundServer/api_template/paths/requestToPayTransfer_requestToPayTransactionId.yaml +34 -0
- package/OutboundServer/api_template/paths/simpleTransfers.yaml +19 -0
- package/OutboundServer/api_template/paths/transfers.yaml +55 -0
- package/OutboundServer/api_template/paths/transfers_transferId.yaml +58 -0
- package/OutboundServer/handlers.js +622 -0
- package/OutboundServer/index.js +137 -0
- package/OutboundServer/middlewares.js +67 -0
- package/TestServer/api.yaml +62 -0
- package/TestServer/handlers.js +63 -0
- package/TestServer/index.js +215 -0
- package/audit-resolve.json +65 -0
- package/babel.config.js +3 -0
- package/config.js +158 -0
- package/index.d.ts +1 -0
- package/index.js +149 -0
- package/jest.config.js +15 -0
- package/lib/api/index.js +12 -0
- package/lib/cache.js +352 -0
- package/lib/check.js +25 -0
- package/lib/model/AccountsModel.js +396 -0
- package/lib/model/Async2SyncModel.js +283 -0
- package/lib/model/AuthorizationsModel.js +86 -0
- package/lib/model/InboundTransfersModel.js +730 -0
- package/lib/model/OutboundBulkQuotesModel.js +485 -0
- package/lib/model/OutboundBulkTransfersModel.js +479 -0
- package/lib/model/OutboundRequestToPayModel.js +517 -0
- package/lib/model/OutboundRequestToPayTransferModel.js +893 -0
- package/lib/model/OutboundTransfersModel.js +823 -0
- package/lib/model/PartiesModel.js +70 -0
- package/lib/model/ProxyModel/MatchRules/Expression.js +48 -0
- package/lib/model/ProxyModel/MatchRules/Headers.js +65 -0
- package/lib/model/ProxyModel/MatchRules/MatchRule.js +27 -0
- package/lib/model/ProxyModel/MatchRules/Path.js +36 -0
- package/lib/model/ProxyModel/MatchRules/Query.js +65 -0
- package/lib/model/ProxyModel/MatchRules/index.js +19 -0
- package/lib/model/ProxyModel/Route.js +82 -0
- package/lib/model/ProxyModel/configSchema.json +118 -0
- package/lib/model/ProxyModel/index.js +138 -0
- package/lib/model/QuotesModel.js +94 -0
- package/lib/model/TransfersModel.js +81 -0
- package/lib/model/common/BackendError.js +26 -0
- package/lib/model/common/PersistentStateMachine.js +93 -0
- package/lib/model/common/index.js +18 -0
- package/lib/model/index.js +43 -0
- package/lib/model/lib/deferredJob.js +113 -0
- package/lib/model/lib/index.js +9 -0
- package/lib/model/lib/requests/backendRequests.js +227 -0
- package/lib/model/lib/requests/common.js +76 -0
- package/lib/model/lib/requests/index.js +19 -0
- package/lib/model/lib/shared.js +468 -0
- package/lib/randomphrase/index.js +21 -0
- package/lib/randomphrase/words.json +3397 -0
- package/lib/router.js +28 -0
- package/lib/validate.js +205 -0
- package/package.json +102 -0
- package/test/__mocks__/@mojaloop/sdk-standard-components.js +152 -0
- package/test/__mocks__/javascript-state-machine.js +21 -0
- package/test/__mocks__/redis.js +49 -0
- package/test/__mocks__/uuidv4.js +16 -0
- package/test/config/integration.env +136 -0
- package/test/integration/lib/Outbound/authorizations.test.js +58 -0
- package/test/integration/lib/Outbound/data/authorizationsPostRequest.json +43 -0
- package/test/integration/lib/Outbound/data/quotesPostRequest.json +52 -0
- package/test/integration/lib/Outbound/data/transfersPostRequest.json +24 -0
- package/test/integration/lib/Outbound/parties.test.js +28 -0
- package/test/integration/lib/Outbound/quotes.test.js +58 -0
- package/test/integration/lib/Outbound/simpleTransfers.test.js +67 -0
- package/test/integration/lib/cache.test.js +80 -0
- package/test/integration/testEnv.js +7 -0
- package/test/unit/InboundServer.test.js +443 -0
- package/test/unit/TestServer.test.js +394 -0
- package/test/unit/api/accounts/accounts.test.js +128 -0
- package/test/unit/api/accounts/data/postAccountsBody.json +7 -0
- package/test/unit/api/accounts/data/postAccountsErrorMojaloopResponse.json +25 -0
- package/test/unit/api/accounts/data/postAccountsErrorTimeoutResponse.json +19 -0
- package/test/unit/api/accounts/data/postAccountsSuccessResponse.json +17 -0
- package/test/unit/api/accounts/data/postAccountsSuccessResponseWithError1.json +21 -0
- package/test/unit/api/accounts/data/postAccountsSuccessResponseWithError2.json +21 -0
- package/test/unit/api/accounts/utils.js +65 -0
- package/test/unit/api/proxy/data/proxyConfig.yaml +82 -0
- package/test/unit/api/proxy/data/requestBody.json +22 -0
- package/test/unit/api/proxy/data/requestHeaders.json +5 -0
- package/test/unit/api/proxy/data/requestQuery.json +6 -0
- package/test/unit/api/proxy/data/responseBody.json +21 -0
- package/test/unit/api/proxy/data/responseHeaders.json +5 -0
- package/test/unit/api/proxy/proxy.test.js +220 -0
- package/test/unit/api/proxy/utils.js +79 -0
- package/test/unit/api/transfers/data/getTransfersCommittedResponse.json +21 -0
- package/test/unit/api/transfers/data/getTransfersErrorNotFound.json +17 -0
- package/test/unit/api/transfers/data/postQuotesBody.json +52 -0
- package/test/unit/api/transfers/data/postTransfersBadBody.json +17 -0
- package/test/unit/api/transfers/data/postTransfersBody.json +24 -0
- package/test/unit/api/transfers/data/postTransfersErrorMojaloopResponse.json +53 -0
- package/test/unit/api/transfers/data/postTransfersErrorTimeoutResponse.json +47 -0
- package/test/unit/api/transfers/data/postTransfersSimpleBody.json +26 -0
- package/test/unit/api/transfers/data/postTransfersSuccessResponse.json +101 -0
- package/test/unit/api/transfers/data/putPartiesBody.json +20 -0
- package/test/unit/api/transfers/data/putQuotesBody.json +37 -0
- package/test/unit/api/transfers/data/putTransfersBody.json +17 -0
- package/test/unit/api/transfers/transfers.test.js +191 -0
- package/test/unit/api/transfers/utils.js +183 -0
- package/test/unit/api/utils.js +75 -0
- package/test/unit/config.test.js +119 -0
- package/test/unit/data/commonHttpHeaders.json +6 -0
- package/test/unit/data/defaultConfig.json +58 -0
- package/test/unit/data/postQuotesBody.json +52 -0
- package/test/unit/data/putParticipantsBody.json +12 -0
- package/test/unit/data/putPartiesBody.json +20 -0
- package/test/unit/data/testFile.json +29 -0
- package/test/unit/data/testFile.yaml +14 -0
- package/test/unit/inboundApi/data/mockArguments.json +117 -0
- package/test/unit/inboundApi/data/mockTransactionRequest.json +42 -0
- package/test/unit/inboundApi/handlers.test.js +799 -0
- package/test/unit/index.test.js +55 -0
- package/test/unit/lib/cache.test.js +146 -0
- package/test/unit/lib/model/AccountsModel.test.js +121 -0
- package/test/unit/lib/model/AuthorizationsModel.test.js +460 -0
- package/test/unit/lib/model/InboundTransfersModel.test.js +628 -0
- package/test/unit/lib/model/OutboundBulkQuotesModel.test.js +249 -0
- package/test/unit/lib/model/OutboundBulkTransfersModel.test.js +244 -0
- package/test/unit/lib/model/OutboundRequestToPayModel.test.js +166 -0
- package/test/unit/lib/model/OutboundRequestToPayTransferModel.test.js +245 -0
- package/test/unit/lib/model/OutboundTransfersModel.test.js +836 -0
- package/test/unit/lib/model/PartiesModel.test.js +468 -0
- package/test/unit/lib/model/QuotesModel.test.js +470 -0
- package/test/unit/lib/model/TransfersModel.test.js +474 -0
- package/test/unit/lib/model/common/PersistentStateMachine.test.js +179 -0
- package/test/unit/lib/model/data/authorizationsResponse.json +13 -0
- package/test/unit/lib/model/data/bulkQuoteRequest.json +27 -0
- package/test/unit/lib/model/data/bulkQuoteResponse.json +35 -0
- package/test/unit/lib/model/data/bulkTransferFulfil.json +13 -0
- package/test/unit/lib/model/data/bulkTransferRequest.json +29 -0
- package/test/unit/lib/model/data/defaultConfig.json +47 -0
- package/test/unit/lib/model/data/getBulkTransfersBackendResponse.json +42 -0
- package/test/unit/lib/model/data/getBulkTransfersMojaloopResponse.json +22 -0
- package/test/unit/lib/model/data/getTransfersBackendResponse.json +34 -0
- package/test/unit/lib/model/data/getTransfersMojaloopResponse.json +17 -0
- package/test/unit/lib/model/data/mockArguments.json +131 -0
- package/test/unit/lib/model/data/mockTxnRequestsArguments.json +63 -0
- package/test/unit/lib/model/data/notificationToPayee.json +10 -0
- package/test/unit/lib/model/data/payeeParty.json +16 -0
- package/test/unit/lib/model/data/putAuthorizationsResponse.json +10 -0
- package/test/unit/lib/model/data/putQuotesResponse.json +33 -0
- package/test/unit/lib/model/data/putTransfersResponse.json +5 -0
- package/test/unit/lib/model/data/quoteResponse.json +31 -0
- package/test/unit/lib/model/data/requestToPayRequest.json +20 -0
- package/test/unit/lib/model/data/requestToPayTransferRequest.json +27 -0
- package/test/unit/lib/model/data/transactionRequestResponse.json +18 -0
- package/test/unit/lib/model/data/transferFulfil.json +8 -0
- package/test/unit/lib/model/data/transferRequest.json +26 -0
- package/test/unit/lib/model/mockedLibRequests.js +74 -0
- package/test/unit/mockLogger.js +39 -0
- package/test/unit/outboundApi/data/bulkQuoteRequest.json +28 -0
- package/test/unit/outboundApi/data/bulkTransferRequest.json +28 -0
- package/test/unit/outboundApi/data/mockBulkQuoteError.json +45 -0
- package/test/unit/outboundApi/data/mockBulkTransferError.json +48 -0
- package/test/unit/outboundApi/data/mockError.json +41 -0
- package/test/unit/outboundApi/data/mockGetPartiesError.json +4 -0
- package/test/unit/outboundApi/data/mockRequestToPayError.json +32 -0
- package/test/unit/outboundApi/data/mockRequestToPayTransferError.json +39 -0
- package/test/unit/outboundApi/data/requestToPay.json +21 -0
- package/test/unit/outboundApi/data/requestToPayTransferRequest.json +20 -0
- package/test/unit/outboundApi/data/transferRequest.json +21 -0
- package/test/unit/outboundApi/handlers.test.js +986 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"executionState": {
|
|
3
|
+
"accounts": [
|
|
4
|
+
{
|
|
5
|
+
"currency": "USD",
|
|
6
|
+
"idType": "MSISDN",
|
|
7
|
+
"idValue": "123456789"
|
|
8
|
+
}
|
|
9
|
+
],
|
|
10
|
+
"currentState": "ERROR_OCCURRED",
|
|
11
|
+
"lastError": {
|
|
12
|
+
"httpStatusCode": 500,
|
|
13
|
+
"mojaloopError": {
|
|
14
|
+
"errorInformation": {
|
|
15
|
+
"errorCode": "3204",
|
|
16
|
+
"errorDescription": "Party not found"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"modelId": "00000000-0000-1000-8000-000000000001",
|
|
21
|
+
"response": []
|
|
22
|
+
},
|
|
23
|
+
"message": "Got an error response creating accounts: {\n errorInformation: { errorCode: '3204', errorDescription: 'Party not found' }\n}",
|
|
24
|
+
"statusCode": "3204"
|
|
25
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"executionState": {
|
|
3
|
+
"accounts": [
|
|
4
|
+
{
|
|
5
|
+
"currency": "USD",
|
|
6
|
+
"idType": "MSISDN",
|
|
7
|
+
"idValue": "123456789"
|
|
8
|
+
}
|
|
9
|
+
],
|
|
10
|
+
"currentState": "ERROR_OCCURRED",
|
|
11
|
+
"lastError": {
|
|
12
|
+
"httpStatusCode": 504
|
|
13
|
+
},
|
|
14
|
+
"modelId": "00000000-0000-1000-8000-000000000001",
|
|
15
|
+
"response": []
|
|
16
|
+
},
|
|
17
|
+
"message": "Timeout waiting for response to account creation request 00000000-0000-1000-8000-000000000002",
|
|
18
|
+
"statusCode": "504"
|
|
19
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"accounts": [
|
|
3
|
+
{
|
|
4
|
+
"currency": "USD",
|
|
5
|
+
"idType": "MSISDN",
|
|
6
|
+
"idValue": "123456789"
|
|
7
|
+
}
|
|
8
|
+
],
|
|
9
|
+
"currentState": "COMPLETED",
|
|
10
|
+
"modelId": "00000000-0000-1000-8000-000000000001",
|
|
11
|
+
"response": [
|
|
12
|
+
{
|
|
13
|
+
"idType": "MSISDN",
|
|
14
|
+
"idValue": "123456789"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"accounts": [
|
|
3
|
+
{
|
|
4
|
+
"currency": "USD",
|
|
5
|
+
"idType": "MSISDN",
|
|
6
|
+
"idValue": "123456789"
|
|
7
|
+
}
|
|
8
|
+
],
|
|
9
|
+
"currentState": "COMPLETED",
|
|
10
|
+
"modelId": "00000000-0000-1000-8000-000000000001",
|
|
11
|
+
"response": [
|
|
12
|
+
{
|
|
13
|
+
"error": {
|
|
14
|
+
"message": "Provided currency not supported",
|
|
15
|
+
"statusCode": "3000"
|
|
16
|
+
},
|
|
17
|
+
"idType": "MSISDN",
|
|
18
|
+
"idValue": "123456789"
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"accounts": [
|
|
3
|
+
{
|
|
4
|
+
"currency": "USD",
|
|
5
|
+
"idType": "MSISDN",
|
|
6
|
+
"idValue": "123456789"
|
|
7
|
+
}
|
|
8
|
+
],
|
|
9
|
+
"currentState": "COMPLETED",
|
|
10
|
+
"modelId": "00000000-0000-1000-8000-000000000001",
|
|
11
|
+
"response": [
|
|
12
|
+
{
|
|
13
|
+
"error": {
|
|
14
|
+
"message": "Party not found",
|
|
15
|
+
"statusCode": "3204"
|
|
16
|
+
},
|
|
17
|
+
"idType": "MSISDN",
|
|
18
|
+
"idValue": "123456789"
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
const nock = require('nock');
|
|
2
|
+
const OpenAPIResponseValidator = require('openapi-response-validator').default;
|
|
3
|
+
|
|
4
|
+
const defaultConfig = require('../../data/defaultConfig');
|
|
5
|
+
const postAccountsBody = require('./data/postAccountsBody');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @param reqInbound
|
|
10
|
+
* @param reqOutbound
|
|
11
|
+
* @param apiSpecsOutbound
|
|
12
|
+
* @returns Function(putBodyFn:function, responseCode:number, responseBody:object) => Promise
|
|
13
|
+
*/
|
|
14
|
+
function createPostAccountsTester({ reqInbound, reqOutbound, apiSpecsOutbound }) {
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
* @param putBodyFn {function}
|
|
18
|
+
* @param responseCode {number}
|
|
19
|
+
* @param responseBody {object}
|
|
20
|
+
*
|
|
21
|
+
* @return {Promise<any>}
|
|
22
|
+
*/
|
|
23
|
+
return async (putBodyFn, responseCode, responseBody) => {
|
|
24
|
+
let pendingRequest = Promise.resolve();
|
|
25
|
+
const endpoint = new URL(`http://${defaultConfig.alsEndpoint}`).host;
|
|
26
|
+
const switchEndpoint = `http://${endpoint}`;
|
|
27
|
+
|
|
28
|
+
const sendPutParticipants = async (requestBody) => {
|
|
29
|
+
const body = JSON.parse(requestBody);
|
|
30
|
+
const putBody = await Promise.resolve(putBodyFn(body));
|
|
31
|
+
let putUrl = `/participants/${body.requestId}`;
|
|
32
|
+
if (putBody.errorInformation) {
|
|
33
|
+
putUrl += '/error';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return reqInbound.put(putUrl)
|
|
37
|
+
.send(putBody)
|
|
38
|
+
.set('Date', new Date().toISOString())
|
|
39
|
+
.set('content-type', 'application/vnd.interoperability.participants+json;version=1.0')
|
|
40
|
+
.set('fspiop-source', 'mojaloop-sdk')
|
|
41
|
+
.expect(200);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
await nock(switchEndpoint)
|
|
45
|
+
.post('/participants')
|
|
46
|
+
.reply(202, (_, requestBody) => {
|
|
47
|
+
pendingRequest = sendPutParticipants(requestBody).then();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const res = await reqOutbound.post('/accounts').send(postAccountsBody);
|
|
51
|
+
const {body} = res;
|
|
52
|
+
expect(res.statusCode).toEqual(responseCode);
|
|
53
|
+
expect(body).toEqual(responseBody);
|
|
54
|
+
const responseValidator = new OpenAPIResponseValidator(apiSpecsOutbound.paths['/accounts'].post);
|
|
55
|
+
const err = responseValidator.validateResponse(responseCode, body);
|
|
56
|
+
if (err) {
|
|
57
|
+
throw err;
|
|
58
|
+
}
|
|
59
|
+
await pendingRequest;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
module.exports = {
|
|
64
|
+
createPostAccountsTester,
|
|
65
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
version: 1.0
|
|
2
|
+
routes:
|
|
3
|
+
- description: 'Routing by URL path as string'
|
|
4
|
+
match:
|
|
5
|
+
- path: /sdk-path-test-1
|
|
6
|
+
destination:
|
|
7
|
+
path: /switch-path-test-1
|
|
8
|
+
|
|
9
|
+
- description: 'Routing by URL path as regexp'
|
|
10
|
+
match:
|
|
11
|
+
- path: ~ ^\/sdk-.*2$
|
|
12
|
+
destination:
|
|
13
|
+
path: /switch-path-test-2
|
|
14
|
+
|
|
15
|
+
- description: 'Routing by Query params with regexp'
|
|
16
|
+
match:
|
|
17
|
+
- path: /sdk-path-test-3
|
|
18
|
+
query:
|
|
19
|
+
- key: queryString1One
|
|
20
|
+
value: Value1
|
|
21
|
+
- key: ~ query.*2Two
|
|
22
|
+
value: ~ val.*2
|
|
23
|
+
destination:
|
|
24
|
+
path: /switch-path-test-3
|
|
25
|
+
|
|
26
|
+
- description: 'Routing by Query params'
|
|
27
|
+
match:
|
|
28
|
+
- query:
|
|
29
|
+
- key: testParam3
|
|
30
|
+
value: testValue3
|
|
31
|
+
destination:
|
|
32
|
+
path: /switch-path-test-3-1
|
|
33
|
+
|
|
34
|
+
- description: 'Routing by Header params with regexp'
|
|
35
|
+
match:
|
|
36
|
+
- headers:
|
|
37
|
+
- name: customHeader2
|
|
38
|
+
value: ~ .*stomval.*
|
|
39
|
+
- name: ~ cus.*header3
|
|
40
|
+
value: ~ .*
|
|
41
|
+
destination:
|
|
42
|
+
path: /switch-path-test-4
|
|
43
|
+
|
|
44
|
+
- description: 'Routing by Header params should work'
|
|
45
|
+
match:
|
|
46
|
+
- path: /sdk-path-test-4
|
|
47
|
+
headers:
|
|
48
|
+
- name: customReq-Header2
|
|
49
|
+
value: ~ .*eq-va.*
|
|
50
|
+
- name: ~ .*header3
|
|
51
|
+
value: ~ .*
|
|
52
|
+
destination:
|
|
53
|
+
path: /switch-path-test-4
|
|
54
|
+
|
|
55
|
+
- description: 'Routing by Header values'
|
|
56
|
+
match:
|
|
57
|
+
- headers:
|
|
58
|
+
- name: ~ *
|
|
59
|
+
value: ~ .*st.*val.*
|
|
60
|
+
- name: ~ *
|
|
61
|
+
value: ~ .*st.*value5
|
|
62
|
+
destination:
|
|
63
|
+
path: '/switch-path-test-5'
|
|
64
|
+
|
|
65
|
+
- description: 'Routing by multiple match rules'
|
|
66
|
+
match:
|
|
67
|
+
- path: ~ /sdk-.*-8
|
|
68
|
+
headers:
|
|
69
|
+
- name: requiredName
|
|
70
|
+
value: yes
|
|
71
|
+
- headers:
|
|
72
|
+
- name: ~ .*hkey81
|
|
73
|
+
value: ~ *
|
|
74
|
+
- headers:
|
|
75
|
+
- name: ~ .*hkey82
|
|
76
|
+
value: ~ *
|
|
77
|
+
- query:
|
|
78
|
+
- key: ~ .*qkey81
|
|
79
|
+
value: ~ *
|
|
80
|
+
|
|
81
|
+
destination:
|
|
82
|
+
path: '/switch-path-test-8'
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"pipe": {
|
|
3
|
+
"gate": {
|
|
4
|
+
"wonder": "pie",
|
|
5
|
+
"motion": -1954091019.282176,
|
|
6
|
+
"sat": -1408621945.196569,
|
|
7
|
+
"paint": false,
|
|
8
|
+
"mass": "cool",
|
|
9
|
+
"ship": 301008758.9371433
|
|
10
|
+
},
|
|
11
|
+
"rear": false,
|
|
12
|
+
"kept": true,
|
|
13
|
+
"shape": "bottle",
|
|
14
|
+
"shine": 190280734.75563002,
|
|
15
|
+
"shown": -822072188
|
|
16
|
+
},
|
|
17
|
+
"trip": -995941977,
|
|
18
|
+
"anybody": -1773044919,
|
|
19
|
+
"shoe": -1775269105,
|
|
20
|
+
"market": "room",
|
|
21
|
+
"your": "pilot"
|
|
22
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"sample": "pick",
|
|
3
|
+
"drop": [
|
|
4
|
+
{
|
|
5
|
+
"stretch": "raise",
|
|
6
|
+
"cloud": "area",
|
|
7
|
+
"mysterious": "slide",
|
|
8
|
+
"system": "headed",
|
|
9
|
+
"human": -935415263.1668315
|
|
10
|
+
},
|
|
11
|
+
-1910628437.0222688,
|
|
12
|
+
1097437779,
|
|
13
|
+
728983216,
|
|
14
|
+
true,
|
|
15
|
+
"percent"
|
|
16
|
+
],
|
|
17
|
+
"low": "material",
|
|
18
|
+
"discussion": "studying",
|
|
19
|
+
"leather": -1095320503,
|
|
20
|
+
"spent": true
|
|
21
|
+
}
|
|
@@ -0,0 +1,220 @@
|
|
|
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
|
+
* Yevhen Kyriukha - yevhen.kyriukha@modusbox.com *
|
|
9
|
+
**************************************************************************/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
jest.unmock('@mojaloop/sdk-standard-components');
|
|
14
|
+
jest.mock('redis');
|
|
15
|
+
|
|
16
|
+
const yaml = require('js-yaml');
|
|
17
|
+
const path = require('path');
|
|
18
|
+
const fs = require('fs');
|
|
19
|
+
|
|
20
|
+
const { createTestServers, destroyTestServers } = require('../utils');
|
|
21
|
+
const { createProxyTester } = require('./utils');
|
|
22
|
+
|
|
23
|
+
const defaultConfig = require('../../data/defaultConfig');
|
|
24
|
+
|
|
25
|
+
defaultConfig.peerEndpoint = `${defaultConfig.peerEndpoint}/abc/def`;
|
|
26
|
+
|
|
27
|
+
describe('Proxy', () => {
|
|
28
|
+
let serversInfo;
|
|
29
|
+
let testProxy;
|
|
30
|
+
|
|
31
|
+
const configPath = path.join(__dirname, 'data', 'proxyConfig.yaml');
|
|
32
|
+
const proxyConfig = yaml.load(fs.readFileSync(configPath));
|
|
33
|
+
|
|
34
|
+
beforeEach(async () => {
|
|
35
|
+
serversInfo = await createTestServers({
|
|
36
|
+
...defaultConfig,
|
|
37
|
+
proxyConfig,
|
|
38
|
+
});
|
|
39
|
+
testProxy = createProxyTester({
|
|
40
|
+
reqOutbound: serversInfo.reqOutbound,
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
afterEach(async () => {
|
|
45
|
+
await destroyTestServers(serversInfo);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test('should return success POST response', async () =>
|
|
49
|
+
testProxy({
|
|
50
|
+
sdkUrlPath: '/sdk-path-test-1',
|
|
51
|
+
method: 'POST',
|
|
52
|
+
query: {},
|
|
53
|
+
headers: {},
|
|
54
|
+
switchUrlPath: '/switch-path-test-1',
|
|
55
|
+
shouldForward: true,
|
|
56
|
+
}));
|
|
57
|
+
|
|
58
|
+
test('should return success PUT response', async () =>
|
|
59
|
+
testProxy({
|
|
60
|
+
sdkUrlPath: '/sdk-path-test-1',
|
|
61
|
+
method: 'PUT',
|
|
62
|
+
query: {},
|
|
63
|
+
headers: {},
|
|
64
|
+
switchUrlPath: '/switch-path-test-1',
|
|
65
|
+
shouldForward: true,
|
|
66
|
+
}));
|
|
67
|
+
|
|
68
|
+
test('should return success GET response', async () =>
|
|
69
|
+
testProxy({
|
|
70
|
+
sdkUrlPath: '/sdk-path-test-1',
|
|
71
|
+
method: 'GET',
|
|
72
|
+
query: {},
|
|
73
|
+
headers: {},
|
|
74
|
+
switchUrlPath: '/switch-path-test-1',
|
|
75
|
+
shouldForward: true,
|
|
76
|
+
}));
|
|
77
|
+
|
|
78
|
+
test('should return error response', async () =>
|
|
79
|
+
testProxy({
|
|
80
|
+
sdkUrlPath: '/unknown-sdk-path-test-1',
|
|
81
|
+
method: 'POST',
|
|
82
|
+
query: {},
|
|
83
|
+
headers: {},
|
|
84
|
+
switchUrlPath: '/switch-path-test-1',
|
|
85
|
+
shouldForward: false,
|
|
86
|
+
}));
|
|
87
|
+
|
|
88
|
+
test('should forward by path regexp', async () =>
|
|
89
|
+
testProxy({
|
|
90
|
+
sdkUrlPath: '/sdk-path-test-2',
|
|
91
|
+
method: 'POST',
|
|
92
|
+
query: {},
|
|
93
|
+
headers: {},
|
|
94
|
+
switchUrlPath: '/switch-path-test-2',
|
|
95
|
+
shouldForward: true,
|
|
96
|
+
}));
|
|
97
|
+
|
|
98
|
+
test('should forward by query params', async () =>
|
|
99
|
+
testProxy({
|
|
100
|
+
sdkUrlPath: '/sdk-path-test',
|
|
101
|
+
method: 'POST',
|
|
102
|
+
query: { testParam3: 'testValue3' },
|
|
103
|
+
headers: {},
|
|
104
|
+
switchUrlPath: '/switch-path-test-3-1',
|
|
105
|
+
shouldForward: true,
|
|
106
|
+
}));
|
|
107
|
+
|
|
108
|
+
test('should not forward by query params', async () =>
|
|
109
|
+
testProxy({
|
|
110
|
+
sdkUrlPath: '/sdk-path-test',
|
|
111
|
+
method: 'POST',
|
|
112
|
+
query: { testParam3: 'testValue4' },
|
|
113
|
+
headers: {},
|
|
114
|
+
switchUrlPath: '/switch-path-test-3-1',
|
|
115
|
+
shouldForward: false,
|
|
116
|
+
}));
|
|
117
|
+
|
|
118
|
+
test('should forward by header params', async () =>
|
|
119
|
+
testProxy({
|
|
120
|
+
sdkUrlPath: '/sdk-path-test',
|
|
121
|
+
method: 'POST',
|
|
122
|
+
query: { },
|
|
123
|
+
headers: {
|
|
124
|
+
customHeader2: 'customValue2',
|
|
125
|
+
customHeader3: 'other value'
|
|
126
|
+
},
|
|
127
|
+
switchUrlPath: '/switch-path-test-4',
|
|
128
|
+
shouldForward: true,
|
|
129
|
+
}));
|
|
130
|
+
|
|
131
|
+
test('should not forward by header params', async () =>
|
|
132
|
+
testProxy({
|
|
133
|
+
sdkUrlPath: '/sdk-path-test',
|
|
134
|
+
method: 'POST',
|
|
135
|
+
query: { },
|
|
136
|
+
headers: {
|
|
137
|
+
customHeader2: 'customValue2',
|
|
138
|
+
},
|
|
139
|
+
switchUrlPath: '/switch-path-test-4',
|
|
140
|
+
shouldForward: false,
|
|
141
|
+
}));
|
|
142
|
+
|
|
143
|
+
test('should forward by header values', async () =>
|
|
144
|
+
testProxy({
|
|
145
|
+
sdkUrlPath: '/sdk-path-test',
|
|
146
|
+
method: 'POST',
|
|
147
|
+
query: { },
|
|
148
|
+
headers: {
|
|
149
|
+
someHeader1: 'someCustomValue',
|
|
150
|
+
someHeader2: 'customValue5',
|
|
151
|
+
},
|
|
152
|
+
switchUrlPath: '/switch-path-test-5',
|
|
153
|
+
shouldForward: true,
|
|
154
|
+
}));
|
|
155
|
+
|
|
156
|
+
test('should forward using multi-match rule (path and headers)', async () =>
|
|
157
|
+
testProxy({
|
|
158
|
+
sdkUrlPath: '/sdk-path-test-8',
|
|
159
|
+
method: 'POST',
|
|
160
|
+
query: { },
|
|
161
|
+
headers: {
|
|
162
|
+
requiredName: 'yes',
|
|
163
|
+
},
|
|
164
|
+
switchUrlPath: '/switch-path-test-8',
|
|
165
|
+
shouldForward: true,
|
|
166
|
+
}));
|
|
167
|
+
|
|
168
|
+
test('should not forward using multi-match rule (wrong headers)', async () =>
|
|
169
|
+
testProxy({
|
|
170
|
+
sdkUrlPath: '/sdk-path-test-8',
|
|
171
|
+
method: 'POST',
|
|
172
|
+
query: { },
|
|
173
|
+
headers: {
|
|
174
|
+
requiredName: 'no',
|
|
175
|
+
},
|
|
176
|
+
switchUrlPath: '/switch-path-test-8',
|
|
177
|
+
shouldForward: false,
|
|
178
|
+
}));
|
|
179
|
+
|
|
180
|
+
test('should forward using multi-match rule (query)', async () =>
|
|
181
|
+
testProxy({
|
|
182
|
+
sdkUrlPath: '/sdk-path-test-8',
|
|
183
|
+
method: 'POST',
|
|
184
|
+
query: { customQkey81: 'some qval' },
|
|
185
|
+
headers: {
|
|
186
|
+
requiredName: 'no',
|
|
187
|
+
},
|
|
188
|
+
switchUrlPath: '/switch-path-test-8',
|
|
189
|
+
shouldForward: true,
|
|
190
|
+
}));
|
|
191
|
+
|
|
192
|
+
test('should forward using multi-match rule (headers)', async () =>
|
|
193
|
+
testProxy({
|
|
194
|
+
sdkUrlPath: '/sdk-path-test-8',
|
|
195
|
+
method: 'POST',
|
|
196
|
+
query: { customQkey81Unknown: 'some qval' },
|
|
197
|
+
headers: {
|
|
198
|
+
requiredName: 'no',
|
|
199
|
+
SomeHKEY82: 'some val',
|
|
200
|
+
'content-type': 'application/json',
|
|
201
|
+
},
|
|
202
|
+
switchUrlPath: '/switch-path-test-8',
|
|
203
|
+
shouldForward: true,
|
|
204
|
+
}));
|
|
205
|
+
|
|
206
|
+
test('should handle binary response', async () =>
|
|
207
|
+
testProxy({
|
|
208
|
+
sdkUrlPath: '/sdk-path-test-8',
|
|
209
|
+
method: 'POST',
|
|
210
|
+
query: { customQkey81Unknown: 'some qval' },
|
|
211
|
+
headers: {
|
|
212
|
+
requiredName: 'no',
|
|
213
|
+
SomeHKEY82: 'some val',
|
|
214
|
+
'content-type': 'application/json',
|
|
215
|
+
},
|
|
216
|
+
switchUrlPath: '/switch-path-test-8',
|
|
217
|
+
shouldForward: true,
|
|
218
|
+
binary: true,
|
|
219
|
+
}));
|
|
220
|
+
});
|