Skip to content

Commit

Permalink
Merge pull request #2484 from alphagov/PP-7583-fix-inconsistent-accou…
Browse files Browse the repository at this point in the history
…nt-id-types

PP-7583 Fix inconsistency in setting session gateway account id
  • Loading branch information
sfount authored Jan 13, 2021
2 parents b22935c + 9abbc30 commit d062a9a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion app/middleware/get-service-and-gateway-account.middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ module.exports = async function getServiceAndGatewayAccount (req, res, next) {
req.account = gatewayAccount
// TODO: To be removed once URLs are updated to use the format /service/:serviceExternalId/account/:gatewayAccountExternalId/xxx.
// Currently authService.getCurrentGatewayAccountId() sets below if account is available on session or derives one from user services.
req.gateway_account = { currentGatewayAccountId: gatewayAccount.gateway_account_id, currentGatewayAccountExternalId: gatewayAccount.external_id }
req.gateway_account = {
currentGatewayAccountId: gatewayAccount.gateway_account_id && String(gatewayAccount.gateway_account_id),
currentGatewayAccountExternalId: gatewayAccount.external_id
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe('middleware: getGatewayAccountAndService', () => {
expect(req.service.externalId).to.equal('some-service-external-id')
expect(req.service.hasCardGatewayAccount).to.equal(true)

expect(req.gateway_account.currentGatewayAccountId).to.equal(1)
expect(req.gateway_account.currentGatewayAccountId).to.equal('1')
})
it('should error, if both gateway account external ID and service external ID cannot be resolved', async () => {
const getGatewayAccountAndService = setupGetGatewayAccountAndService(1, 'some-gateway-external-id', 'worldpay', 'some-service-external-id')
Expand Down

0 comments on commit d062a9a

Please sign in to comment.