Skip to content

Commit

Permalink
fix(csi-107): fixed QSh iso callback (#364)
Browse files Browse the repository at this point in the history
  • Loading branch information
geka-evk authored Oct 24, 2024
1 parent eaacf04 commit 0182107
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 30 deletions.
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ x-depends-on: &dependsOnMysqlAndKafka
condition: service_completed_successfully

x-quoting-service: &quotingServiceBase
# image: mojaloop/quoting-service:v15.9.0-iso.6
image: mojaloop/quoting-service:local
build:
context: .
Expand Down
38 changes: 19 additions & 19 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
},
"dependencies": {
"@hapi/good": "9.0.1",
"@hapi/hapi": "21.3.10",
"@hapi/hapi": "21.3.11",
"@hapi/inert": "7.1.0",
"@hapi/vision": "7.0.3",
"@mojaloop/central-services-error-handling": "13.0.2",
Expand All @@ -116,7 +116,7 @@
"@mojaloop/event-sdk": "14.1.1",
"@mojaloop/inter-scheme-proxy-cache-lib": "2.3.0",
"@mojaloop/ml-number": "11.2.4",
"@mojaloop/ml-schema-transformer-lib": "1.1.5",
"@mojaloop/ml-schema-transformer-lib": "1.1.6",
"@mojaloop/sdk-standard-components": "18.1.0",
"ajv": "8.17.1",
"ajv-keywords": "5.1.0",
Expand Down
6 changes: 4 additions & 2 deletions src/lib/dto.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ const storeOriginalPayload = async ({ originalPayloadStorage, dataUri, requestId
}

const extractOriginalPayload = async (originalPayloadStorage, context, payloadCache) => {
logger.debug('extractOriginalPayload: ', { originalPayloadStorage })
let payload

if (originalPayloadStorage === PAYLOAD_STORAGES.kafka) {
Expand All @@ -88,7 +87,10 @@ const extractOriginalPayload = async (originalPayloadStorage, context, payloadCa
payload = await payloadCache?.getPayload(context?.originalRequestId)
}

return payload ? decodePayload(payload) : null
const result = payload ? decodePayload(payload) : null
logger.debug('extractOriginalPayload result: ', { originalPayloadStorage, result })

return result
}

// todo: move to domain folder
Expand Down
20 changes: 14 additions & 6 deletions src/model/quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,15 @@ class QuotesModel {
return events
}

async handleRuleEvents (events, headers, quoteRequest) {
async handleRuleEvents (events, headers, originalPayload) {
// At the time of writing, all events cause the "normal" flow of execution to be interrupted.
// So we'll return false when there have been no events whatsoever.
if (events.length === 0) {
return { terminate: false, quoteRequest, headers }
return {
terminate: false,
quoteRequest: originalPayload,
headers
}
}

const { INVALID_QUOTE_REQUEST, INTERCEPT_QUOTE } = RulesEngine.events
Expand All @@ -115,8 +119,12 @@ class QuotesModel {
// once. But is a valid solution in the short-term.
const { FSPIOPError: code, message } = invalidQuoteRequestEvents[0].params
// Will throw an internal server error if property doesn't exist
throw ErrorHandler.CreateFSPIOPError(ErrorHandler.Enums.FSPIOPErrorCodes[code],
message, null, headers['fspiop-source'])
throw ErrorHandler.CreateFSPIOPError(
ErrorHandler.Enums.FSPIOPErrorCodes[code],
message,
null,
headers['fspiop-source']
)
}

const interceptQuoteEvents = events.filter(ev => ev.type === INTERCEPT_QUOTE)
Expand All @@ -128,7 +136,7 @@ class QuotesModel {
// send the quote request to the recipient in the event
const result = {
terminate: false,
quoteRequest,
quoteRequest: originalPayload,
headers: {
...headers,
'fspiop-destination': interceptQuoteEvents[0].params.rerouteToFsp
Expand Down Expand Up @@ -278,7 +286,7 @@ class QuotesModel {
// supply a rules file containing an empty array.
const events = await this.executeRules(headers, quoteRequest, payer, payee)

handledRuleEvents = await this.handleRuleEvents(events, headers, quoteRequest, originalPayload)
handledRuleEvents = await this.handleRuleEvents(events, headers, originalPayload)
if (handledRuleEvents.terminate) {
return
}
Expand Down
2 changes: 1 addition & 1 deletion test/integration/isoApi.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe.skip('ISO API Tests -->', () => {
await sleep(3000)

const { data } = await hubClient.getHistory()
expect(data.history.length).toBe(1)
expect(data.history.length).toBeGreaterThanOrEqual(1)
const { PmtId, CdtrAgt, DbtrAgt } = data.history[0].body.CdtTrfTxInf
expect(PmtId.TxId).toBe(quoteId)
expect(PmtId.EndToEndId).toBe(transactionId)
Expand Down
1 change: 1 addition & 0 deletions test/integration/mockHttpServer/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ let history = []

const server = createServer(async (req, res) => {
const { url, method, headers } = req
console.log(`[==>] ${method.toUpperCase()} ${url}`)

if (url === Routes.HISTORY && method === 'DELETE') {
history = []
Expand Down

0 comments on commit 0182107

Please sign in to comment.