@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,21 @@
|
|
|
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
|
+
const StateMachine = jest.requireActual('javascript-state-machine');
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class MockStateMachine extends StateMachine {
|
|
15
|
+
constructor(...args) {
|
|
16
|
+
super(...args);
|
|
17
|
+
MockStateMachine.__instance = this;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
module.exports = MockStateMachine;
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
const redisMock = require('redis-mock');
|
|
14
|
+
|
|
15
|
+
// redis-mock currently ignores callback argument, the following class fix this
|
|
16
|
+
class RedisClient extends redisMock.RedisClient {
|
|
17
|
+
constructor(options, stream, redisMock) {
|
|
18
|
+
super(options, stream, redisMock);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
_executeCallback(...args) {
|
|
22
|
+
if (typeof args[args.length - 1] === 'function') {
|
|
23
|
+
const callback = args[args.length - 1];
|
|
24
|
+
const argList = Array.prototype.slice.call(args, 0, args.length - 1);
|
|
25
|
+
callback(null, argList);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
subscribe(...args) {
|
|
30
|
+
super.subscribe(...args);
|
|
31
|
+
this._executeCallback(...args);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
publish(...args) {
|
|
35
|
+
super.publish(...args);
|
|
36
|
+
this._executeCallback(...args);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
set(...args) {
|
|
40
|
+
super.set(...args);
|
|
41
|
+
this._executeCallback(...args);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
module.exports = {
|
|
48
|
+
createClient: (options = {host: 'localhost', port: 6380}, stream, redisMock) => new RedisClient(options, stream, redisMock),
|
|
49
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
let id = 0;
|
|
12
|
+
|
|
13
|
+
module.exports = {
|
|
14
|
+
__reset: () => { id = 0; },
|
|
15
|
+
uuid: () => `00000000-0000-1000-8000-${(++id).toString().padStart(12, '0')}`,
|
|
16
|
+
};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# Port number that the inbound (Mojaloop API) HTTP server will listen on
|
|
2
|
+
INBOUND_LISTEN_PORT=4000
|
|
3
|
+
|
|
4
|
+
# Port number that the outbound (simplified DFSP outbound API) HTTP server will listen on
|
|
5
|
+
OUTBOUND_LISTEN_PORT=4001
|
|
6
|
+
|
|
7
|
+
# Enable mutual TLS authentication. Useful when not running in a secure
|
|
8
|
+
# environment, i.e. when you're running it locally against your own implementation.
|
|
9
|
+
INBOUND_MUTUAL_TLS_ENABLED=false
|
|
10
|
+
OUTBOUND_MUTUAL_TLS_ENABLED=false
|
|
11
|
+
|
|
12
|
+
# Enable verification or incoming JWS signatures
|
|
13
|
+
# Note that signatures will be required on incoming messages
|
|
14
|
+
# and will be validated against a public key.
|
|
15
|
+
VALIDATE_INBOUND_JWS=false
|
|
16
|
+
|
|
17
|
+
# applicable only if VALIDATE_INBOUND_JWS is "true"
|
|
18
|
+
# allows disabling of validation on incoming PUT /parties/{idType}/{idValue} requests
|
|
19
|
+
VALIDATE_INBOUND_PUT_PARTIES_JWS=false
|
|
20
|
+
|
|
21
|
+
# Enable signing of outgoing requests
|
|
22
|
+
JWS_SIGN=false
|
|
23
|
+
|
|
24
|
+
# applicable only if JWS_SIGN is "true"
|
|
25
|
+
# allows disabling of signing on outgoing PUT /parties/{idType}/{idValue} requests
|
|
26
|
+
JWS_SIGN_PUT_PARTIES=false
|
|
27
|
+
|
|
28
|
+
# Path to JWS signing key (private key of THIS DFSP)
|
|
29
|
+
JWS_SIGNING_KEY_PATH=/jwsSigningKey.key
|
|
30
|
+
JWS_VERIFICATION_KEYS_DIRECTORY=/jwsVerificationKeys
|
|
31
|
+
|
|
32
|
+
# Location of certs and key required for TLS
|
|
33
|
+
# IN_CA_CERT_PATH=./secrets/cacert.pem
|
|
34
|
+
# IN_SERVER_CERT_PATH=./secrets/servercert.pem
|
|
35
|
+
# IN_SERVER_KEY_PATH=./secrets/serverkey.pem
|
|
36
|
+
|
|
37
|
+
# OUT_CA_CERT_PATH=./secrets/cacert.pem
|
|
38
|
+
# OUT_CLIENT_CERT_PATH=./secrets/servercert.pem
|
|
39
|
+
# OUT_CLIENT_KEY_PATH=./secrets/serverkey.pem
|
|
40
|
+
|
|
41
|
+
# The number of space characters by which to indent pretty-printed logs. If set to zero, log events
|
|
42
|
+
# will each be printed on a single line.
|
|
43
|
+
LOG_INDENT=0
|
|
44
|
+
|
|
45
|
+
# REDIS CACHE CONNECTION
|
|
46
|
+
CACHE_HOST=redis
|
|
47
|
+
CACHE_PORT=6379
|
|
48
|
+
CACHE_SHOULD_EXPIRE=false
|
|
49
|
+
CACHE_EXPIRY_SECONDS=3600
|
|
50
|
+
|
|
51
|
+
# SWITCH ENDPOINT
|
|
52
|
+
# The option 'PEER_ENDPOINT' has no effect if the remaining options 'ALS_ENDPOINT', 'QUOTES_ENDPOINT',
|
|
53
|
+
# 'BULK_QUOTES_ENDPOINT', 'TRANSFERS_ENDPOINT', 'BULK_TRANSFERS_ENDPOINT', 'TRANSACTION_REQUESTS_ENDPOINT' are specified.
|
|
54
|
+
PEER_ENDPOINT=172.17.0.3:4000
|
|
55
|
+
#ALS_ENDPOINT=account-lookup-service.local
|
|
56
|
+
#QUOTES_ENDPOINT=quoting-service.local
|
|
57
|
+
#TRANSFERS_ENDPOINT=ml-api-adapter.local
|
|
58
|
+
#BULK_TRANSFERS_ENDPOINT=bulk-api-adapter.local
|
|
59
|
+
#TRANSACTION_REQUESTS_ENDPOINT=transaction-requests-service.local
|
|
60
|
+
|
|
61
|
+
# BACKEND ENDPOINT
|
|
62
|
+
BACKEND_ENDPOINT=172.17.0.5:4000
|
|
63
|
+
|
|
64
|
+
# FSPID of this DFSP
|
|
65
|
+
DFSP_ID=mojaloop-sdk
|
|
66
|
+
|
|
67
|
+
# Secret used for generation and verification of secure ILP
|
|
68
|
+
ILP_SECRET=Quaixohyaesahju3thivuiChai5cahng
|
|
69
|
+
|
|
70
|
+
# expiry period in seconds for quote and transfers issued by the SDK
|
|
71
|
+
EXPIRY_SECONDS=60
|
|
72
|
+
|
|
73
|
+
# if set to false the SDK will not automatically accept all returned quotes
|
|
74
|
+
# but will halt the transfer after a quote response is received. A further
|
|
75
|
+
# confirmation call will be required to complete the final transfer stage.
|
|
76
|
+
AUTO_ACCEPT_QUOTES=false
|
|
77
|
+
|
|
78
|
+
# if set to false the SDK will not automatically accept a resolved party
|
|
79
|
+
# but will halt the transer after a party lookup response is received. A further
|
|
80
|
+
# cnofirmation call will be required to progress the transfer to quotes state.
|
|
81
|
+
AUTO_ACCEPT_PARTY=false
|
|
82
|
+
|
|
83
|
+
# when set to true, when sending money via the outbound API, the SDK will use the value
|
|
84
|
+
# of FSPIOP-Source header from the received quote response as the payeeFsp value in the
|
|
85
|
+
# transfer prepare request body instead of the value received in the payee party lookup.
|
|
86
|
+
# This behaviour should be enabled when the SDK user DFSP is in a forex enabled switch
|
|
87
|
+
# ecosystem and expects quotes and transfers to be rerouted by the switch to forex
|
|
88
|
+
# entities i.e. forex providing DFSPs. Please see the SDK documentation and switch
|
|
89
|
+
# operator documentation for more information on forex use cases.
|
|
90
|
+
USE_QUOTE_SOURCE_FSP_AS_TRANSFER_PAYEE_FSP=false
|
|
91
|
+
|
|
92
|
+
# set to true to validate ILP, otherwise false to ignore ILP
|
|
93
|
+
CHECK_ILP=true
|
|
94
|
+
|
|
95
|
+
# set to true to enable test features such as request cacheing and retrieval endpoints
|
|
96
|
+
ENABLE_TEST_FEATURES=false
|
|
97
|
+
|
|
98
|
+
# set to true to mock WSO2 oauth2 token endpoint
|
|
99
|
+
ENABLE_OAUTH_TOKEN_ENDPOINT=false
|
|
100
|
+
OAUTH_TOKEN_ENDPOINT_CLIENT_KEY=test-client-key
|
|
101
|
+
OAUTH_TOKEN_ENDPOINT_CLIENT_SECRET=test-client-secret
|
|
102
|
+
OAUTH_TOKEN_ENDPOINT_LISTEN_PORT=6000
|
|
103
|
+
|
|
104
|
+
# WSO2 Bearer Token specific to golden-fsp instance and environment
|
|
105
|
+
WSO2_BEARER_TOKEN=7718fa9b-be13-3fe7-87f0-a12cf1628168
|
|
106
|
+
|
|
107
|
+
# OAuth2 data used to obtain WSO2 bearer token
|
|
108
|
+
OAUTH_TOKEN_ENDPOINT=
|
|
109
|
+
OAUTH_CLIENT_KEY=
|
|
110
|
+
OAUTH_CLIENT_SECRET=
|
|
111
|
+
OAUTH_REFRESH_SECONDS=3600
|
|
112
|
+
|
|
113
|
+
# Set to true to respect expirity timestamps
|
|
114
|
+
REJECT_EXPIRED_QUOTE_RESPONSES=false
|
|
115
|
+
REJECT_TRANSFERS_ON_EXPIRED_QUOTES=false
|
|
116
|
+
REJECT_EXPIRED_TRANSFER_FULFILS=false
|
|
117
|
+
|
|
118
|
+
# Timeout for GET/POST/DELETE - PUT flow processing
|
|
119
|
+
REQUEST_PROCESSING_TIMEOUT_SECONDS=4
|
|
120
|
+
|
|
121
|
+
# Common Account Lookup System (ALS)
|
|
122
|
+
ALS_ENDPOINT=ml-testing-toolkit:5000
|
|
123
|
+
|
|
124
|
+
# QUOTES_ENDPOINT
|
|
125
|
+
QUOTES_ENDPOINT=ml-testing-toolkit:5000
|
|
126
|
+
|
|
127
|
+
# TRANSFERS_ENDPOINT
|
|
128
|
+
TRANSFERS_ENDPOINT=ml-testing-toolkit:5000
|
|
129
|
+
|
|
130
|
+
# Authorizations_ENDPOINT
|
|
131
|
+
TRANSACTION_REQUESTS_ENDPOINT=ml-testing-toolkit:5000
|
|
132
|
+
|
|
133
|
+
# To allow transfer without a previous quote request, set this value to true.
|
|
134
|
+
# The incoming transfer request should consists of an ILP packet and a matching condition in this case.
|
|
135
|
+
# The fulfilment will be generated from the provided ILP packet, and must hash to the provided condition.
|
|
136
|
+
ALLOW_TRANSFER_WITHOUT_QUOTE=false
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const axios = require('axios');
|
|
4
|
+
const { uuid } = require('uuidv4');
|
|
5
|
+
const env = require('../../testEnv');
|
|
6
|
+
const authorizationsPostRequest = require('./data/authorizationsPostRequest.json');
|
|
7
|
+
|
|
8
|
+
jest.dontMock('redis');
|
|
9
|
+
|
|
10
|
+
describe('/authorizations', () => {
|
|
11
|
+
|
|
12
|
+
test('post - happy flow', async () => {
|
|
13
|
+
const postAuthorizationsURI = `${env.OutboundHostURI}/authorizations`;
|
|
14
|
+
const transactionRequestId = uuid();
|
|
15
|
+
const res = await axios({
|
|
16
|
+
method: 'POST',
|
|
17
|
+
url: postAuthorizationsURI,
|
|
18
|
+
data: {
|
|
19
|
+
fspId: 'switch',
|
|
20
|
+
authorizationsPostRequest: {
|
|
21
|
+
...authorizationsPostRequest,
|
|
22
|
+
transactionRequestId
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
headers: {
|
|
26
|
+
'access-control-allow-origin': '*'
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
expect(res.status).toEqual(200);
|
|
31
|
+
expect(res.data.currentState).toEqual('COMPLETED');
|
|
32
|
+
expect(typeof res.data).toEqual('object');
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test('post - timeout', (done) => {
|
|
36
|
+
const postAuthorizationsURI = `${env.OutboundHostURI}/authorizations`;
|
|
37
|
+
const transactionRequestId = uuid();
|
|
38
|
+
axios({
|
|
39
|
+
method: 'POST',
|
|
40
|
+
url: postAuthorizationsURI,
|
|
41
|
+
data: {
|
|
42
|
+
fspId: 'timeout-fsp-id',
|
|
43
|
+
authorizationsPostRequest: {
|
|
44
|
+
...authorizationsPostRequest,
|
|
45
|
+
transactionRequestId
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
headers: {
|
|
49
|
+
'access-control-allow-origin': '*'
|
|
50
|
+
}
|
|
51
|
+
}).catch(err => {
|
|
52
|
+
expect(err.response.status).toEqual(500);
|
|
53
|
+
expect(err.response.data.message).toEqual('Timeout');
|
|
54
|
+
done();
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"authenticationType": "U2F",
|
|
3
|
+
"retriesLeft": 1,
|
|
4
|
+
"amount": {
|
|
5
|
+
"currency": "USD",
|
|
6
|
+
"amount": "100"
|
|
7
|
+
},
|
|
8
|
+
"transactionId": "2f169631-ef99-4cb1-96dc-91e8fc08f539",
|
|
9
|
+
"transactionRequestId": "02e28448-3c05-4059-b5f7-d518d0a2d8ea",
|
|
10
|
+
"quote": {
|
|
11
|
+
"transferAmount": {
|
|
12
|
+
"currency": "USD",
|
|
13
|
+
"amount": "100"
|
|
14
|
+
},
|
|
15
|
+
"payeeReceiveAmount": {
|
|
16
|
+
"currency": "USD",
|
|
17
|
+
"amount": "99"
|
|
18
|
+
},
|
|
19
|
+
"payeeFspFee": {
|
|
20
|
+
"currency": "USD",
|
|
21
|
+
"amount": "1"
|
|
22
|
+
},
|
|
23
|
+
"payeeFspCommission": {
|
|
24
|
+
"currency": "USD",
|
|
25
|
+
"amount": "0"
|
|
26
|
+
},
|
|
27
|
+
"expiration": "2020-05-17T15:28:54.250Z",
|
|
28
|
+
"geoCode": {
|
|
29
|
+
"latitude": "+45.4215",
|
|
30
|
+
"longitude": "+75.6972"
|
|
31
|
+
},
|
|
32
|
+
"ilpPacket": "AQAAAAAAACasIWcuc2UubW9iaWxlbW9uZXkubXNpc2RuLjEyMzQ1Njc4OYIEIXsNCiAgICAidHJhbnNhY3Rpb25JZCI6ICI4NWZlYWMyZi0zOWIyLTQ5MWItODE3ZS00YTAzMjAzZDRmMTQiLA0KICAgICJxdW90ZUlkIjogIjdjMjNlODBjLWQwNzgtNDA3Ny04MjYzLTJjMDQ3ODc2ZmNmNiIsDQogICAgInBheWVlIjogew0KICAgICAgICAicGFydHlJZEluZm8iOiB7DQogICAgICAgICAgICAicGFydHlJZFR5cGUiOiAiTVNJU0ROIiwNCiAgICAgICAgICAgICJwYXJ0eUlkZW50aWZpZXIiOiAiMTIzNDU2Nzg5IiwNCiAgICAgICAgICAgICJmc3BJZCI6ICJNb2JpbGVNb25leSINCiAgICAgICAgfSwNCiAgICAgICAgInBlcnNvbmFsSW5mbyI6IHsNCiAgICAgICAgICAgICJjb21wbGV4TmFtZSI6IHsNCiAgICAgICAgICAgICAgICAiZmlyc3ROYW1lIjogIkhlbnJpayIsDQogICAgICAgICAgICAgICAgImxhc3ROYW1lIjogIkthcmxzc29uIg0KICAgICAgICAgICAgfQ0KICAgICAgICB9DQogICAgfSwNCiAgICAicGF5ZXIiOiB7DQogICAgICAgICJwZXJzb25hbEluZm8iOiB7DQogICAgICAgICAgICAiY29tcGxleE5hbWUiOiB7DQogICAgICAgICAgICAgICAgImZpcnN0TmFtZSI6ICJNYXRzIiwNCiAgICAgICAgICAgICAgICAibGFzdE5hbWUiOiAiSGFnbWFuIg0KICAgICAgICAgICAgfQ0KICAgICAgICB9LA0KICAgICAgICAicGFydHlJZEluZm8iOiB7DQogICAgICAgICAgICAicGFydHlJZFR5cGUiOiAiSUJBTiIsDQogICAgICAgICAgICAicGFydHlJZGVudGlmaWVyIjogIlNFNDU1MDAwMDAwMDA1ODM5ODI1NzQ2NiIsDQogICAgICAgICAgICAiZnNwSWQiOiAiQmFua05yT25lIg0KICAgICAgICB9DQogICAgfSwNCiAgICAiYW1vdW50Ijogew0KICAgICAgICAiYW1vdW50IjogIjEwMCIsDQogICAgICAgICJjdXJyZW5jeSI6ICJVU0QiDQogICAgfSwNCiAgICAidHJhbnNhY3Rpb25UeXBlIjogew0KICAgICAgICAic2NlbmFyaW8iOiAiVFJBTlNGRVIiLA0KICAgICAgICAiaW5pdGlhdG9yIjogIlBBWUVSIiwNCiAgICAgICAgImluaXRpYXRvclR5cGUiOiAiQ09OU1VNRVIiDQogICAgfSwNCiAgICAibm90ZSI6ICJGcm9tIE1hdHMiDQp9DQo\u003d\u003d",
|
|
33
|
+
"condition": "f5sqb7tBTWPd5Y8BDFdMm9BJR_MNI4isf8p8n4D5pHA",
|
|
34
|
+
"extensionList": {
|
|
35
|
+
"extension": [
|
|
36
|
+
{
|
|
37
|
+
"key": "errorDescription1",
|
|
38
|
+
"value": "This is a more detailed error description"
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -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
|
+
"scenario": "TRANSFER",
|
|
49
|
+
"initiator": "PAYEE",
|
|
50
|
+
"initiatorType": "CONSUMER"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"transferId": "00000000-0000-1000-8000-000000000005",
|
|
3
|
+
"payeeFsp": "sim",
|
|
4
|
+
"payerFsp": "mojaloop-sdk",
|
|
5
|
+
"amount": {
|
|
6
|
+
"amount": "100",
|
|
7
|
+
"currency": "USD"
|
|
8
|
+
},
|
|
9
|
+
"ilpPacket": "AYIBgQAAAAAAAASwNGxldmVsb25lLmRmc3AxLm1lci45T2RTOF81MDdqUUZERmZlakgyOVc4bXFmNEpLMHlGTFGCAUBQU0svMS4wCk5vbmNlOiB1SXlweUYzY3pYSXBFdzVVc05TYWh3CkVuY3J5cHRpb246IG5vbmUKUGF5bWVudC1JZDogMTMyMzZhM2ItOGZhOC00MTYzLTg0NDctNGMzZWQzZGE5OGE3CgpDb250ZW50LUxlbmd0aDogMTM1CkNvbnRlbnQtVHlwZTogYXBwbGljYXRpb24vanNvbgpTZW5kZXItSWRlbnRpZmllcjogOTI4MDYzOTEKCiJ7XCJmZWVcIjowLFwidHJhbnNmZXJDb2RlXCI6XCJpbnZvaWNlXCIsXCJkZWJpdE5hbWVcIjpcImFsaWNlIGNvb3BlclwiLFwiY3JlZGl0TmFtZVwiOlwibWVyIGNoYW50XCIsXCJkZWJpdElkZW50aWZpZXJcIjpcIjkyODA2MzkxXCJ9IgA",
|
|
10
|
+
"condition": "f5sqb7tBTWPd5Y8BDFdMm9BJR_MNI4isf8p8n4D5pHA",
|
|
11
|
+
"expiration": "2020-01-20T11:31:49.325Z",
|
|
12
|
+
"extensionList": {
|
|
13
|
+
"extension": [
|
|
14
|
+
{
|
|
15
|
+
"key": "qreqkey1",
|
|
16
|
+
"value": "qreqvalue1"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"key": "qreqkey2",
|
|
20
|
+
"value": "qreqvalue2"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const axios = require('axios');
|
|
4
|
+
const env = require('../../testEnv');
|
|
5
|
+
|
|
6
|
+
jest.dontMock('redis');
|
|
7
|
+
|
|
8
|
+
describe('/parties', () => {
|
|
9
|
+
|
|
10
|
+
test('get - happy flow', async () => {
|
|
11
|
+
const getPartiesURI = `${env.OutboundHostURI}/parties/MSISDN/1234567890`;
|
|
12
|
+
const res = await axios.get(getPartiesURI);
|
|
13
|
+
|
|
14
|
+
expect(res.status).toEqual(200);
|
|
15
|
+
expect(res.data.currentState).toEqual('COMPLETED');
|
|
16
|
+
expect(typeof res.data.party).toEqual('object');
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test('get - timeout', (done) => {
|
|
20
|
+
const getPartiesURI = `${env.OutboundHostURI}/parties/MSISDN/0987654321`;
|
|
21
|
+
axios.get(getPartiesURI).catch(err => {
|
|
22
|
+
expect(err.response.status).toEqual(500);
|
|
23
|
+
expect(err.response.data.message).toEqual('Timeout');
|
|
24
|
+
done();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const axios = require('axios');
|
|
4
|
+
const { uuid } = require('uuidv4');
|
|
5
|
+
const env = require('../../testEnv');
|
|
6
|
+
const quotesPostRequest = require('./data/quotesPostRequest.json');
|
|
7
|
+
|
|
8
|
+
jest.dontMock('redis');
|
|
9
|
+
|
|
10
|
+
describe('/quotes', () => {
|
|
11
|
+
|
|
12
|
+
test('post - happy flow', async () => {
|
|
13
|
+
const postQuotesURI = `${env.OutboundHostURI}/quotes`;
|
|
14
|
+
const quoteId = uuid();
|
|
15
|
+
const res = await axios({
|
|
16
|
+
method: 'POST',
|
|
17
|
+
url: postQuotesURI,
|
|
18
|
+
data: {
|
|
19
|
+
fspId: 'switch',
|
|
20
|
+
quotesPostRequest: {
|
|
21
|
+
...quotesPostRequest,
|
|
22
|
+
quoteId
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
headers: {
|
|
26
|
+
'access-control-allow-origin': '*'
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
expect(res.status).toEqual(200);
|
|
31
|
+
expect(res.data.currentState).toEqual('COMPLETED');
|
|
32
|
+
expect(typeof res.data.quotes).toEqual('object');
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test('post - timeout', (done) => {
|
|
36
|
+
const postQuotesURI = `${env.OutboundHostURI}/quotes`;
|
|
37
|
+
const quoteId = uuid();
|
|
38
|
+
axios({
|
|
39
|
+
method: 'POST',
|
|
40
|
+
url: postQuotesURI,
|
|
41
|
+
data: {
|
|
42
|
+
fspId: 'timeout-fsp-id',
|
|
43
|
+
quotesPostRequest: {
|
|
44
|
+
...quotesPostRequest,
|
|
45
|
+
quoteId
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
headers: {
|
|
49
|
+
'access-control-allow-origin': '*'
|
|
50
|
+
}
|
|
51
|
+
}).catch(err => {
|
|
52
|
+
expect(err.response.status).toEqual(500);
|
|
53
|
+
expect(err.response.data.message).toEqual('Timeout');
|
|
54
|
+
done();
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
});
|