account-lookup-service 17.12.6 → 17.12.8

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.
@@ -25,7 +25,8 @@
25
25
  /* istanbul ignore file */
26
26
  'use strict'
27
27
 
28
- const ErrorHandler = require('@mojaloop/central-services-error-handling')
28
+ const { Factory, Enums } = require('@mojaloop/central-services-error-handling')
29
+ const { errorInfoDto } = require('../../lib/dto')
29
30
 
30
31
  /**
31
32
  * Operations on /participants/{ID}
@@ -39,6 +40,8 @@ module.exports = {
39
40
  * responses: 200, 400, 401, 403, 404, 405, 406, 501, 503
40
41
  */
41
42
  put: function (context, request, h) {
42
- return h.response(ErrorHandler.Factory.createFSPIOPError(ErrorHandler.Enums.FSPIOPErrorCodes.NOT_IMPLEMENTED))
43
+ const { code, message, httpStatusCode } = Factory.createFSPIOPError(Enums.FSPIOPErrorCodes.NOT_IMPLEMENTED).apiErrorCode
44
+ return h.response(errorInfoDto(code, message))
45
+ .code(httpStatusCode)
43
46
  }
44
47
  }
@@ -71,8 +71,8 @@ module.exports = {
71
71
  payload
72
72
  }, EventSdk.AuditEventAction.start)
73
73
 
74
- const metadata = `${request.method} ${request.path}`
75
- participants.getParticipantsByTypeAndID(request.headers, request.params, request.method, request.query, span, request.server.app.cache).catch(err => {
74
+ const metadata = `${method} ${path}`
75
+ participants.getParticipantsByTypeAndID(headers, params, method, request.query, span, request.server.app.cache).catch(err => {
76
76
  request.server.log(['error'], `ERROR - getParticipantsByTypeAndID:${metadata}: ${LibUtil.getStackOrInspect(err)}`)
77
77
  })
78
78
  histTimerEnd({ success: true })
@@ -115,7 +115,7 @@ module.exports = {
115
115
  payload
116
116
  }, EventSdk.AuditEventAction.start)
117
117
 
118
- participants.putParticipantsByTypeAndID(request.headers, request.params, request.method, request.payload, request.server.app.cache).catch(err => {
118
+ participants.putParticipantsByTypeAndID(headers, params, method, payload, request.server.app.cache).catch(err => {
119
119
  request.server.log(['error'], `ERROR - putParticipantsByTypeAndID:${metadata}: ${LibUtil.getStackOrInspect(err)}`)
120
120
  })
121
121
  histTimerEnd({ success: true })
@@ -134,7 +134,7 @@ module.exports = {
134
134
  'Ingress: Post participant by Type and Id',
135
135
  ['success']
136
136
  ).startTimer()
137
- const { method, path, params, span } = request
137
+ const { headers, payload, method, path, params, span } = request
138
138
  const spanTags = LibUtil.getSpanTags(request, Enum.Events.Event.Type.PARTICIPANT, Enum.Events.Event.Action.POST)
139
139
  span.setTags(spanTags)
140
140
  const queryTags = EventFrameworkUtil.Tags.getQueryTags(
@@ -151,11 +151,12 @@ module.exports = {
151
151
  )
152
152
  span.setTags(queryTags)
153
153
  await span.audit({
154
- headers: request.headers,
155
- payload: request.payload
154
+ headers,
155
+ payload
156
156
  }, EventSdk.AuditEventAction.start)
157
- const metadata = `${request.method} ${request.path}`
158
- participants.postParticipants(request.headers, request.method, request.params, request.payload, span, request.server.app.cache).catch(err => {
157
+
158
+ const metadata = `${method} ${path}`
159
+ participants.postParticipants(headers, method, params, payload, span, request.server.app.cache).catch(err => {
159
160
  request.server.log(['error'], `ERROR - postParticipants:${metadata}: ${LibUtil.getStackOrInspect(err)}`)
160
161
  })
161
162
  histTimerEnd({ success: true })
@@ -196,8 +197,8 @@ module.exports = {
196
197
  payload: undefined
197
198
  }, EventSdk.AuditEventAction.start)
198
199
 
199
- const metadata = `${request.method} ${request.path}`
200
- participants.deleteParticipants(request.headers, request.params, request.method, request.query, request.server.app.cache).catch(err => {
200
+ const metadata = `${method} ${path}`
201
+ participants.deleteParticipants(headers, params, method, request.query, request.server.app.cache).catch(err => {
201
202
  request.server.log(['error'], `ERROR - deleteParticipants:${metadata}: ${LibUtil.getStackOrInspect(err)}`)
202
203
  })
203
204
  histTimerEnd({ success: true })
package/src/lib/dto.js ADDED
@@ -0,0 +1,38 @@
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 errorInfoDto = (errorCode, errorDescription, extensionList = null) => ({
29
+ errorInformation: {
30
+ errorCode,
31
+ errorDescription,
32
+ ...(extensionList && { extensionList })
33
+ }
34
+ })
35
+
36
+ module.exports = {
37
+ errorInfoDto
38
+ }
@@ -68,7 +68,7 @@ describe('Parties Endpoints Tests -->', () => {
68
68
 
69
69
  await sleep(1000)
70
70
  history = await proxyClient.getHistory()
71
- expect(history.length).toBe(2)
71
+ expect(history.length).toBeGreaterThanOrEqual(2)
72
72
  expect(history[0].path).toBe(`/oracle/participants/${PARTY_ID_TYPE}/${partyId}`)
73
73
  expect(history[1].path).toBe(`/parties/${PARTY_ID_TYPE}/${partyId}`)
74
74
 
@@ -112,4 +112,25 @@ describe('/participants', () => {
112
112
  expect(response.statusCode).toBe(500)
113
113
  participants.postParticipantsBatch.restore()
114
114
  })
115
+
116
+ it('should return 501 error on PUT /participants/{ID} call [CSI-1694]', async () => {
117
+ // Arrange
118
+ const options = {
119
+ method: 'put',
120
+ url: '/participants/123',
121
+ headers: Helper.defaultSwitchHeaders,
122
+ payload: {
123
+ partyList: [
124
+ { partyId: mock.partyList[0] }
125
+ ]
126
+ }
127
+ }
128
+
129
+ // Act
130
+ const response = await server.inject(options)
131
+
132
+ // Assert
133
+ expect(response.statusCode).toBe(501)
134
+ expect(response.result.errorInformation).toBeDefined()
135
+ })
115
136
  })