account-lookup-service 17.8.0-snapshot.10 → 17.8.0-snapshot.12
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
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.12",
|
5
5
|
"license": "Apache-2.0",
|
6
6
|
"author": "ModusBox",
|
7
7
|
"contributors": [
|
@@ -92,9 +92,9 @@
|
|
92
92
|
"@hapi/vision": "7.0.3",
|
93
93
|
"@mojaloop/central-services-error-handling": "13.0.7",
|
94
94
|
"@mojaloop/central-services-health": "15.0.4",
|
95
|
-
"@mojaloop/central-services-logger": "11.8.
|
95
|
+
"@mojaloop/central-services-logger": "11.8.1",
|
96
96
|
"@mojaloop/central-services-metrics": "12.5.0",
|
97
|
-
"@mojaloop/central-services-shared": "18.23.
|
97
|
+
"@mojaloop/central-services-shared": "18.23.2",
|
98
98
|
"@mojaloop/central-services-stream": "11.5.2",
|
99
99
|
"@mojaloop/database-lib": "11.1.4",
|
100
100
|
"@mojaloop/event-sdk": "14.4.0",
|
@@ -106,7 +106,7 @@
|
|
106
106
|
"ajv-keywords": "5.1.0",
|
107
107
|
"blipp": "4.0.2",
|
108
108
|
"commander": "13.1.0",
|
109
|
-
"cron": "4.1.
|
109
|
+
"cron": "4.1.3",
|
110
110
|
"fast-safe-stringify": "^2.1.1",
|
111
111
|
"hapi-auth-bearer-token": "8.0.0",
|
112
112
|
"joi": "17.13.3",
|
@@ -100,16 +100,17 @@ class BasePartiesService {
|
|
100
100
|
get state () { return this.#state }
|
101
101
|
|
102
102
|
async handleError (error) {
|
103
|
-
const {
|
103
|
+
const { params } = this.inputs
|
104
104
|
const log = this.log.child({ method: 'handleError' })
|
105
105
|
try {
|
106
106
|
log.error('error in processing parties request: ', error)
|
107
107
|
const fspiopError = ErrorHandler.Factory.reformatFSPIOPError(error)
|
108
|
-
const
|
108
|
+
const callbackHeaders = BasePartiesService.createErrorCallbackHeaders(this.inputs.headers, params)
|
109
|
+
const errorInfo = await this.deps.partiesUtils.makePutPartiesErrorPayload(this.deps.config, fspiopError, callbackHeaders, params)
|
109
110
|
|
110
111
|
await this.sendErrorCallback({
|
111
112
|
errorInfo,
|
112
|
-
headers:
|
113
|
+
headers: callbackHeaders,
|
113
114
|
params
|
114
115
|
})
|
115
116
|
log.info('handleError in done')
|
package/src/server.js
CHANGED
@@ -45,7 +45,18 @@ const OracleEndpointCache = require('./models/oracle/oracleEndpointCached')
|
|
45
45
|
const Handlers = require('./handlers/register')
|
46
46
|
|
47
47
|
const connectDatabase = async (dbConfig) => {
|
48
|
-
|
48
|
+
await Db.connect(dbConfig)
|
49
|
+
logger.info('Database connected')
|
50
|
+
}
|
51
|
+
|
52
|
+
const initOpenApiBackend = async ({ isAdmin }) => {
|
53
|
+
const OpenAPISpecPath = Util.pathForInterface({ isAdmin, isMockInterface: false })
|
54
|
+
const apiHandlers = isAdmin
|
55
|
+
? APIHandlers.AdminHandlers
|
56
|
+
: APIHandlers.ApiHandlers
|
57
|
+
const api = await OpenapiBackend.initialise(OpenAPISpecPath, apiHandlers)
|
58
|
+
logger.verbose('OpenAPI Backend initialized', { isAdmin })
|
59
|
+
return api
|
49
60
|
}
|
50
61
|
|
51
62
|
const migrate = async () => {
|
@@ -132,8 +143,7 @@ const initializeApi = async (appConfig) => {
|
|
132
143
|
initializeInstrumentation(INSTRUMENTATION_METRICS_CONFIG)
|
133
144
|
}
|
134
145
|
await connectDatabase(DATABASE)
|
135
|
-
const
|
136
|
-
const api = await OpenapiBackend.initialise(OpenAPISpecPath, APIHandlers.ApiHandlers)
|
146
|
+
const api = await initOpenApiBackend({ isAdmin: false })
|
137
147
|
|
138
148
|
await Promise.all([
|
139
149
|
Endpoints.initializeCache(CENTRAL_SHARED_ENDPOINT_CACHE_CONFIG, Util.hubNameConfig),
|
@@ -142,6 +152,7 @@ const initializeApi = async (appConfig) => {
|
|
142
152
|
OracleEndpointCache.initialize(),
|
143
153
|
Cache.initCache()
|
144
154
|
])
|
155
|
+
logger.verbose('all caches initialized')
|
145
156
|
|
146
157
|
return createServer(API_PORT, api, Routes.APIRoutes(api), false, PROXY_CACHE_CONFIG)
|
147
158
|
}
|
@@ -161,8 +172,8 @@ const initializeAdmin = async (appConfig) => {
|
|
161
172
|
}
|
162
173
|
await connectDatabase(DATABASE)
|
163
174
|
RUN_MIGRATIONS && await migrate()
|
164
|
-
const
|
165
|
-
|
175
|
+
const api = await initOpenApiBackend({ isAdmin: true })
|
176
|
+
|
166
177
|
await Promise.all([
|
167
178
|
OracleEndpointCache.initialize(),
|
168
179
|
Cache.initCache()
|
@@ -54,7 +54,8 @@ describe('BasePartiesService Tests -->', () => {
|
|
54
54
|
expect(sentTo).toBe(source)
|
55
55
|
expect(payload.Rpt.Rsn.Cd).toBe('2001')
|
56
56
|
expect(payload.Rpt.OrgnlId).toBe(`${params.Type}/${params.ID}`)
|
57
|
-
expect(payload.Assgnmt.
|
57
|
+
expect(payload.Assgnmt.Assgne.Agt.FinInstnId.Othr.Id).toBe(source)
|
58
|
+
expect(payload.Assgnmt.Assgnr.Agt.FinInstnId.Othr.Id).toBe(config.HUB_NAME)
|
58
59
|
})
|
59
60
|
|
60
61
|
test('should remove proxy getParties timeout cache key', async () => {
|
@@ -199,15 +199,18 @@ describe('GetPartiesService Tests -->', () => {
|
|
199
199
|
expect(participantMock.sendRequest.mock.lastCall[1]).toBe(proxyOk)
|
200
200
|
})
|
201
201
|
|
202
|
-
|
203
|
-
expect.assertions(1)
|
202
|
+
const throwDelayedErrorOnNthCall = (N, delay = 1000, error = new Error('Nth call Delayed Error')) => {
|
204
203
|
let count = 0
|
205
|
-
|
204
|
+
return async () => {
|
206
205
|
count++
|
207
|
-
if (count !==
|
208
|
-
await sleep(1000)
|
209
|
-
throw
|
210
|
-
}
|
206
|
+
if (count !== N) return {}
|
207
|
+
await sleep(1000)
|
208
|
+
throw error
|
209
|
+
}
|
210
|
+
}
|
211
|
+
|
212
|
+
const prepareGetPartiesServiceForDelayedProxyError = () => {
|
213
|
+
participantMock.sendRequest = jest.fn(throwDelayedErrorOnNthCall(2)) // throw error on 2nd proxy call
|
211
214
|
const proxies = createProxiesUtilMock({
|
212
215
|
getAllProxiesNames: jest.fn().mockResolvedValue(['proxy1', 'proxy2'])
|
213
216
|
})
|
@@ -215,14 +218,31 @@ describe('GetPartiesService Tests -->', () => {
|
|
215
218
|
receivedErrorResponse: jest.fn().mockResolvedValue(true) // failed proxy request is last in inter-scheme discovery flow
|
216
219
|
})
|
217
220
|
const deps = createMockDeps({ proxies, proxyCache })
|
218
|
-
|
219
221
|
const headers = fixtures.partiesCallHeadersDto({ destination: '' })
|
220
222
|
const params = fixtures.partiesParamsDto()
|
221
|
-
|
223
|
+
|
224
|
+
return new GetPartiesService(deps, { headers, params })
|
225
|
+
}
|
226
|
+
|
227
|
+
test('should throw an error if proxyRequest failed after delay, and other proxies have already replied', async () => {
|
228
|
+
expect.assertions(1)
|
229
|
+
const service = prepareGetPartiesServiceForDelayedProxyError()
|
230
|
+
const { headers } = service.inputs
|
222
231
|
|
223
232
|
await expect(service.triggerInterSchemeDiscoveryFlow(headers))
|
224
233
|
.rejects.toThrow(ERROR_MESSAGES.noSuccessfulProxyDiscoveryResponses)
|
225
234
|
})
|
235
|
+
|
236
|
+
test('should send error callback in ISO format if proxyRequest failed after delay, and other proxies have already replied', async () => {
|
237
|
+
const service = prepareGetPartiesServiceForDelayedProxyError()
|
238
|
+
const { headers } = service.inputs
|
239
|
+
service.deps.config.API_TYPE = API_TYPES.iso20022
|
240
|
+
|
241
|
+
await service.triggerInterSchemeDiscoveryFlow(headers)
|
242
|
+
.catch(err => service.handleError(err))
|
243
|
+
expect(participantMock.sendErrorToParticipant).toHaveBeenCalledTimes(1)
|
244
|
+
expect(participantMock.sendErrorToParticipant.mock.lastCall[2].Rpt.Rsn.Cd).toBe('3200')
|
245
|
+
})
|
226
246
|
})
|
227
247
|
|
228
248
|
describe('setProxyGetPartiesTimeout Tests', () => {
|