Skip to content

Commit

Permalink
added headers to close settlement window function call (#363)
Browse files Browse the repository at this point in the history
  • Loading branch information
vgenev authored Jul 15, 2021
1 parent e3c8cf8 commit 3771515
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 41 deletions.
56 changes: 23 additions & 33 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "central-settlement",
"description": "Central settlements hosted by a scheme to record and make settlements.",
"version": "13.3.1",
"version": "13.3.2",
"license": "Apache-2.0",
"private": false,
"author": "ModusBox",
Expand Down Expand Up @@ -56,7 +56,7 @@
},
"devDependencies": {
"@hapi/joi": "17.1.1",
"@types/lodash": "4.14.170",
"@types/lodash": "4.14.171",
"@mojaloop/central-services-metrics": "11.0.0",
"ajv": "8.6.1",
"ajv-keywords": "5.0.0",
Expand All @@ -71,9 +71,9 @@
"jest": "27.0.6",
"jest-junit": "12.2.0",
"node-fetch": "2.6.1",
"nodemon": "2.0.9",
"nodemon": "2.0.12",
"npm-audit-resolver": "2.3.1",
"npm-check-updates": "11.8.1",
"npm-check-updates": "11.8.3",
"nyc": "15.1.0",
"pre-commit": "1.2.2",
"proxyquire": "2.1.3",
Expand Down
2 changes: 1 addition & 1 deletion src/api/handlers/settlementWindows/{id}.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ module.exports = {
const settlementWindowId = request.params.id
try {
const Enums = await request.server.methods.enums('settlementWindowStates')
return await settlementWindow.process({ settlementWindowId, reason }, Enums)
return await settlementWindow.process({ settlementWindowId, reason, request }, Enums)
} catch (err) {
request.server.log('error', err)
return ErrorHandler.Factory.reformatFSPIOPError(err)
Expand Down
2 changes: 1 addition & 1 deletion src/domain/settlementWindow/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ module.exports = {
const state = StreamingProtocol.createEventState(Enum.Events.EventStatus.SUCCESS.status, Enum.Events.EventStatus.SUCCESS.code, Enum.Events.EventStatus.SUCCESS.description)
const event = StreamingProtocol.createEventMetadata(Enum.Events.Event.Type.DEFERRED_SETTLEMENT, Enum.Events.Event.Action.CLOSE, state)
const metadata = StreamingProtocol.createMetadata(eventId, event)
const messageProtocol = StreamingProtocol.createMessage(messageId, Enum.Http.Headers.FSPIOP.SWITCH.value, Enum.Http.Headers.FSPIOP.SWITCH.value, metadata, undefined, params)
const messageProtocol = StreamingProtocol.createMessage(messageId, Enum.Http.Headers.FSPIOP.SWITCH.value, Enum.Http.Headers.FSPIOP.SWITCH.value, metadata, params.request.headers, params)
const topicConfig = KafkaUtil.createGeneralTopicConf(Config.KAFKA_CONFIG.TOPIC_TEMPLATES.GENERAL_TOPIC_TEMPLATE.TEMPLATE, Enum.Events.Event.Type.DEFERRED_SETTLEMENT, Enum.Events.Event.Action.CLOSE)
const kafkaConfig = KafkaUtil.getKafkaConfig(Config.KAFKA_CONFIG, Enum.Kafka.Config.PRODUCER, Enum.Events.Event.Type.DEFERRED_SETTLEMENT.toUpperCase(), Enum.Events.Event.Action.CLOSE.toUpperCase())
await Producer.produceMessage(messageProtocol, topicConfig, kafkaConfig)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,17 @@ Test('SettlementTransfer should', async settlementTransferTest => {
settlementWindowId = res1[0].settlementWindowId
test.ok(settlementWindowId > 0, '#1 retrieve the OPEN window')

params = { settlementWindowId: settlementWindowId, state: enums.settlementWindowStates.CLOSED, reason: 'text' }
params = {
settlementWindowId: settlementWindowId,
state: enums.settlementWindowStates.CLOSED,
reason: 'text',
request: {
headers: {
'FSPIOP-Source': 'test',
'FSPIOP-Destination': 'test'
}
}
}
const res2 = await SettlementWindowService.process(params, enums.settlementWindowStates)
const res3 = await SettlementWindowService.close(params.settlementWindowId, params.reason)
test.ok(res3, '#2 close settlement window operation success')
Expand Down
2 changes: 1 addition & 1 deletion test/unit/domain/settlementWindow/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ Test('SettlementWindowService', async (settlementWindowServiceTest) => {

await settlementWindowServiceTest.test('process should', async processTest => {
try {
const params = { id: 1 }
const params = { id: 1, request: { headers: { testHeader: 'testHeader' } } }
const enums = {}
const options = { logger: Logger }
const settlementWindowIdMock = 1
Expand Down

0 comments on commit 3771515

Please sign in to comment.