account-lookup-service 17.8.0-snapshot.6 → 17.8.0-snapshot.7

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.6",
4
+ "version": "17.8.0-snapshot.7",
5
5
  "license": "Apache-2.0",
6
6
  "author": "ModusBox",
7
7
  "contributors": [
@@ -99,8 +99,8 @@
99
99
  "@mojaloop/database-lib": "11.1.4",
100
100
  "@mojaloop/event-sdk": "14.4.0",
101
101
  "@mojaloop/inter-scheme-proxy-cache-lib": "2.4.0",
102
- "@mojaloop/ml-schema-transformer-lib": "2.6.0",
103
- "@mojaloop/sdk-standard-components": "19.11.1",
102
+ "@mojaloop/ml-schema-transformer-lib": "2.7.0",
103
+ "@mojaloop/sdk-standard-components": "19.11.2",
104
104
  "@now-ims/hapi-now-auth": "2.1.0",
105
105
  "ajv": "8.17.1",
106
106
  "ajv-keywords": "5.1.0",
@@ -25,7 +25,7 @@
25
25
  --------------
26
26
  ******/
27
27
 
28
- const { proxies } = require('@mojaloop/central-services-shared').Util
28
+ const { Util } = require('@mojaloop/central-services-shared')
29
29
  const { logger } = require('../../lib')
30
30
  const config = require('../../lib/config')
31
31
  const oracle = require('../../models/oracle/facade')
@@ -33,7 +33,13 @@ const participant = require('../../models/participantEndpoint/facade')
33
33
  const partiesUtils = require('./partiesUtils')
34
34
 
35
35
  /** @returns {PartiesDeps} */
36
- const createDeps = ({ cache, proxyCache, childSpan, log = logger }) => Object.freeze({
36
+ const createDeps = ({
37
+ cache,
38
+ proxyCache,
39
+ proxies = Util.proxies,
40
+ childSpan = null,
41
+ log = logger
42
+ }) => Object.freeze({
37
43
  cache,
38
44
  proxyCache,
39
45
  childSpan,
@@ -162,6 +162,7 @@ class GetPartiesService extends BasePartiesService {
162
162
  const isOk = results.some(result => result.status === 'fulfilled')
163
163
  // If, at least, one request is sent to proxy, we treat the whole flow as successful.
164
164
  // Failed requests should be handled by TTL expired/timeout handler
165
+ // todo: If forwarding request to proxy failed, remove the proxy from setSendToProxiesList
165
166
  log.info('triggerInterSchemeDiscoveryFlow is done:', { isOk, results, proxyNames, alsReq })
166
167
  this.stepInProgress('allSent-12')
167
168
 
@@ -245,11 +246,15 @@ class GetPartiesService extends BasePartiesService {
245
246
 
246
247
  async #sendPartyNotFoundErrorCallback (headers) {
247
248
  const { params } = this.inputs
249
+ const callbackHeaders = GetPartiesService.createErrorCallbackHeaders(headers, params)
248
250
  const fspiopError = super.createFspiopIdNotFoundError('No proxy found to start inter-scheme discovery flow')
251
+ const errorInfo = await this.deps.partiesUtils.makePutPartiesErrorPayload(
252
+ this.deps.config, fspiopError, callbackHeaders, params
253
+ )
249
254
 
250
255
  await this.sendErrorCallback({
251
- errorInfo: fspiopError.toApiErrorObject(this.deps.config.ERROR_HANDLING),
252
- headers: GetPartiesService.createErrorCallbackHeaders(headers, params),
256
+ errorInfo,
257
+ headers: callbackHeaders,
253
258
  params
254
259
  })
255
260
  return fspiopError
@@ -30,6 +30,7 @@ const { ERROR_MESSAGES } = require('../../../constants')
30
30
  const BasePartiesService = require('./BasePartiesService')
31
31
 
32
32
  class PutPartiesErrorService extends BasePartiesService {
33
+ /** @returns {Promise<true | undefined>} - If true, need to trigger inter-scheme discovery. */
33
34
  async handleRequest () {
34
35
  if (this.state.proxyEnabled && this.state.proxy) {
35
36
  const alsReq = this.deps.partiesUtils.alsRequestDto(this.state.destination, this.inputs.params) // or source?
@@ -48,7 +48,7 @@ describe('BasePartiesService Tests -->', () => {
48
48
  const service = new BasePartiesService(deps, { headers, params })
49
49
 
50
50
  await service.handleError(new Error('test error'))
51
- expect(participantMock.sendErrorToParticipant.mock.calls.length).toBe(1)
51
+ expect(participantMock.sendErrorToParticipant).toHaveBeenCalledTimes(1)
52
52
  // eslint-disable-next-line no-unused-vars
53
53
  const [sentTo, _, payload] = participantMock.sendErrorToParticipant.mock.lastCall
54
54
  expect(sentTo).toBe(source)
@@ -28,11 +28,14 @@
28
28
  const { createMockDeps, createProxyCacheMock, oracleMock, participantMock } = require('./deps')
29
29
  // ↑ should be first require to mock external deps ↑
30
30
  const { GetPartiesService } = require('#src/domain/parties/services/index')
31
+ const { API_TYPES } = require('#src/constants')
31
32
  const fixtures = require('#test/fixtures/index')
32
33
 
33
34
  const { RestMethods, Headers } = GetPartiesService.enums()
34
35
 
35
36
  describe('GetPartiesService Tests -->', () => {
37
+ const { config } = createMockDeps()
38
+
36
39
  beforeEach(() => {
37
40
  jest.clearAllMocks()
38
41
  })
@@ -221,4 +224,22 @@ describe('GetPartiesService Tests -->', () => {
221
224
  expect(participantMock.sendRequest).toHaveBeenCalledTimes(1)
222
225
  })
223
226
  })
227
+
228
+ test('should send partyNotFound callback in ISO20022 format', async () => {
229
+ participantMock.validateParticipant = jest.fn().mockResolvedValue({})
230
+ oracleMock.oracleRequest = jest.fn()
231
+ const deps = {
232
+ ...createMockDeps(),
233
+ config: { ...config, API_TYPE: API_TYPES.iso20022 }
234
+ }
235
+ const headers = fixtures.partiesCallHeadersDto({ destination: '' })
236
+ const params = fixtures.partiesParamsDto()
237
+ const service = new GetPartiesService(deps, { headers, params })
238
+
239
+ await service.handleRequest()
240
+ expect(participantMock.sendErrorToParticipant).toHaveBeenCalledTimes(1)
241
+ const isoPayload = participantMock.sendErrorToParticipant.mock.lastCall[2]
242
+ expect(isoPayload.Assgnmt).toBeDefined()
243
+ expect(isoPayload.Rpt).toBeDefined()
244
+ })
224
245
  })
@@ -32,18 +32,20 @@ const oracleMock = require('#src/models/oracle/facade')
32
32
  const participantMock = require('#src/models/participantEndpoint/facade')
33
33
  const { createDeps } = require('#src/domain/parties/deps')
34
34
  const { logger } = require('#src/lib/index')
35
- const { createProxyCacheMock } = require('#test/util/mockDeps')
35
+ const { createProxyCacheMock, createProxiesUtilMock } = require('#test/util/mockDeps')
36
36
 
37
37
  /** @returns {PartiesDeps} */
38
38
  const createMockDeps = ({
39
39
  proxyCache = createProxyCacheMock(),
40
+ proxies = createProxiesUtilMock(),
40
41
  log = logger.child({ test: true }),
41
42
  cache
42
- } = {}) => createDeps({ cache, proxyCache, log })
43
+ } = {}) => createDeps({ cache, proxyCache, proxies, log })
43
44
 
44
45
  module.exports = {
45
46
  createMockDeps,
46
47
  createProxyCacheMock,
48
+ createProxiesUtilMock,
47
49
  oracleMock,
48
50
  participantMock
49
51
  }
@@ -56,6 +56,17 @@ const createProxyCacheMock = ({
56
56
  setSendToProxiesList
57
57
  })
58
58
 
59
+ // @mojaloop/central-services-shared/Util/proxies
60
+ /** @returns {Proxies} */
61
+ const createProxiesUtilMock = ({
62
+ getAllProxiesNames = jest.fn().mockResolvedValue([]),
63
+ invalidateProxiesCache = jest.fn()
64
+ } = {}) => ({
65
+ getAllProxiesNames,
66
+ invalidateProxiesCache
67
+ })
68
+
59
69
  module.exports = {
60
- createProxyCacheMock
70
+ createProxyCacheMock,
71
+ createProxiesUtilMock
61
72
  }