account-lookup-service 15.6.0-iso.17 → 15.6.0-iso.18

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": "15.6.0-iso.17",
4
+ "version": "15.6.0-iso.18",
5
5
  "license": "Apache-2.0",
6
6
  "author": "ModusBox",
7
7
  "contributors": [
@@ -148,7 +148,7 @@
148
148
  "devDependencies": {
149
149
  "@types/jest": "29.5.14",
150
150
  "audit-ci": "^7.1.0",
151
- "axios": "1.7.8",
151
+ "axios": "1.7.9",
152
152
  "axios-retry": "^4.5.0",
153
153
  "docdash": "2.0.2",
154
154
  "dotenv": "^16.4.7",
@@ -890,13 +890,14 @@ components:
890
890
  schemas:
891
891
  CorrelationId:
892
892
  title: CorrelationId
893
- pattern: ^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
894
893
  type: string
895
- description: Identifier that correlates all messages of the same sequence. The
896
- API data type UUID (Universally Unique Identifier) is a JSON String in canonical
897
- format, conforming to RFC 4122, that is restricted by a regular expression
898
- for interoperability reasons. An UUID is always 36 characters long, 32 hexadecimal
899
- symbols and 4 dashes (‘-‘).
894
+ pattern: ^[0-9a-f]{8}-[0-9a-f]{4}-[1-7][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$|^[0-9A-HJKMNP-TV-Z]{26}$
895
+ description: >-
896
+ Identifier that correlates all messages of the same sequence.
897
+ The supported identifiers formats are for
898
+ lowercase [UUID](https://datatracker.ietf.org/doc/html/rfc9562) and
899
+ uppercase [ULID](https://github.com/ulid/spec)
900
+ example: 'b51ec534-ee48-4575-b6a9-ead2955b8069'
900
901
  Currency:
901
902
  title: CurrencyEnum
902
903
  maxLength: 3
@@ -889,13 +889,14 @@ components:
889
889
  schemas:
890
890
  CorrelationId:
891
891
  title: CorrelationId
892
- pattern: ^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
893
892
  type: string
894
- description: Identifier that correlates all messages of the same sequence. The
895
- API data type UUID (Universally Unique Identifier) is a JSON String in canonical
896
- format, conforming to RFC 4122, that is restricted by a regular expression
897
- for interoperability reasons. An UUID is always 36 characters long, 32 hexadecimal
898
- symbols and 4 dashes (‘-‘).
893
+ pattern: ^[0-9a-f]{8}-[0-9a-f]{4}-[1-7][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$|^[0-9A-HJKMNP-TV-Z]{26}$
894
+ description: >-
895
+ Identifier that correlates all messages of the same sequence.
896
+ The supported identifiers formats are for
897
+ lowercase [UUID](https://datatracker.ietf.org/doc/html/rfc9562) and
898
+ uppercase [ULID](https://github.com/ulid/spec)
899
+ example: 'b51ec534-ee48-4575-b6a9-ead2955b8069'
899
900
  Currency:
900
901
  title: CurrencyEnum
901
902
  maxLength: 3
@@ -9,14 +9,15 @@ const headersDto = ({
9
9
  destination = 'toDfsp',
10
10
  proxy = '',
11
11
  date = '2024-05-24 08:52:19',
12
- accept
12
+ accept,
13
+ contentType
13
14
  } = {}) => Object.freeze({
14
15
  [Headers.FSPIOP.SOURCE]: source,
15
16
  ...(destination && { [Headers.FSPIOP.DESTINATION]: destination }),
16
17
  ...(proxy && { [Headers.FSPIOP.PROXY]: proxy }),
17
18
  date,
18
19
  accept,
19
- 'content-type': accept
20
+ 'content-type': contentType || accept
20
21
  })
21
22
 
22
23
  const protocolVersionsDto = () => ({
@@ -40,22 +41,29 @@ const partiesCallHeadersDto = ({
40
41
  destination,
41
42
  proxy,
42
43
  date,
43
- accept: 'application/vnd.interoperability.parties+json;version=1.1'
44
+ accept: interopHeader('parties', '1'),
45
+ contentType: interopHeader('parties', '1.1')
44
46
  })
45
47
 
46
48
  const participantsCallHeadersDto = ({
47
49
  source,
48
50
  destination,
49
51
  proxy,
50
- date
52
+ date,
53
+ acceptVersion = '1',
54
+ contentTypeVersion = '1.1'
51
55
  } = {}) => headersDto({
52
56
  source,
53
57
  destination,
54
58
  proxy,
55
59
  date,
56
- accept: 'application/vnd.interoperability.participants+json;version=1'
60
+ accept: interopHeader('participants', acceptVersion),
61
+ contentType: interopHeader('participants', contentTypeVersion)
57
62
  })
58
63
 
64
+ // todo: add ISO mode support
65
+ const interopHeader = (resource, version = '1') => `application/vnd.interoperability.${resource}+json;version=${version}`
66
+
59
67
  const oracleRequestResponseDto = ({
60
68
  partyList = [{ fspId: 'dfspFromOracle' }]
61
69
  } = {}) => ({
@@ -83,6 +91,20 @@ const putPartiesSuccessResponseDto = ({
83
91
  }
84
92
  })
85
93
 
94
+ const postParticipantsPayloadDto = ({
95
+ requestId = randomUUID(), // '01JE8SG3F4WNHY8B9876THQ344',
96
+ partyList = [{
97
+ partyIdType: 'MSISDN',
98
+ partyIdentifier: '123456',
99
+ fspId: 'fspId123'
100
+ }],
101
+ currency = 'XXX'
102
+ } = {}) => Object.freeze({
103
+ requestId,
104
+ partyList,
105
+ ...(currency && { currency })
106
+ })
107
+
86
108
  const errorCallbackResponseDto = ({
87
109
  errorCode = '1234',
88
110
  errorDescription = 'Error description',
@@ -124,8 +146,10 @@ module.exports = {
124
146
  participantsCallHeadersDto,
125
147
  oracleRequestResponseDto,
126
148
  putPartiesSuccessResponseDto,
149
+ postParticipantsPayloadDto,
127
150
  errorCallbackResponseDto,
128
151
  mockAlsRequestDto,
129
152
  protocolVersionsDto,
130
- mockHapiRequestDto
153
+ mockHapiRequestDto,
154
+ interopHeader
131
155
  }
@@ -36,6 +36,7 @@ const initServer = require('../../../src/server').initializeApi
36
36
  const Helper = require('../../util/helper')
37
37
  const Db = require('../../../src/lib/db')
38
38
  const Config = require('../../../src/lib/config')
39
+ const fixtures = require('../../fixtures')
39
40
 
40
41
  Logger.isDebugEnabled = jest.fn(() => true)
41
42
  Logger.isErrorEnabled = jest.fn(() => true)
@@ -44,14 +45,14 @@ let sandbox
44
45
  let server
45
46
 
46
47
  describe('/participants', () => {
47
- beforeEach(async () => {
48
+ beforeAll(async () => {
48
49
  sandbox = Sinon.createSandbox()
49
50
  sandbox.stub(Db, 'connect').returns(Promise.resolve({}))
50
51
  Config.API_PORT = await getPort()
51
52
  server = await initServer(Config)
52
53
  })
53
54
 
54
- afterEach(async () => {
55
+ afterAll(async () => {
55
56
  await server.stop()
56
57
  sandbox.restore()
57
58
  })
@@ -103,6 +104,38 @@ describe('/participants', () => {
103
104
 
104
105
  // Assert
105
106
  expect(response.statusCode).toBe(400)
106
- await server.stop()
107
+ })
108
+
109
+ it('should validate requestId in UUID format', async () => {
110
+ const reqOptions = {
111
+ method: 'post',
112
+ url: '/participants',
113
+ headers: fixtures.participantsCallHeadersDto(),
114
+ payload: fixtures.postParticipantsPayloadDto()
115
+ }
116
+ const response = await server.inject(reqOptions)
117
+ expect(response.statusCode).toBe(200)
118
+ })
119
+
120
+ it('should validate requestId in ULID format', async () => {
121
+ const reqOptions = {
122
+ method: 'post',
123
+ url: '/participants',
124
+ headers: fixtures.participantsCallHeadersDto(),
125
+ payload: fixtures.postParticipantsPayloadDto({ requestId: '01JE8SG3F4WNHY8B9876THQ344' })
126
+ }
127
+ const response = await server.inject(reqOptions)
128
+ expect(response.statusCode).toBe(200)
129
+ })
130
+
131
+ it('should fail requestId validation', async () => {
132
+ const reqOptions = {
133
+ method: 'post',
134
+ url: '/participants',
135
+ headers: fixtures.participantsCallHeadersDto(),
136
+ payload: fixtures.postParticipantsPayloadDto({ requestId: 'wrong format' })
137
+ }
138
+ const response = await server.inject(reqOptions)
139
+ expect(response.statusCode).toBe(400)
107
140
  })
108
141
  })