account-lookup-service 17.8.0-snapshot.18 → 17.8.0-snapshot.19
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/package.json +1 -1
- package/src/domain/parties/services/BasePartiesService.js +8 -3
- package/src/domain/parties/services/PutPartiesErrorService.js +19 -4
- package/src/handlers/index.js +3 -3
- package/test/unit/domain/parties/parties.test.js +3 -3
- package/test/unit/domain/parties/services/PutPartiesErrorService.test.js +10 -10
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "account-lookup-service",
|
3
3
|
"description": "Account Lookup Service is used to validate Party and Participant lookups.",
|
4
|
-
"version": "17.8.0-snapshot.
|
4
|
+
"version": "17.8.0-snapshot.19",
|
5
5
|
"license": "Apache-2.0",
|
6
6
|
"author": "ModusBox",
|
7
7
|
"contributors": [
|
@@ -156,7 +156,7 @@ class BasePartiesService {
|
|
156
156
|
|
157
157
|
async sendErrorCallback ({ errorInfo, headers, params }) {
|
158
158
|
this.stepInProgress('sendErrorCallback')
|
159
|
-
const sendTo = this.state.requester || this.state.source
|
159
|
+
const sendTo = this.state.requester || headers[Headers.FSPIOP.DESTINATION] /* || this.state.source */
|
160
160
|
const endpointType = this.deps.partiesUtils.errorPartyCbType(params.SubId)
|
161
161
|
|
162
162
|
await this.deps.participant.sendErrorToParticipant(
|
@@ -171,6 +171,7 @@ class BasePartiesService {
|
|
171
171
|
}
|
172
172
|
|
173
173
|
async removeProxyGetPartiesTimeoutCache (alsReq) {
|
174
|
+
this.stepInProgress('removeProxyGetPartiesTimeoutCache')
|
174
175
|
const isRemoved = await this.deps.proxyCache.removeProxyGetPartiesTimeout(alsReq, this.state.proxy)
|
175
176
|
this.log.debug('removeProxyGetPartiesTimeoutCache is done', { isRemoved, alsReq })
|
176
177
|
return isRemoved
|
@@ -230,8 +231,8 @@ class BasePartiesService {
|
|
230
231
|
}
|
231
232
|
}
|
232
233
|
|
233
|
-
static createErrorCallbackHeaders (headers, params) {
|
234
|
-
|
234
|
+
static createErrorCallbackHeaders (headers, params, overrideDestination = '') {
|
235
|
+
const cbHeaders = createCallbackHeaders({
|
235
236
|
requestHeaders: headers,
|
236
237
|
partyIdType: params.Type,
|
237
238
|
partyIdentifier: params.ID,
|
@@ -239,6 +240,10 @@ class BasePartiesService {
|
|
239
240
|
? FspEndpointTemplates.PARTIES_SUB_ID_PUT_ERROR
|
240
241
|
: FspEndpointTemplates.PARTIES_PUT_ERROR
|
241
242
|
})
|
243
|
+
if (overrideDestination) {
|
244
|
+
cbHeaders[Headers.FSPIOP.DESTINATION] = overrideDestination
|
245
|
+
}
|
246
|
+
return cbHeaders
|
242
247
|
}
|
243
248
|
|
244
249
|
static createHubErrorCallbackHeaders (hubName, destination) {
|
@@ -43,16 +43,16 @@ class PutPartiesErrorService extends BasePartiesService {
|
|
43
43
|
} else {
|
44
44
|
const schemeParticipant = await this.validateParticipant(this.state.destination)
|
45
45
|
if (schemeParticipant) {
|
46
|
-
|
47
|
-
this.log.info('Need to cleanup oracle and throw SERVICE_CURRENTLY_UNAVAILABLE error')
|
46
|
+
this.log.info('Need to cleanup oracle and forward SERVICE_CURRENTLY_UNAVAILABLE error')
|
48
47
|
await this.cleanupOracle()
|
49
48
|
await this.removeProxyGetPartiesTimeoutCache(alsReq)
|
50
|
-
|
49
|
+
await this.forwardServiceUnavailableErrorCallback()
|
50
|
+
return
|
51
51
|
}
|
52
52
|
}
|
53
53
|
}
|
54
54
|
|
55
|
-
await
|
55
|
+
await super.identifyDestinationForCallback()
|
56
56
|
await this.sendErrorCallbackToParticipant()
|
57
57
|
this.log.info('handleRequest is done')
|
58
58
|
}
|
@@ -78,6 +78,21 @@ class PutPartiesErrorService extends BasePartiesService {
|
|
78
78
|
const errorInfo = PutPartiesErrorService.decodeDataUriPayload(dataUri)
|
79
79
|
return super.sendErrorCallback({ errorInfo, headers, params })
|
80
80
|
}
|
81
|
+
|
82
|
+
async forwardServiceUnavailableErrorCallback () {
|
83
|
+
this.stepInProgress('forwardServiceUnavailableErrorCallback')
|
84
|
+
const { headers, params } = this.inputs
|
85
|
+
const error = super.createFspiopServiceUnavailableError(ERROR_MESSAGES.externalPartyError)
|
86
|
+
const callbackHeaders = BasePartiesService.createErrorCallbackHeaders(headers, params, this.state.destination)
|
87
|
+
const errorInfo = await this.deps.partiesUtils.makePutPartiesErrorPayload(this.deps.config, error, callbackHeaders, params)
|
88
|
+
|
89
|
+
await super.sendErrorCallback({
|
90
|
+
errorInfo,
|
91
|
+
headers: callbackHeaders,
|
92
|
+
params
|
93
|
+
})
|
94
|
+
this.log.verbose('#forwardServiceUnavailableErrorCallback is done', { callbackHeaders, errorInfo })
|
95
|
+
}
|
81
96
|
}
|
82
97
|
|
83
98
|
module.exports = PutPartiesErrorService
|
package/src/handlers/index.js
CHANGED
@@ -38,12 +38,12 @@ const { HANDLER_TYPES } = require('../constants')
|
|
38
38
|
const Config = require('../lib/config')
|
39
39
|
const log = require('../lib').logger.child('ALS-timeout-handler')
|
40
40
|
|
41
|
-
process.on('
|
42
|
-
log.error(`uncaughtException: ${
|
41
|
+
process.on('uncaughtException', (err, origin) => {
|
42
|
+
log.error(`uncaughtException event [origin: ${origin}]: `, err)
|
43
43
|
process.exit(2)
|
44
44
|
})
|
45
45
|
process.on('unhandledRejection', (err) => {
|
46
|
-
log.error(
|
46
|
+
log.error('unhandledRejection event: ', err)
|
47
47
|
process.exit(3)
|
48
48
|
})
|
49
49
|
|
@@ -931,9 +931,9 @@ describe('Parties Tests', () => {
|
|
931
931
|
Config.PROXY_CACHE_CONFIG.enabled = true
|
932
932
|
const errorCode = MojaloopApiErrorCodes.PAYEE_IDENTIFIER_NOT_VALID.code
|
933
933
|
const payload = fixtures.errorCallbackResponseDto({ errorCode })
|
934
|
-
const
|
934
|
+
const destination = `dest-${Date.now()}`
|
935
935
|
const proxy = `proxy-${Date.now()}`
|
936
|
-
const headers = fixtures.partiesCallHeadersDto({
|
936
|
+
const headers = fixtures.partiesCallHeadersDto({ destination, proxy })
|
937
937
|
const { params } = Helper.putByTypeIdRequest
|
938
938
|
participant.validateParticipant = sandbox.stub().resolves({})
|
939
939
|
participant.sendRequest = sandbox.stub().resolves()
|
@@ -951,7 +951,7 @@ describe('Parties Tests', () => {
|
|
951
951
|
expect(participant.sendErrorToParticipant.callCount).toBe(1)
|
952
952
|
// eslint-disable-next-line no-unused-vars
|
953
953
|
const [sentTo, _, data] = participant.sendErrorToParticipant.lastCall.args
|
954
|
-
expect(sentTo).toBe(
|
954
|
+
expect(sentTo).toBe(destination)
|
955
955
|
expect(data.errorInformation.errorCode).toBe('2003')
|
956
956
|
})
|
957
957
|
})
|
@@ -29,7 +29,6 @@ const { createMockDeps, oracleMock, participantMock } = require('./deps')
|
|
29
29
|
// ↑ should be first require to mock external deps ↑
|
30
30
|
const { PutPartiesErrorService } = require('#src/domain/parties/services/index')
|
31
31
|
const fixtures = require('#test/fixtures/index')
|
32
|
-
const { ERROR_MESSAGES } = require('#src/constants')
|
33
32
|
|
34
33
|
const { RestMethods } = PutPartiesErrorService.enums()
|
35
34
|
|
@@ -38,21 +37,22 @@ describe('PutPartiesErrorService Tests -->', () => {
|
|
38
37
|
jest.clearAllMocks()
|
39
38
|
})
|
40
39
|
|
41
|
-
test('should cleanup oracle and
|
42
|
-
expect.hasAssertions()
|
40
|
+
test('should cleanup oracle and forward SERVICE_CURRENTLY_UNAVAILABLE error for party from external dfsp', async () => {
|
43
41
|
participantMock.validateParticipant = jest.fn().mockResolvedValue({})
|
44
|
-
const
|
42
|
+
const destination = 'destFsp'
|
43
|
+
const headers = fixtures.partiesCallHeadersDto({ destination, proxy: 'proxyA' })
|
45
44
|
const params = fixtures.partiesParamsDto()
|
46
45
|
const dataUri = fixtures.dataUriDto()
|
47
46
|
const service = new PutPartiesErrorService(createMockDeps(), { headers, params, dataUri })
|
48
47
|
|
49
48
|
await service.handleRequest()
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
49
|
+
expect(oracleMock.oracleRequest).toHaveBeenCalledTimes(1)
|
50
|
+
expect(oracleMock.oracleRequest.mock.lastCall[1]).toBe(RestMethods.DELETE)
|
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(destination)
|
55
|
+
expect(payload.errorInformation.errorCode).toBe('2003')
|
56
56
|
})
|
57
57
|
|
58
58
|
test('should NOT cleanup oracle if destination is external', async () => {
|