account-lookup-service 15.6.0-snapshot.0 → 15.6.0-snapshot.1

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/.ncurc.yaml CHANGED
@@ -1,6 +1,5 @@
1
1
  ## Add a TODO comment indicating the reason for each rejected dependency upgrade added to this list, and what should be done to resolve it (i.e. handle it through a story, etc).
2
2
  reject: [
3
3
  # TODO: v6+ (ref: https://github.com/sindresorhus/get-port/releases/tag/v6.0.0) is an ESM library and thus not compatible with CommonJS. Future story needed to resolve.
4
- "get-port",
5
- "@mojaloop/sdk-standard-components" ## version 19.1.0 caused lots of failed unit tests with the error - TypeError: Cannot read properties of undefined (reading 'createFSPIOPError')
4
+ "get-port"
6
5
  ]
package/audit-ci.jsonc CHANGED
@@ -27,6 +27,7 @@
27
27
  "GHSA-7fh5-64p2-3v2j",
28
28
  "GHSA-rm97-x556-q36h", // https://github.com/advisories/GHSA-rm97-x556-q36h
29
29
  "GHSA-rv95-896h-c2vc", // https://github.com/advisories/GHSA-rv95-896h-c2vc
30
- "GHSA-952p-6rrq-rcjv" // https://github.com/advisories/GHSA-952p-6rrq-rcjv
30
+ "GHSA-952p-6rrq-rcjv", // https://github.com/advisories/GHSA-952p-6rrq-rcjv
31
+ "GHSA-3xgq-45jj-v275" // https://github.com/advisories/GHSA-3xgq-45jj-v275
31
32
  ]
32
33
  }
package/jest.config.js CHANGED
@@ -1,5 +1,7 @@
1
1
  module.exports = {
2
2
  verbose: true,
3
+ clearMocks: true,
4
+
3
5
  collectCoverageFrom: [
4
6
  '**/src/**/**/*.js'
5
7
  ],
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": "15.6.0-snapshot.0",
4
+ "version": "15.6.0-snapshot.1",
5
5
  "license": "Apache-2.0",
6
6
  "author": "ModusBox",
7
7
  "contributors": [
@@ -54,7 +54,7 @@
54
54
  "test:coverage-check": "npm test -- --coverage",
55
55
  "test:junit": "npm test -- --reporters=default --reporters=jest-junit",
56
56
  "test:xunit": "npm run test:junit",
57
- "test:functional": "sh ./scripts/test-functional.sh",
57
+ "test:functional": "bash ./scripts/test-functional.sh",
58
58
  "test:int": "npm run migrate && npm run onboarding && jest --config=./jest-int.config.js --runInBand",
59
59
  "test:integration": "npm run dc:up && npm run wait-4-docker && npm run test:int | tee ./test/results/test-int.log",
60
60
  "test:integration-runner": "TEST_MODE=rm ./test/integration-runner.sh",
@@ -89,25 +89,24 @@
89
89
  "@hapi/good": "9.0.1",
90
90
  "@hapi/hapi": "21.3.12",
91
91
  "@hapi/inert": "7.1.0",
92
- "@hapi/joi": "17.1.1",
93
92
  "@hapi/vision": "7.0.3",
94
93
  "@mojaloop/central-services-error-handling": "13.0.2",
95
94
  "@mojaloop/central-services-health": "15.0.0",
96
95
  "@mojaloop/central-services-logger": "11.5.1",
97
- "@mojaloop/central-services-metrics": "12.0.8",
98
- "@mojaloop/central-services-shared": "18.12.0-snapshot.0",
96
+ "@mojaloop/central-services-metrics": "12.1.0",
97
+ "@mojaloop/central-services-shared": "18.11.1",
99
98
  "@mojaloop/central-services-stream": "11.3.1",
100
99
  "@mojaloop/database-lib": "11.0.6",
101
100
  "@mojaloop/event-sdk": "14.1.1",
102
101
  "@mojaloop/inter-scheme-proxy-cache-lib": "2.3.0",
103
- "@mojaloop/ml-schema-transformer-lib": "2.3.4",
104
- "@mojaloop/sdk-standard-components": "19.0.0",
102
+ "@mojaloop/ml-schema-transformer-lib": "2.4.1",
103
+ "@mojaloop/sdk-standard-components": "19.5.1",
105
104
  "@now-ims/hapi-now-auth": "2.1.0",
106
105
  "ajv": "8.17.1",
107
106
  "ajv-keywords": "5.1.0",
108
107
  "blipp": "4.0.2",
109
108
  "commander": "12.1.0",
110
- "cron": "3.2.0",
109
+ "cron": "3.2.1",
111
110
  "fast-safe-stringify": "^2.1.1",
112
111
  "hapi-auth-bearer-token": "8.0.0",
113
112
  "joi": "17.13.3",
@@ -159,10 +158,9 @@
159
158
  "jest-junit": "16.0.0",
160
159
  "jsdoc": "4.0.4",
161
160
  "nodemon": "3.1.7",
162
- "npm-check-updates": "17.1.10",
161
+ "npm-check-updates": "17.1.11",
163
162
  "nyc": "17.1.0",
164
163
  "pre-commit": "1.2.2",
165
- "proxyquire": "2.1.3",
166
164
  "replace": "^1.2.2",
167
165
  "sinon": "19.0.2",
168
166
  "standard": "17.1.2",
@@ -32,21 +32,22 @@ const oracle = require('../../models/oracle/facade')
32
32
  const participant = require('../../models/participantEndpoint/facade')
33
33
  const { createCallbackHeaders } = require('../../lib/headers')
34
34
  const { ERROR_MESSAGES } = require('../../constants')
35
- const { loggerFactory } = require('../../lib')
35
+ const { logger } = require('../../lib')
36
36
  const Config = require('../../lib/config')
37
37
  const utils = require('./utils')
38
38
 
39
39
  const { FspEndpointTypes, FspEndpointTemplates } = Enum.EndPoints
40
40
  const { Headers, RestMethods } = Enum.Http
41
41
 
42
- const logger = loggerFactory('domain:get-parties')
42
+ const log = logger.child('domain:get-parties')
43
+ const handleErrorOnSendingCallback = utils.createErrorHandlerOnSendingCallback(Config, log)
43
44
 
44
45
  const proxyCacheTtlSec = 40 // todo: make configurable
45
46
 
46
47
  const validateRequester = async ({ source, proxy, proxyCache }) => {
47
48
  const sourceParticipant = await participant.validateParticipant(source)
48
49
  if (sourceParticipant) {
49
- logger.debug('source is in scheme', { source })
50
+ log.debug('source is in scheme', { source })
50
51
  return source
51
52
  }
52
53
 
@@ -63,7 +64,7 @@ const validateRequester = async ({ source, proxy, proxyCache }) => {
63
64
 
64
65
  const isCached = await proxyCache.addDfspIdToProxyMapping(source, proxy)
65
66
  // think, what if isCached !== true?
66
- logger.info('source is added to proxyMapping cache:', { source, proxy, isCached })
67
+ log.info('source is added to proxyMapping cache:', { source, proxy, isCached })
67
68
  return proxy
68
69
  }
69
70
 
@@ -94,7 +95,7 @@ const getPartiesByTypeAndID = async (headers, params, method, query, span, cache
94
95
  const callbackEndpointType = utils.getPartyCbType(partySubId)
95
96
 
96
97
  const childSpan = span ? span.getChild('getPartiesByTypeAndID') : undefined
97
- logger.info('parties::getPartiesByTypeAndID::begin', { source, proxy, params })
98
+ log.info('parties::getPartiesByTypeAndID::begin', { source, proxy, params })
98
99
 
99
100
  let requester
100
101
  let fspiopError
@@ -127,7 +128,7 @@ const getPartiesByTypeAndID = async (headers, params, method, query, span, cache
127
128
  await participant.sendRequest(headers, destination, callbackEndpointType, RestMethods.GET, undefined, options, childSpan)
128
129
 
129
130
  histTimerEnd({ success: true })
130
- logger.info('discovery getPartiesByTypeAndID request was sent to destination', { destination })
131
+ log.info('discovery getPartiesByTypeAndID request was sent to destination', { destination })
131
132
  return
132
133
  }
133
134
 
@@ -161,7 +162,7 @@ const getPartiesByTypeAndID = async (headers, params, method, query, span, cache
161
162
  const schemeParticipant = await participant.validateParticipant(fspId)
162
163
  if (schemeParticipant) {
163
164
  sentCount++
164
- logger.debug('participant is in scheme', { fspId })
165
+ log.debug('participant is in scheme', { fspId })
165
166
  return participant.sendRequest(clonedHeaders, party.fspId, callbackEndpointType, RestMethods.GET, undefined, options, childSpan)
166
167
  }
167
168
 
@@ -170,20 +171,20 @@ const getPartiesByTypeAndID = async (headers, params, method, query, span, cache
170
171
  if (proxyEnabled) {
171
172
  const proxyName = await proxyCache.lookupProxyByDfspId(fspId)
172
173
  if (!proxyName) {
173
- logger.warn('no proxyMapping for participant! TODO: Delete reference in oracle...', { fspId })
174
+ log.warn('no proxyMapping for participant! TODO: Delete reference in oracle...', { fspId })
174
175
  // todo: delete reference in oracle
175
176
  } else {
176
177
  sentCount++
177
- logger.debug('participant NOT is in scheme, use proxy name', { fspId, proxyName })
178
+ log.debug('participant NOT is in scheme, use proxy name', { fspId, proxyName })
178
179
  return participant.sendRequest(clonedHeaders, proxyName, callbackEndpointType, RestMethods.GET, undefined, options, childSpan)
179
180
  }
180
181
  }
181
182
  })
182
183
  await Promise.all(sending)
183
- logger.info('participant.sendRequests to filtered oracle partyList are done', { sentCount })
184
+ log.info('participant.sendRequests to filtered oracle partyList are done', { sentCount })
184
185
  // todo: think what if sentCount === 0 here
185
186
  } else {
186
- logger.info('empty partyList form oracle, getting proxies list...', { proxyEnabled, params })
187
+ log.info('empty partyList form oracle, getting proxies list...', { proxyEnabled, params })
187
188
  let filteredProxyNames = []
188
189
 
189
190
  if (proxyEnabled) {
@@ -206,7 +207,7 @@ const getPartiesByTypeAndID = async (headers, params, method, query, span, cache
206
207
  fspiopError.toApiErrorObject(config.ERROR_HANDLING), callbackHeaders, params, childSpan)
207
208
  } else {
208
209
  const alsReq = utils.alsRequestDto(source, params)
209
- logger.info('starting setSendToProxiesList flow: ', { filteredProxyNames, alsReq, proxyCacheTtlSec })
210
+ log.info('starting setSendToProxiesList flow: ', { filteredProxyNames, alsReq, proxyCacheTtlSec })
210
211
  const isCached = await proxyCache.setSendToProxiesList(alsReq, filteredProxyNames, proxyCacheTtlSec)
211
212
  if (!isCached) {
212
213
  throw ErrorHandler.Factory.createFSPIOPError(ErrorHandler.Enums.FSPIOPErrorCodes.ID_NOT_FOUND, ERROR_MESSAGES.failedToCacheSendToProxiesList)
@@ -221,7 +222,7 @@ const getPartiesByTypeAndID = async (headers, params, method, query, span, cache
221
222
  // If, at least, one request is sent to proxy, we treat the whole flow as successful.
222
223
  // Failed requests should be handled by TTL expired/timeout handler
223
224
  // todo: - think, if we should handle failed requests here (e.g., by calling receivedErrorResponse)
224
- logger.info('setSendToProxiesList flow is done:', { isOk, results, filteredProxyNames, alsReq })
225
+ log.info('setSendToProxiesList flow is done:', { isOk, results, filteredProxyNames, alsReq })
225
226
  if (!isOk) {
226
227
  throw ErrorHandler.Factory.createFSPIOPError(ErrorHandler.Enums.FSPIOPErrorCodes.ID_NOT_FOUND, ERROR_MESSAGES.proxyConnectionError)
227
228
  }
@@ -229,7 +230,7 @@ const getPartiesByTypeAndID = async (headers, params, method, query, span, cache
229
230
  }
230
231
  histTimerEnd({ success: true })
231
232
  } catch (err) {
232
- fspiopError = await utils.handleErrorOnSendingCallback(err, headers, params, requester)
233
+ fspiopError = await handleErrorOnSendingCallback(err, headers, params, requester)
233
234
  histTimerEnd({ success: false })
234
235
  } finally {
235
236
  await utils.finishSpanWithError(childSpan, fspiopError)
@@ -44,6 +44,7 @@ const utils = require('./utils')
44
44
  const getPartiesByTypeAndID = require('./getPartiesByTypeAndID')
45
45
 
46
46
  const logger = loggerFactory('domain:put-parties')
47
+ const handleErrorOnSendingCallback = utils.createErrorHandlerOnSendingCallback(Config, logger)
47
48
 
48
49
  /**
49
50
  * @function putPartiesByTypeAndID
@@ -124,7 +125,7 @@ const putPartiesByTypeAndID = async (headers, params, method, payload, dataUri,
124
125
  logger.info('parties::putPartiesByTypeAndID::callback was sent', { sendTo, options })
125
126
  histTimerEnd({ success: true })
126
127
  } catch (err) {
127
- await utils.handleErrorOnSendingCallback(err, headers, params, sendTo)
128
+ await handleErrorOnSendingCallback(err, headers, params, sendTo)
128
129
  histTimerEnd({ success: false })
129
130
  }
130
131
  }
@@ -197,7 +198,7 @@ const putPartiesErrorByTypeAndID = async (headers, params, payload, dataUri, spa
197
198
  logger.info('putPartiesErrorByTypeAndID callback was sent', { sendTo })
198
199
  histTimerEnd({ success: true })
199
200
  } catch (err) {
200
- fspiopError = await utils.handleErrorOnSendingCallback(err, headers, params, sendTo)
201
+ fspiopError = await handleErrorOnSendingCallback(err, headers, params, sendTo)
201
202
  histTimerEnd({ success: false })
202
203
  } finally {
203
204
  await utils.finishSpanWithError(childSpan, fspiopError)
@@ -1,10 +1,9 @@
1
- const { Enum } = require('@mojaloop/central-services-shared')
1
+ const { Enum, Util: { Hapi } } = require('@mojaloop/central-services-shared')
2
2
  const EventSdk = require('@mojaloop/event-sdk')
3
3
  const ErrorHandler = require('@mojaloop/central-services-error-handling')
4
4
 
5
5
  const participant = require('../../models/participantEndpoint/facade')
6
- const Config = require('../../lib/config')
7
- const { logger } = require('../../lib')
6
+ const { TransformFacades } = require('../../lib')
8
7
 
9
8
  const { FspEndpointTypes } = Enum.EndPoints
10
9
  const { Headers } = Enum.Http
@@ -33,6 +32,13 @@ const finishSpanWithError = async (childSpan, fspiopError) => {
33
32
  }
34
33
  }
35
34
 
35
+ const makePutPartiesErrorPayload = async (config, fspiopError, headers, params) => {
36
+ const body = fspiopError.toApiErrorObject(config.ERROR_HANDLING)
37
+ return config.API_TYPE === Hapi.API_TYPES.iso20022
38
+ ? (await TransformFacades.FSPIOP.parties.putError({ body, headers, params })).body
39
+ : body
40
+ }
41
+
36
42
  const alsRequestDto = (sourceId, params) => ({
37
43
  sourceId,
38
44
  type: params.Type,
@@ -54,13 +60,13 @@ const swapSourceDestinationHeaders = (headers) => {
54
60
  }
55
61
 
56
62
  // change signature to accept object
57
- const handleErrorOnSendingCallback = async (err, headers, params, requester) => {
63
+ const createErrorHandlerOnSendingCallback = (config, logger) => async (err, headers, params, requester) => {
58
64
  try {
59
65
  logger.error('error in sending parties callback', err)
60
66
  const sendTo = requester || headers[Headers.FSPIOP.SOURCE]
61
67
  const errorCallbackEndpointType = errorPartyCbType(params.SubId)
62
68
  const fspiopError = ErrorHandler.Factory.reformatFSPIOPError(err)
63
- const errInfo = fspiopError.toApiErrorObject(Config.ERROR_HANDLING)
69
+ const errInfo = await makePutPartiesErrorPayload(config, fspiopError, headers, params)
64
70
 
65
71
  await participant.sendErrorToParticipant(sendTo, errorCallbackEndpointType, errInfo, headers, params)
66
72
 
@@ -77,8 +83,9 @@ module.exports = {
77
83
  getPartyCbType,
78
84
  putPartyCbType,
79
85
  errorPartyCbType,
86
+ makePutPartiesErrorPayload,
80
87
  finishSpanWithError,
81
- handleErrorOnSendingCallback,
88
+ createErrorHandlerOnSendingCallback,
82
89
  alsRequestDto,
83
90
  swapSourceDestinationHeaders
84
91
  }
@@ -8,18 +8,10 @@ const {
8
8
  EndPoints: { FspEndpointTypes }
9
9
  } = require('@mojaloop/central-services-shared').Enum
10
10
  const { Tracer } = require('@mojaloop/event-sdk')
11
- const { API_TYPES } = require('@mojaloop/central-services-shared').Util.Hapi
12
11
 
13
- const { TransformFacades } = require('../../lib')
14
12
  const LibUtil = require('../../lib/util')
15
13
  const Config = require('../../lib/config')
16
-
17
- const makeErrorPayload = async (headers, params) => {
18
- const body = createFSPIOPError(FSPIOPErrorCodes.EXPIRED_ERROR).toApiErrorObject(Config.ERROR_HANDLING)
19
- return Config.API_TYPE === API_TYPES.iso20022
20
- ? (await TransformFacades.FSPIOP.parties.putError({ body, headers, params })).body
21
- : body
22
- }
14
+ const partiesUtils = require('../parties/utils')
23
15
 
24
16
  const timeoutCallbackDto = async ({ destination, partyId, partyType }) => {
25
17
  const headers = {
@@ -30,8 +22,10 @@ const timeoutCallbackDto = async ({ destination, partyId, partyType }) => {
30
22
  ID: partyId,
31
23
  Type: partyType
32
24
  }
25
+ const error = createFSPIOPError(FSPIOPErrorCodes.EXPIRED_ERROR)
26
+
33
27
  const dto = {
34
- errorInformation: await makeErrorPayload(headers, params),
28
+ errorInformation: await partiesUtils.makePutPartiesErrorPayload(Config, error, headers, params),
35
29
  headers,
36
30
  params,
37
31
  endpointType: FspEndpointTypes.FSPIOP_CALLBACK_URL_PARTIES_PUT_ERROR
@@ -613,7 +613,7 @@ describe('Parties Tests', () => {
613
613
  it('handles error when `participant.validateParticipant()` returns no participant', async () => {
614
614
  expect.hasAssertions()
615
615
  // Arrange
616
- const loggerStub = sandbox.stub(logger, 'error')
616
+ const loggerStub = sandbox.stub(logger.constructor.prototype, 'error')
617
617
  participant.sendErrorToParticipant = sandbox.stub().resolves()
618
618
 
619
619
  const payload = JSON.stringify({ testPayload: true })
@@ -874,7 +874,7 @@ describe('Parties Tests', () => {
874
874
  it('handles error when `validateParticipant()` fails', async () => {
875
875
  expect.hasAssertions()
876
876
  // Arrange)
877
- const loggerStub = sandbox.stub(logger.mlLogger, 'error')
877
+ const loggerStub = sandbox.stub(logger.constructor.prototype, 'error')
878
878
  participant.validateParticipant = sandbox.stub().throws(new Error('Validation fails'))
879
879
  participant.sendErrorToParticipant = sandbox.stub().resolves({})
880
880
  const payload = JSON.stringify({ errorPayload: true })
@@ -894,7 +894,7 @@ describe('Parties Tests', () => {
894
894
  expect.hasAssertions()
895
895
  // Arrange
896
896
 
897
- const loggerStub = sandbox.stub(logger.mlLogger, 'error')
897
+ const loggerStub = sandbox.stub(logger.constructor.prototype, 'error')
898
898
  participant.validateParticipant = sandbox.stub().throws(new Error('Validation fails'))
899
899
  participant.sendErrorToParticipant = sandbox.stub().resolves({})
900
900
  const payload = JSON.stringify({ errorPayload: true })
@@ -0,0 +1,60 @@
1
+ /*****
2
+ License
3
+ --------------
4
+ Copyright © 2017 Bill & Melinda Gates Foundation
5
+ The Mojaloop files are made available by the Bill & Melinda Gates 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
+ Gates 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
+ * Gates Foundation
20
+ - Name Surname <name.surname@gatesfoundation.com>
21
+
22
+ * Eugen Klymniuk <eugen.klymniuk@infitx.com>
23
+ --------------
24
+ **********/
25
+
26
+ const mockSendRequest = jest.fn()
27
+
28
+ jest.mock('@mojaloop/central-services-shared', () => ({
29
+ ...jest.requireActual('@mojaloop/central-services-shared'),
30
+ Util: {
31
+ ...jest.requireActual('@mojaloop/central-services-shared').Util,
32
+ Endpoints: { getEndpoint: jest.fn() },
33
+ Request: { sendRequest: mockSendRequest }
34
+ }
35
+ }))
36
+
37
+ const { API_TYPES } = require('@mojaloop/central-services-shared').Util.Hapi
38
+ const { logger } = require('../../../../src/lib')
39
+ const utils = require('../../../../src/domain/parties/utils')
40
+ const config = require('../../../../src/lib/config')
41
+ const fixtures = require('../../../fixtures')
42
+
43
+ describe('parties utils Tests -->', () => {
44
+ test('should send error party callback in ISO format', async () => {
45
+ const isoConfig = { ...config, API_TYPE: API_TYPES.iso20022 }
46
+ const err = new Error('test error')
47
+ const source = 'dfsp1'
48
+ const headers = fixtures.partiesCallHeadersDto({ source })
49
+ const params = { ID: '1234', Type: 'MSISDN' }
50
+
51
+ const handleError = utils.createErrorHandlerOnSendingCallback(isoConfig, logger)
52
+ await handleError(err, headers, params, source)
53
+
54
+ expect(mockSendRequest).toHaveBeenCalledTimes(1)
55
+ const { payload } = mockSendRequest.mock.calls[0][0]
56
+ expect(payload.Rpt.Rsn.Cd).toBe('2001')
57
+ expect(payload.Rpt.OrgnlId).toBe(`${params.Type}/${params.ID}`)
58
+ expect(payload.Assgnmt.Assgnr.Agt.FinInstnId.Othr.Id).toBe(source)
59
+ })
60
+ })
@@ -5,7 +5,7 @@ describe('TransformFacades Tests -->', () => {
5
5
  test('should transform PUT /parties error callback payload to ISO format', async () => {
6
6
  const body = errorCallbackResponseDto()
7
7
  const headers = partiesCallHeadersDto()
8
- TransformFacades.FSPIOP.configure({ logger: console, isTestingMode: true })
8
+ TransformFacades.FSPIOP.configure({ isTestingMode: true })
9
9
  const isoPayload = await TransformFacades.FSPIOP.parties.putError({
10
10
  body,
11
11
  headers,
@@ -58,6 +58,18 @@ jest.mock('@mojaloop/central-services-shared', () => ({
58
58
  const Logger = require('@mojaloop/central-services-logger')
59
59
  const fixtures = require('../../../fixtures')
60
60
 
61
+ const mockConfigDto = ({
62
+ apiType = 'fspiop', // todo: use API_TYPES
63
+ jwsSign = false
64
+ } = {}) => ({
65
+ API_TYPE: apiType,
66
+ JWS_SIGN: jwsSign,
67
+ FSPIOP_SOURCE_TO_SIGN: mockHubName,
68
+ JWS_SIGNING_KEY_PATH: 'secrets/jwsSigningKey.key',
69
+ JWS_SIGNING_KEY: 'somekey',
70
+ PROTOCOL_VERSIONS: fixtures.protocolVersionsDto()
71
+ })
72
+
61
73
  Logger.isDebugEnabled = jest.fn(() => true)
62
74
  Logger.isErrorEnabled = jest.fn(() => true)
63
75
  Logger.isInfoEnabled = jest.fn(() => true)
@@ -190,14 +202,6 @@ describe('participantEndpoint Facade', () => {
190
202
  })
191
203
 
192
204
  describe('sendErrorToParticipant', () => {
193
- const mockConfigDto = ({ jwsSign = false } = {}) => ({
194
- JWS_SIGN: jwsSign,
195
- FSPIOP_SOURCE_TO_SIGN: mockHubName,
196
- JWS_SIGNING_KEY_PATH: 'secrets/jwsSigningKey.key',
197
- JWS_SIGNING_KEY: 'somekey',
198
- PROTOCOL_VERSIONS: fixtures.protocolVersionsDto()
199
- })
200
-
201
205
  it('throws an error when the request fails', async () => {
202
206
  // Arrange
203
207
  jest.mock('../../../../src/lib/config', () => mockConfigDto())
@@ -291,5 +295,18 @@ describe('participantEndpoint Facade', () => {
291
295
  })
292
296
  spy.mockRestore()
293
297
  })
298
+
299
+ it('should send error response with apiType from config [ISO20022]', async () => {
300
+ const apiType = 'iso20022'
301
+ jest.mock('../../../../src/lib/config', () => mockConfigDto({ apiType }))
302
+ mockGetEndpoint.mockImplementation(() => 'http://example.com/12345')
303
+
304
+ const { sendErrorToParticipant } = require(`${src}/models/participantEndpoint/facade`)
305
+ await sendErrorToParticipant('participantName', 'URL', fixtures.errorCallbackResponseDto(), {})
306
+
307
+ expect(mockSendRequest).toHaveBeenCalledTimes(1)
308
+ const args = mockSendRequest.mock.calls[0][0]
309
+ expect(args.apiType).toBe(apiType)
310
+ })
294
311
  })
295
312
  })