Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(mojaloop/#2535): fspiop api version negotiation not handled by quoting service (#289) #290

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions audit-resolve.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,21 @@
"decision": "ignore",
"madeAt": 1634736540650,
"expiresAt": 1637328532038
},
"1004809|@mojaloop/central-services-shared>widdershins>openapi-sampler>json-pointer": {
"decision": "ignore",
"madeAt": 1636987481291,
"expiresAt": 1639579470858
},
"1004812|@mojaloop/central-services-shared>widdershins>swagger2openapi>better-ajv-errors>jsonpointer": {
"decision": "ignore",
"madeAt": 1636987484386,
"expiresAt": 1639579470858
},
"1004812|@mojaloop/central-services-shared>widdershins>swagger2openapi>oas-validator>better-ajv-errors>jsonpointer": {
"decision": "ignore",
"madeAt": 1636987484386,
"expiresAt": 1639579470858
}
},
"rules": {},
Expand Down
10 changes: 5 additions & 5 deletions src/model/bulkQuotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class BulkQuotesModel {
}

const fullCallbackUrl = `${endpoint}${ENUM.EndPoints.FspEndpointTemplates.BULK_QUOTES_POST}`
const newHeaders = generateRequestHeaders(headers, this.config.protocolVersions)
const newHeaders = generateRequestHeaders(headers, this.db.config.protocolVersions)

this.writeLog(`Forwarding quote request to endpoint: ${fullCallbackUrl}`)
this.writeLog(`Forwarding quote request headers: ${JSON.stringify(newHeaders)}`)
Expand Down Expand Up @@ -217,7 +217,7 @@ class BulkQuotesModel {
// we need to strip off the 'accept' header
// for all PUT requests as per the API Specification Document
// https://github.com/mojaloop/mojaloop-specification/blob/master/API%20Definition%20v1.0.pdf
const newHeaders = generateRequestHeaders(headers, this.config.protocolVersions, true)
const newHeaders = generateRequestHeaders(headers, this.db.config.protocolVersions, true)

this.writeLog(`Forwarding bulk quote response to endpoint: ${fullCallbackUrl}`)
this.writeLog(`Forwarding bulk quote response headers: ${JSON.stringify(newHeaders)}`)
Expand Down Expand Up @@ -291,7 +291,7 @@ class BulkQuotesModel {
}

const fullCallbackUrl = `${endpoint}/bulkQuotes/${bulkQuoteId}`
const newHeaders = generateRequestHeaders(headers, this.config.protocolVersions)
const newHeaders = generateRequestHeaders(headers, this.db.config.protocolVersions)

this.writeLog(`Forwarding quote get request to endpoint: ${fullCallbackUrl}`)

Expand Down Expand Up @@ -415,9 +415,9 @@ class BulkQuotesModel {

// JWS Signer expects headers in lowercase
if (envConfig.jws && envConfig.jws.jwsSign && fromSwitchHeaders['fspiop-source'] === envConfig.jws.fspiopSourceToSign) {
formattedHeaders = generateRequestHeadersForJWS(fromSwitchHeaders, true)
formattedHeaders = generateRequestHeadersForJWS(fromSwitchHeaders, this.db.config.protocolVersions, true)
} else {
formattedHeaders = generateRequestHeaders(fromSwitchHeaders, true)
formattedHeaders = generateRequestHeaders(fromSwitchHeaders, this.db.config.protocolVersions, true)
}

let opts = {
Expand Down
10 changes: 5 additions & 5 deletions src/model/quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ class QuotesModel {
}

const fullCallbackUrl = `${endpoint}/quotes`
const newHeaders = generateRequestHeaders(headers, this.config.protocolVersions)
const newHeaders = generateRequestHeaders(headers, this.db.config.protocolVersions)

this.writeLog(`Forwarding quote request to endpoint: ${fullCallbackUrl}`)
this.writeLog(`Forwarding quote request headers: ${JSON.stringify(newHeaders)}`)
Expand Down Expand Up @@ -652,7 +652,7 @@ class QuotesModel {
// we need to strip off the 'accept' header
// for all PUT requests as per the API Specification Document
// https://github.com/mojaloop/mojaloop-specification/blob/master/API%20Definition%20v1.0.pdf
const newHeaders = generateRequestHeaders(headers, this.config.protocolVersions, true)
const newHeaders = generateRequestHeaders(headers, this.db.config.protocolVersions, true)

this.writeLog(`Forwarding quote response to endpoint: ${fullCallbackUrl}`)
this.writeLog(`Forwarding quote response headers: ${JSON.stringify(newHeaders)}`)
Expand Down Expand Up @@ -822,7 +822,7 @@ class QuotesModel {
}

const fullCallbackUrl = `${endpoint}/quotes/${quoteId}`
const newHeaders = generateRequestHeaders(headers, this.config.protocolVersions)
const newHeaders = generateRequestHeaders(headers, this.db.config.protocolVersions)

this.writeLog(`Forwarding quote get request to endpoint: ${fullCallbackUrl}`)

Expand Down Expand Up @@ -919,9 +919,9 @@ class QuotesModel {

// JWS Signer expects headers in lowercase
if (envConfig.jws && envConfig.jws.jwsSign && fromSwitchHeaders['fspiop-source'] === envConfig.jws.fspiopSourceToSign) {
formattedHeaders = generateRequestHeadersForJWS(fromSwitchHeaders, true)
formattedHeaders = generateRequestHeadersForJWS(fromSwitchHeaders, this.db.config.protocolVersions, true)
} else {
formattedHeaders = generateRequestHeaders(fromSwitchHeaders, this.config.protocolVersions, true)
formattedHeaders = generateRequestHeaders(fromSwitchHeaders, this.db.config.protocolVersions, true)
}

let opts = {
Expand Down
6 changes: 2 additions & 4 deletions test/unit/lib/util.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,14 +447,13 @@ describe('util', () => {
it('generates the default request headers', () => {
// Arrange
const expected = {
Accept: 'application/vnd.interoperability.quotes+json;version=1.1',
'Content-Type': 'application/vnd.interoperability.quotes+json;version=1.1',
'fspiop-destination': 'dfsp2',
'fspiop-source': 'dfsp1'
}

// Act
const result = generateRequestHeadersForJWS(mockData.headers, true)
const result = generateRequestHeadersForJWS(mockData.headers, config.protocolVersions, true)

// Assert
expect(result).toStrictEqual(expected)
Expand All @@ -470,8 +469,7 @@ describe('util', () => {
}

// Act
const result = generateRequestHeadersForJWS(mockData.headers, false)

const result = generateRequestHeadersForJWS(mockData.headers, config.protocolVersions, false)
// Assert
expect(result).toStrictEqual(expected)
})
Expand Down
2 changes: 1 addition & 1 deletion test/unit/model/bulkQuotes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ describe('BulkQuotesModel', () => {
requestId: mockData.bulkQuotePostRequest.bulkQuoteId
})
bulkQuotesModel.db.newTransaction.mockImplementation(() => mockTransaction)

bulkQuotesModel.db.config = mockConfig
bulkQuotesModel.db.createTransactionReference.mockImplementation(() => mockData.transactionReference)
bulkQuotesModel.db.getInitiatorType.mockImplementation(() => mockData.initiatorType)
bulkQuotesModel.db.getInitiator.mockImplementation(() => mockData.initiator)
Expand Down
2 changes: 1 addition & 1 deletion test/unit/model/quotes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ describe('QuotesModel', () => {
requestId: mockData.quoteRequest.quoteId
})
quotesModel.db.newTransaction.mockImplementation(() => mockTransaction)

quotesModel.db.config = mockConfig
quotesModel.db.createTransactionReference.mockImplementation(() => mockData.transactionReference)
quotesModel.db.getInitiatorType.mockImplementation(() => mockData.initiatorType)
quotesModel.db.getInitiator.mockImplementation(() => mockData.initiator)
Expand Down