account-lookup-service 15.6.0-iso.16 → 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.
|
4
|
+
"version": "15.6.0-iso.18",
|
5
5
|
"license": "Apache-2.0",
|
6
6
|
"author": "ModusBox",
|
7
7
|
"contributors": [
|
@@ -94,13 +94,13 @@
|
|
94
94
|
"@mojaloop/central-services-health": "15.0.0",
|
95
95
|
"@mojaloop/central-services-logger": "11.5.1",
|
96
96
|
"@mojaloop/central-services-metrics": "12.3.0",
|
97
|
-
"@mojaloop/central-services-shared": "18.12.
|
97
|
+
"@mojaloop/central-services-shared": "18.12.1",
|
98
98
|
"@mojaloop/central-services-stream": "11.3.1",
|
99
99
|
"@mojaloop/database-lib": "11.0.6",
|
100
100
|
"@mojaloop/event-sdk": "14.1.1",
|
101
101
|
"@mojaloop/inter-scheme-proxy-cache-lib": "2.3.0",
|
102
102
|
"@mojaloop/ml-schema-transformer-lib": "2.4.1",
|
103
|
-
"@mojaloop/sdk-standard-components": "19.
|
103
|
+
"@mojaloop/sdk-standard-components": "19.6.1",
|
104
104
|
"@now-ims/hapi-now-auth": "2.1.0",
|
105
105
|
"ajv": "8.17.1",
|
106
106
|
"ajv-keywords": "5.1.0",
|
@@ -148,10 +148,10 @@
|
|
148
148
|
"devDependencies": {
|
149
149
|
"@types/jest": "29.5.14",
|
150
150
|
"audit-ci": "^7.1.0",
|
151
|
-
"axios": "1.7.
|
151
|
+
"axios": "1.7.9",
|
152
152
|
"axios-retry": "^4.5.0",
|
153
153
|
"docdash": "2.0.2",
|
154
|
-
"dotenv": "^16.4.
|
154
|
+
"dotenv": "^16.4.7",
|
155
155
|
"get-port": "5.1.1",
|
156
156
|
"ioredis-mock": "^8.9.0",
|
157
157
|
"jest": "29.7.0",
|
@@ -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
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
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
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
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
|
package/src/server.js
CHANGED
@@ -129,6 +129,9 @@ const initializeApi = async (appConfig) => {
|
|
129
129
|
} = appConfig
|
130
130
|
|
131
131
|
if (!INSTRUMENTATION_METRICS_DISABLED) {
|
132
|
+
if (INSTRUMENTATION_METRICS_CONFIG.defaultLabels) {
|
133
|
+
INSTRUMENTATION_METRICS_CONFIG.defaultLabels.serviceVersion = version
|
134
|
+
}
|
132
135
|
initializeInstrumentation(INSTRUMENTATION_METRICS_CONFIG)
|
133
136
|
}
|
134
137
|
await connectDatabase(DATABASE)
|
package/test/fixtures/index.js
CHANGED
@@ -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: '
|
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: '
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
})
|