account-lookup-service 17.7.0 → 17.8.0-snapshot.10
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/docker/mock-proxy/src/server.ts +13 -4
- package/package.json +11 -8
- package/src/constants.js +35 -2
- package/src/domain/parties/deps.js +11 -4
- package/src/domain/parties/getPartiesByTypeAndID.js +9 -13
- package/src/domain/parties/partiesUtils.js +4 -34
- package/src/domain/parties/putParties.js +26 -71
- package/src/domain/parties/services/BasePartiesService.js +143 -15
- package/src/domain/parties/services/GetPartiesService.js +210 -165
- package/src/domain/parties/services/PutPartiesErrorService.js +52 -28
- package/src/domain/parties/services/PutPartiesService.js +51 -33
- package/src/domain/parties/services/TimeoutPartiesService.js +84 -0
- package/src/domain/parties/services/index.js +3 -1
- package/src/domain/timeout/createSpan.js +55 -0
- package/src/domain/timeout/index.js +27 -36
- package/src/handlers/TimeoutHandler.js +2 -2
- package/src/index.js +3 -0
- package/src/lib/util.js +11 -3
- package/test/fixtures/index.js +53 -3
- package/test/integration/api/parties.test.js +1 -0
- package/test/integration/domain/timeout/index.test.js +83 -28
- package/test/unit/domain/parties/parties.test.js +26 -18
- package/test/unit/domain/parties/partiesUtils.test.js +51 -0
- package/test/unit/domain/parties/services/BasePartiesService.test.js +71 -0
- package/test/unit/domain/parties/services/GetPartiesService.test.js +316 -0
- package/test/unit/domain/parties/services/PutPartiesErrorService.test.js +50 -0
- package/test/unit/domain/parties/services/TimeoutPartiesService.test.js +72 -0
- package/test/unit/domain/parties/services/deps.js +51 -0
- package/test/unit/domain/timeout/index.test.js +17 -12
- package/test/util/apiClients/AlsApiClient.js +6 -4
- package/test/util/apiClients/BasicApiClient.js +33 -6
- package/test/util/apiClients/ProxyApiClient.js +46 -1
- package/test/util/index.js +5 -6
- package/test/util/mockDeps.js +72 -0
- package/src/domain/timeout/dto.js +0 -54
- package/test/unit/domain/parties/utils.test.js +0 -60
- package/test/unit/domain/timeout/dto.test.js +0 -24
@@ -1,18 +1,50 @@
|
|
1
|
+
/*****
|
2
|
+
License
|
3
|
+
--------------
|
4
|
+
Copyright © 2020-2025 Mojaloop Foundation
|
5
|
+
The Mojaloop files are made available by the Mojaloop Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
10
|
+
|
11
|
+
Contributors
|
12
|
+
--------------
|
13
|
+
This is the official list of the Mojaloop project contributors for this file.
|
14
|
+
Names of the original copyright holders (individuals or organizations)
|
15
|
+
should be listed with a '*' in the first column. People who have
|
16
|
+
contributed from an organization can be listed under the organization
|
17
|
+
that actually holds the copyright for their contributions (see the
|
18
|
+
Mojaloop Foundation for an example). Those individuals should have
|
19
|
+
their names indented and be marked with a '-'. Email address can be added
|
20
|
+
optionally within square brackets <email>.
|
21
|
+
|
22
|
+
* Mojaloop Foundation
|
23
|
+
* Eugen Klymniuk <eugen.klymniuk@infitx.com>
|
24
|
+
|
25
|
+
--------------
|
26
|
+
******/
|
27
|
+
|
1
28
|
const { createProxyCache } = require('@mojaloop/inter-scheme-proxy-cache-lib')
|
2
|
-
const {
|
29
|
+
const { RedisProxyCache } = require('@mojaloop/inter-scheme-proxy-cache-lib/dist/lib/storages/RedisProxyCache')
|
30
|
+
const config = require('#src/lib/config')
|
3
31
|
const fixtures = require('../../../fixtures')
|
4
32
|
const { ProxyApiClient } = require('../../../util')
|
5
|
-
const
|
33
|
+
const { PAYER_DFSP, PARTY_ID_TYPE, PROXY_NAME } = require('../../constants')
|
6
34
|
|
7
35
|
const wait = (sec) => new Promise(resolve => setTimeout(resolve, sec * 1000))
|
8
36
|
|
9
37
|
const CRON_TIMEOUT_SEC = 15 // see TIMEXP
|
10
38
|
|
39
|
+
jest.setTimeout(60_000)
|
40
|
+
|
11
41
|
describe('Timeout Handler', () => {
|
12
42
|
const { type, proxyConfig } = config.PROXY_CACHE_CONFIG
|
13
43
|
const proxyCache = createProxyCache(type, proxyConfig)
|
14
44
|
const proxyClient = new ProxyApiClient()
|
15
45
|
|
46
|
+
const checkKeysExistence = async (keys) => Promise.all(keys.map(key => proxyCache.redisClient.exists(key)))
|
47
|
+
|
16
48
|
beforeAll(async () => {
|
17
49
|
await proxyCache.connect()
|
18
50
|
const redisClient = proxyCache.redisClient
|
@@ -22,6 +54,11 @@ describe('Timeout Handler', () => {
|
|
22
54
|
}))
|
23
55
|
})
|
24
56
|
|
57
|
+
beforeEach(async () => {
|
58
|
+
const history = await proxyClient.deleteHistory()
|
59
|
+
expect(history).toEqual([])
|
60
|
+
})
|
61
|
+
|
25
62
|
afterAll(async () => {
|
26
63
|
return Promise.all([
|
27
64
|
proxyClient.deleteHistory(),
|
@@ -29,47 +66,65 @@ describe('Timeout Handler', () => {
|
|
29
66
|
])
|
30
67
|
})
|
31
68
|
|
32
|
-
it('
|
33
|
-
|
34
|
-
expect(history).toEqual([])
|
35
|
-
|
36
|
-
// send a couple of keys to redis
|
37
|
-
const partyIds = ['1234567', '7654321']
|
38
|
-
const keys = [
|
39
|
-
`'als:${PAYER_DFSP}:${PARTY_ID_TYPE}:${partyIds[0]}:expiresAt'`,
|
40
|
-
`'als:${PAYER_DFSP}:${PARTY_ID_TYPE}:${partyIds[1]}:expiresAt'`
|
41
|
-
]
|
69
|
+
it('should pass timeoutInterschemePartiesLookups flow', async () => {
|
70
|
+
const partyIds = [`isp1-${Date.now()}`, `isp2-${Date.now()}`]
|
42
71
|
const proxies = [PROXY_NAME]
|
43
72
|
const alsReq1 = fixtures.mockAlsRequestDto(PAYER_DFSP, PARTY_ID_TYPE, partyIds[0])
|
44
73
|
const alsReq2 = fixtures.mockAlsRequestDto(PAYER_DFSP, PARTY_ID_TYPE, partyIds[1])
|
74
|
+
const keys = [
|
75
|
+
RedisProxyCache.formatAlsCacheExpiryKey(alsReq1),
|
76
|
+
RedisProxyCache.formatAlsCacheExpiryKey(alsReq2)
|
77
|
+
]
|
78
|
+
// send a couple of keys to redis
|
45
79
|
const results = await Promise.all([
|
46
80
|
proxyCache.setSendToProxiesList(alsReq1, proxies, CRON_TIMEOUT_SEC),
|
47
81
|
proxyCache.setSendToProxiesList(alsReq2, proxies, CRON_TIMEOUT_SEC)
|
48
82
|
])
|
49
|
-
expect(results
|
83
|
+
expect(results).toEqual([true, true])
|
84
|
+
expect(await checkKeysExistence(keys)).toEqual([1, 1])
|
50
85
|
|
51
86
|
// wait for the timeout handler to process the keys
|
52
87
|
await wait(CRON_TIMEOUT_SEC * 1.5)
|
88
|
+
const history = await proxyClient.waitForNHistoryCalls(2)
|
53
89
|
|
54
90
|
// check that the keys are no longer in redis
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
// check that the callbacks are sent and received at the FSP
|
59
|
-
// for test resilience, we will retry the history check a few times
|
60
|
-
const retryMaxCount = 20
|
61
|
-
const retryIntervalSec = 2
|
62
|
-
let retryCount = 0
|
63
|
-
|
64
|
-
while (history.length < 2 && retryCount < retryMaxCount) {
|
65
|
-
await wait(retryIntervalSec)
|
66
|
-
history = await proxyClient.getHistory()
|
67
|
-
retryCount++
|
68
|
-
}
|
91
|
+
expect(await checkKeysExistence(keys)).toEqual([0, 0])
|
92
|
+
|
69
93
|
expect(history.length).toBe(2)
|
70
94
|
const path0 = history.find(h => h.path.includes(partyIds[0])).path
|
71
95
|
const path1 = history.find(h => h.path.includes(partyIds[1])).path
|
72
96
|
expect(path0).toBe(`/parties/${PARTY_ID_TYPE}/${partyIds[0]}/error`)
|
73
97
|
expect(path1).toBe(`/parties/${PARTY_ID_TYPE}/${partyIds[1]}/error`)
|
74
|
-
}
|
98
|
+
})
|
99
|
+
|
100
|
+
it('should pass timeoutProxyGetPartiesLookups flow', async () => {
|
101
|
+
const partyId1 = `pgp1-${Date.now()}`
|
102
|
+
const partyId2 = `pgp2-${Date.now()}`
|
103
|
+
const alsReq1 = fixtures.mockAlsRequestDto(PAYER_DFSP, PARTY_ID_TYPE, partyId1)
|
104
|
+
const alsReq2 = fixtures.mockAlsRequestDto(PAYER_DFSP, PARTY_ID_TYPE, partyId2)
|
105
|
+
const keys = [
|
106
|
+
RedisProxyCache.formatProxyGetPartiesExpiryKey(alsReq1, PROXY_NAME),
|
107
|
+
RedisProxyCache.formatProxyGetPartiesExpiryKey(alsReq2, PROXY_NAME)
|
108
|
+
]
|
109
|
+
// send a couple of keys to redis
|
110
|
+
const results = await Promise.all([
|
111
|
+
proxyCache.setProxyGetPartiesTimeout(alsReq1, PROXY_NAME, CRON_TIMEOUT_SEC),
|
112
|
+
proxyCache.setProxyGetPartiesTimeout(alsReq2, PROXY_NAME, CRON_TIMEOUT_SEC)
|
113
|
+
])
|
114
|
+
expect(results).toEqual([true, true])
|
115
|
+
expect(await checkKeysExistence(keys)).toEqual([1, 1])
|
116
|
+
|
117
|
+
// wait for the timeout handler to process the keys
|
118
|
+
await wait(CRON_TIMEOUT_SEC * 1.5)
|
119
|
+
const history = await proxyClient.waitForNHistoryCalls(2)
|
120
|
+
|
121
|
+
// check that the keys are no longer in redis
|
122
|
+
expect(await checkKeysExistence(keys)).toEqual([0, 0])
|
123
|
+
|
124
|
+
expect(history.length).toBe(2)
|
125
|
+
const path1 = history.find(h => h.path.includes(partyId1)).path
|
126
|
+
const path2 = history.find(h => h.path.includes(partyId2)).path
|
127
|
+
expect(path1).toBe(`/parties/${PARTY_ID_TYPE}/${partyId1}/error`)
|
128
|
+
expect(path2).toBe(`/parties/${PARTY_ID_TYPE}/${partyId2}/error`)
|
129
|
+
})
|
75
130
|
})
|
@@ -56,7 +56,7 @@ const fixtures = require('../../../fixtures')
|
|
56
56
|
const { type: proxyCacheType, proxyConfig: proxyCacheConfig } = Config.PROXY_CACHE_CONFIG
|
57
57
|
|
58
58
|
const { encodePayload } = Util.StreamingProtocol
|
59
|
-
const { RestMethods } = Enum.Http
|
59
|
+
const { RestMethods, Headers } = Enum.Http
|
60
60
|
|
61
61
|
Logger.isDebugEnabled = jest.fn(() => true)
|
62
62
|
Logger.isErrorEnabled = jest.fn(() => true)
|
@@ -192,24 +192,26 @@ describe('Parties Tests', () => {
|
|
192
192
|
expect(cached).toBe(proxy)
|
193
193
|
})
|
194
194
|
|
195
|
-
it('should
|
195
|
+
it('should cleanup oracle and trigger discovery flow, if destination is not in scheme and no dfsp-to-proxy mapping', async () => {
|
196
|
+
Config.PROXY_CACHE_CONFIG.enabled = true
|
196
197
|
participant.validateParticipant = sandbox.stub()
|
197
198
|
.onFirstCall().resolves({}) // source
|
198
199
|
.onSecondCall().resolves(null) // destination
|
199
200
|
participant.sendRequest = sandbox.stub().resolves()
|
200
201
|
participant.sendErrorToParticipant = sandbox.stub().resolves()
|
201
202
|
sandbox.stub(oracle, 'oracleRequest')
|
203
|
+
const proxy = 'some-proxy'
|
204
|
+
Util.proxies.getAllProxiesNames = sandbox.stub().resolves([proxy])
|
202
205
|
const headers = fixtures.partiesCallHeadersDto()
|
203
206
|
|
204
207
|
await partiesDomain.getPartiesByTypeAndID(headers, Helper.getByTypeIdRequest.params, Helper.getByTypeIdRequest.method, Helper.getByTypeIdRequest.query, Helper.mockSpan(), null, proxyCache)
|
205
208
|
|
206
|
-
expect(
|
207
|
-
expect(
|
208
|
-
expect(participant.
|
209
|
-
|
210
|
-
const
|
211
|
-
expect(
|
212
|
-
expect(errorInformation.errorDescription).toContain(ERROR_MESSAGES.partyDestinationFspNotFound)
|
209
|
+
expect(oracle.oracleRequest.lastCall.args[1]).toBe(RestMethods.DELETE)
|
210
|
+
expect(participant.sendErrorToParticipant.callCount).toBe(0)
|
211
|
+
expect(participant.sendRequest.callCount).toBe(1)
|
212
|
+
// eslint-disable-next-line no-unused-vars
|
213
|
+
const [_, sendTo] = participant.sendRequest.lastCall.args
|
214
|
+
expect(sendTo).toBe(proxy)
|
213
215
|
})
|
214
216
|
|
215
217
|
it('should send request to proxy, if destination is not in the scheme, but has proxyMapping', async () => {
|
@@ -470,7 +472,7 @@ describe('Parties Tests', () => {
|
|
470
472
|
expect(firstCallArgs[2]).toBe(expectedCallbackEnpointType)
|
471
473
|
})
|
472
474
|
|
473
|
-
it('should send
|
475
|
+
it('should send errorCallback if oracle returns external dfsp, and source is external', async () => {
|
474
476
|
Config.PROXY_CACHE_CONFIG.enabled = true
|
475
477
|
const proxyName = `proxy-${Date.now()}`
|
476
478
|
const fspId = `dfspNotFromScheme-${Date.now()}`
|
@@ -479,7 +481,7 @@ describe('Parties Tests', () => {
|
|
479
481
|
})
|
480
482
|
sandbox.stub(oracle, 'oracleRequest').resolves(oracleResponse)
|
481
483
|
participant.validateParticipant = sandbox.stub()
|
482
|
-
.onFirstCall().resolves(
|
484
|
+
.onFirstCall().resolves(null) // source
|
483
485
|
.onSecondCall().resolves(null) // oracle dfsp
|
484
486
|
participant.sendRequest = sandbox.stub().resolves()
|
485
487
|
participant.sendErrorToParticipant = sandbox.stub().resolves()
|
@@ -487,15 +489,20 @@ describe('Parties Tests', () => {
|
|
487
489
|
const isAdded = await proxyCache.addDfspIdToProxyMapping(fspId, proxyName)
|
488
490
|
expect(isAdded).toBe(true)
|
489
491
|
|
490
|
-
const
|
492
|
+
const source = `fromDfsp-${Date.now()}`
|
493
|
+
const headers = fixtures.partiesCallHeadersDto({ destination: '', source, proxy: 'proxy' })
|
491
494
|
const { params, method, query } = Helper.getByTypeIdRequest
|
492
495
|
|
493
496
|
await partiesDomain.getPartiesByTypeAndID(headers, params, method, query, null, null, proxyCache)
|
494
497
|
|
495
|
-
expect(participant.
|
496
|
-
expect(participant.
|
497
|
-
|
498
|
-
|
498
|
+
expect(participant.sendRequest.callCount).toBe(0)
|
499
|
+
expect(participant.sendErrorToParticipant.callCount).toBe(1)
|
500
|
+
// eslint-disable-next-line no-unused-vars
|
501
|
+
const [sentTo, _, payload, sentHeaders] = participant.sendErrorToParticipant.lastCall.args
|
502
|
+
expect(sentTo).toBe(source)
|
503
|
+
expect(payload.errorInformation.errorCode).toBe('3200')
|
504
|
+
expect(sentHeaders[Headers.FSPIOP.SOURCE]).toBe(Config.HUB_NAME)
|
505
|
+
expect(sentHeaders[Headers.FSPIOP.DESTINATION]).toBe(headers[Headers.FSPIOP.SOURCE])
|
499
506
|
})
|
500
507
|
|
501
508
|
it('handles error when `oracleRequest` returns no result', async () => {
|
@@ -554,13 +561,14 @@ describe('Parties Tests', () => {
|
|
554
561
|
participant.sendRequest = sandbox.stub().rejects(new Error('Some network issue'))
|
555
562
|
participant.sendErrorToParticipant = sandbox.stub().resolves()
|
556
563
|
const headers = fixtures.partiesCallHeadersDto({ destination: '' })
|
564
|
+
const params = fixtures.partiesParamsDto()
|
557
565
|
|
558
|
-
await partiesDomain.getPartiesByTypeAndID(headers,
|
566
|
+
await partiesDomain.getPartiesByTypeAndID(headers, params, Helper.getByTypeIdRequest.method, Helper.getByTypeIdRequest.query, Helper.mockSpan(), null, proxyCache)
|
559
567
|
|
560
568
|
expect(participant.sendRequest.callCount).toBe(proxyNames.length)
|
561
569
|
expect(participant.sendErrorToParticipant.callCount).toBe(1)
|
562
570
|
|
563
|
-
const { errorInformation } = participant.sendErrorToParticipant.
|
571
|
+
const { errorInformation } = participant.sendErrorToParticipant.lastCall.args[2]
|
564
572
|
expect(errorInformation.errorCode).toBe('3200')
|
565
573
|
expect(errorInformation.errorDescription).toContain(ERROR_MESSAGES.proxyConnectionError)
|
566
574
|
})
|
@@ -0,0 +1,51 @@
|
|
1
|
+
/*****
|
2
|
+
License
|
3
|
+
--------------
|
4
|
+
Copyright © 2020-2025 Mojaloop Foundation
|
5
|
+
The Mojaloop files are made available by the Mojaloop Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at
|
6
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
7
|
+
Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
8
|
+
|
9
|
+
Contributors
|
10
|
+
--------------
|
11
|
+
This is the official list of the Mojaloop project contributors for this file.
|
12
|
+
Names of the original copyright holders (individuals or organizations)
|
13
|
+
should be listed with a '*' in the first column. People who have
|
14
|
+
contributed from an organization can be listed under the organization
|
15
|
+
that actually holds the copyright for their contributions (see the
|
16
|
+
Mojaloop Foundation organization for an example). Those individuals should have
|
17
|
+
their names indented and be marked with a '-'. Email address can be added
|
18
|
+
optionally within square brackets <email>.
|
19
|
+
* Mojaloop Foundation
|
20
|
+
- Name Surname <name.surname@mojaloop.io>
|
21
|
+
|
22
|
+
* Eugen Klymniuk <eugen.klymniuk@infitx.com>
|
23
|
+
--------------
|
24
|
+
**********/
|
25
|
+
|
26
|
+
const ErrorHandler = require('@mojaloop/central-services-error-handling')
|
27
|
+
const partiesUtils = require('#src/domain/parties/partiesUtils')
|
28
|
+
const config = require('#src/lib/config')
|
29
|
+
const { API_TYPES } = require('#src/constants')
|
30
|
+
const fixtures = require('#test/fixtures/index')
|
31
|
+
|
32
|
+
describe('partiesUtils Tests -->', () => {
|
33
|
+
describe('makePutPartiesErrorPayload Tests', () => {
|
34
|
+
const error = ErrorHandler.Factory.reformatFSPIOPError(new Error('Test Error'))
|
35
|
+
const ERR_CODE = '2001'
|
36
|
+
const headers = fixtures.partiesCallHeadersDto()
|
37
|
+
const params = fixtures.partiesParamsDto()
|
38
|
+
|
39
|
+
test('should make putParties error payload in FSPIOP format', async () => {
|
40
|
+
const fspiopConfig = { ...config, API_TYPE: API_TYPES.fspiop }
|
41
|
+
const payload = await partiesUtils.makePutPartiesErrorPayload(fspiopConfig, error, headers, params)
|
42
|
+
expect(payload.errorInformation.errorCode).toBe(ERR_CODE)
|
43
|
+
})
|
44
|
+
|
45
|
+
test('should make putParties error payload in ISO20022 format', async () => {
|
46
|
+
const fspiopConfig = { ...config, API_TYPE: API_TYPES.iso20022 }
|
47
|
+
const payload = await partiesUtils.makePutPartiesErrorPayload(fspiopConfig, error, headers, params)
|
48
|
+
expect(payload.Rpt.Rsn.Cd).toBe(ERR_CODE)
|
49
|
+
})
|
50
|
+
})
|
51
|
+
})
|
@@ -0,0 +1,71 @@
|
|
1
|
+
/*****
|
2
|
+
License
|
3
|
+
--------------
|
4
|
+
Copyright © 2020-2025 Mojaloop Foundation
|
5
|
+
The Mojaloop files are made available by the Mojaloop Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
10
|
+
|
11
|
+
Contributors
|
12
|
+
--------------
|
13
|
+
This is the official list of the Mojaloop project contributors for this file.
|
14
|
+
Names of the original copyright holders (individuals or organizations)
|
15
|
+
should be listed with a '*' in the first column. People who have
|
16
|
+
contributed from an organization can be listed under the organization
|
17
|
+
that actually holds the copyright for their contributions (see the
|
18
|
+
Mojaloop Foundation for an example). Those individuals should have
|
19
|
+
their names indented and be marked with a '-'. Email address can be added
|
20
|
+
optionally within square brackets <email>.
|
21
|
+
|
22
|
+
* Mojaloop Foundation
|
23
|
+
* Eugen Klymniuk <eugen.klymniuk@infitx.com>
|
24
|
+
|
25
|
+
--------------
|
26
|
+
******/
|
27
|
+
|
28
|
+
const { createMockDeps, participantMock } = require('./deps')
|
29
|
+
// ↑ should be first require to mock external deps ↑
|
30
|
+
const BasePartiesService = require('#src/domain/parties/services/BasePartiesService')
|
31
|
+
const config = require('#src/lib/config')
|
32
|
+
const { API_TYPES } = require('#src/constants')
|
33
|
+
const fixtures = require('#test/fixtures/index')
|
34
|
+
|
35
|
+
describe('BasePartiesService Tests -->', () => {
|
36
|
+
beforeEach(() => {
|
37
|
+
jest.clearAllMocks()
|
38
|
+
})
|
39
|
+
|
40
|
+
test('should send error party callback in ISO20022 format', async () => {
|
41
|
+
const deps = {
|
42
|
+
...createMockDeps(),
|
43
|
+
config: { ...config, API_TYPE: API_TYPES.iso20022 }
|
44
|
+
}
|
45
|
+
const source = 'sourceFsp'
|
46
|
+
const headers = fixtures.partiesCallHeadersDto({ source })
|
47
|
+
const params = fixtures.partiesParamsDto()
|
48
|
+
const service = new BasePartiesService(deps, { headers, params })
|
49
|
+
|
50
|
+
await service.handleError(new Error('test error'))
|
51
|
+
expect(participantMock.sendErrorToParticipant).toHaveBeenCalledTimes(1)
|
52
|
+
// eslint-disable-next-line no-unused-vars
|
53
|
+
const [sentTo, _, payload] = participantMock.sendErrorToParticipant.mock.lastCall
|
54
|
+
expect(sentTo).toBe(source)
|
55
|
+
expect(payload.Rpt.Rsn.Cd).toBe('2001')
|
56
|
+
expect(payload.Rpt.OrgnlId).toBe(`${params.Type}/${params.ID}`)
|
57
|
+
expect(payload.Assgnmt.Assgnr.Agt.FinInstnId.Othr.Id).toBe(source)
|
58
|
+
})
|
59
|
+
|
60
|
+
test('should remove proxy getParties timeout cache key', async () => {
|
61
|
+
const deps = createMockDeps()
|
62
|
+
const proxy = 'proxyAB'
|
63
|
+
const headers = fixtures.partiesCallHeadersDto({ proxy })
|
64
|
+
const params = fixtures.partiesParamsDto()
|
65
|
+
const alsReq = {}
|
66
|
+
const service = new BasePartiesService(deps, { headers, params })
|
67
|
+
|
68
|
+
await service.removeProxyGetPartiesTimeoutCache(alsReq)
|
69
|
+
expect(deps.proxyCache.removeProxyGetPartiesTimeout).toHaveBeenCalledWith(alsReq, proxy)
|
70
|
+
})
|
71
|
+
})
|