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

PP-11594 Add ‘sandbox’ to ‘isDigitalWalletSupported’ test. #4143

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
41c8b08
PP-11594 Add ‘sandbox’ to ‘isDigitalWalletSupported’ test.
JFSGDS Oct 13, 2023
2a65bfd
BAU: Fix Dependabot Docker ignore
katstevens Oct 17, 2023
0dd38e5
Merge pull request #4144 from alphagov/BAU-fix-dependabot-docker-ignore
katstevens Oct 17, 2023
555e58d
Bump node from 18.17.1-alpine3.18 to 18.18.2-alpine3.18
dependabot[bot] Oct 17, 2023
a8bfea6
Merge pull request #4145 from alphagov/dependabot/docker/node-18.18.2…
katstevens Oct 18, 2023
fcf8c67
PP-9916 Change test card number in Stripe test accounts
JFSGDS Oct 18, 2023
bd9a04f
Bump @babel/traverse from 7.22.10 to 7.23.2
dependabot[bot] Oct 19, 2023
fc19af8
Merge pull request #4147 from alphagov/dependabot/npm_and_yarn/babel/…
katstevens Oct 19, 2023
5a6a9ed
PP-9916 Change test card number in Stripe test accounts
JFSGDS Oct 19, 2023
fc2ef7f
PP-9916 Change test card number in Stripe test accounts
JFSGDS Oct 19, 2023
4048451
PP-9916 Change test card number in Stripe test accounts
JFSGDS Oct 19, 2023
2807062
Merge pull request #4146 from alphagov/PP-9916-change-test-card-numbe…
JFSGDS Oct 20, 2023
7f524f8
PP-7843 Stop selecting default option on permission level radios (#4148)
hjvoid Oct 23, 2023
7281d7f
PP-11594 Add ‘sandbox’ to ‘isDigitalWalletSupported’ test.
JFSGDS Oct 13, 2023
d6f0428
Merge branch 'PP-11594-enable-apple-gpay-for-sandbox-accts' of github…
JFSGDS Oct 26, 2023
d4d525f
PP-11594 Remove Pact tests no longer required
JFSGDS Oct 26, 2023
dacbb22
PP-11594 Fix linting errors picked up during build.
JFSGDS Oct 26, 2023
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
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ updates:
ignore:
- dependency-name: node
versions:
- ">= 18"
- ">= 19"
- package-ecosystem: github-actions
directory: "/"
schedule:
Expand Down
15 changes: 10 additions & 5 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,6 @@
{
"path": "detect_secrets.filters.allowlist.is_line_allowlisted"
},
{
"path": "detect_secrets.filters.common.is_baseline_file",
"filename": ".secrets.baseline"
},
{
"path": "detect_secrets.filters.common.is_ignored_due_to_verification_policies",
"min_level": 2
Expand Down Expand Up @@ -384,6 +380,15 @@
"line_number": 5
}
],
"test/cypress/integration/demo-payment/mock-cards.cy.js": [
{
"type": "Hex High Entropy String",
"filename": "test/cypress/integration/demo-payment/mock-cards.cy.js",
"hashed_secret": "7bb363901b8a686a4d3e1949032e469901cddaa8",
"is_verified": false,
"line_number": 5
}
],
"test/cypress/integration/index/index.cy.js": [
{
"type": "Hex High Entropy String",
Expand Down Expand Up @@ -894,5 +899,5 @@
}
]
},
"generated_at": "2023-08-17T11:37:31Z"
"generated_at": "2023-10-19T14:35:18Z"
}
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:18.17.1-alpine3.18@sha256:982b5b6f07cd9241c9ebb163829067deac8eaefc57cfa8f31927f4b18943d971 as builder
FROM node:18.18.2-alpine3.18@sha256:0fe7402d11d8c85474c6ec6f9c9c8048cd0549c95535832b7f0735a4b47690a5 as builder

### Needed to run pact-mock-service
COPY sgerrand.rsa.pub /etc/apk/keys/sgerrand.rsa.pub
Expand All @@ -14,7 +14,7 @@ RUN npm ci --quiet
COPY . .
RUN npm run compile

FROM node:18.17.1-alpine3.18@sha256:982b5b6f07cd9241c9ebb163829067deac8eaefc57cfa8f31927f4b18943d971 AS final
FROM node:18.18.2-alpine3.18@sha256:0fe7402d11d8c85474c6ec6f9c9c8048cd0549c95535832b7f0735a4b47690a5 AS final

RUN ["apk", "--no-cache", "upgrade"]

Expand Down
4 changes: 3 additions & 1 deletion app/controllers/invite-user.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ async function invite (req, res, next) {
lodash.set(req, 'session.pageData', { invitee })
res.redirect(303, formatServicePathsFor(paths.service.teamMembers.invite, externalServiceId))
} else if (!role) {
next(new Error(`Cannot identify role from user input ${roleId}`))
req.flash('genericError', 'Select the team member’s permission level')
lodash.set(req, 'session.pageData', { invitee })
res.redirect(303, formatServicePathsFor(paths.service.teamMembers.invite, externalServiceId))
} else {
try {
await userService.createInviteToJoinService(invitee, senderId, externalServiceId, role.name)
Expand Down
23 changes: 23 additions & 0 deletions app/controllers/invite-user.controller.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,27 @@ describe('invite user controller', () => {
sinon.assert.calledWith(req.flash, 'genericError', 'Enter a valid email address')
sinon.assert.calledWith(res.redirect, 303, `/service/${externalServiceId}/team-members/invite`)
})

it('should error if a role is not recognised', async () => {
const externalServiceId = 'some-external-service-id'
const unknownRoleId = '999'
const req = {
user: { externalId: 'some-ext-id', serviceIds: ['1'] },
body: {
'invitee-email': '[email protected]',
'role-input': unknownRoleId
},
service: {
externalId: externalServiceId
},
flash: sinon.stub()
}
const res = {
redirect: sinon.stub()
}

await inviteUserController.invite(req, res)
sinon.assert.calledWith(req.flash, 'genericError', 'Select the team member’s permission level')
sinon.assert.calledWith(res.redirect, 303, `/service/${externalServiceId}/team-members/invite`)
})
})
1 change: 1 addition & 0 deletions app/utils/display-converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ module.exports = function (req, data, template) {
convertedData.isTestGateway = _.get(convertedData, 'currentGatewayAccount.type') === 'test'
convertedData.isSandbox = paymentProvider === 'sandbox'
convertedData.isDigitalWalletSupported = paymentProvider === 'worldpay' ||
(paymentProvider === 'sandbox' && process.env.ALLOW_ENABLING_DIGITAL_WALLETS_FOR_SANDBOX_ACCOUNT === 'true') ||
(paymentProvider === 'stripe' && process.env.ALLOW_ENABLING_DIGITAL_WALLETS_FOR_STRIPE_ACCOUNT === 'true') ||
(paymentProvider === 'stripe' && convertedData.isTestGateway === true)
Comment on lines 124 to 127
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wallet payments for stripe are now live so we can probably remove the env var that toggles this feature

Suggested change
convertedData.isDigitalWalletSupported = paymentProvider === 'worldpay' ||
(paymentProvider === 'sandbox' && process.env.ALLOW_ENABLING_DIGITAL_WALLETS_FOR_SANDBOX_ACCOUNT === 'true') ||
(paymentProvider === 'stripe' && process.env.ALLOW_ENABLING_DIGITAL_WALLETS_FOR_STRIPE_ACCOUNT === 'true') ||
(paymentProvider === 'stripe' && convertedData.isTestGateway === true)
convertedData.isDigitalWalletSupported = paymentProvider === 'worldpay' ||
(paymentProvider === 'sandbox' && process.env.ALLOW_ENABLING_DIGITAL_WALLETS_FOR_SANDBOX_ACCOUNT === 'true') ||
paymentProvider === 'stripe'

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might need to update some tests if taking this suggestion

convertedData.currentService = service
Expand Down
32 changes: 32 additions & 0 deletions app/utils/display-converter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const expect = chai.expect
describe('Display converter', function () {
afterEach(() => {
process.env.ALLOW_ENABLING_DIGITAL_WALLETS_FOR_STRIPE_ACCOUNT = undefined
process.env.ALLOW_ENABLING_DIGITAL_WALLETS_FOR_SANDBOX_ACCOUNT = undefined
})

it('should add full_type to account if type is test', function () {
Expand Down Expand Up @@ -80,4 +81,35 @@ describe('Display converter', function () {
}, {}, {})
expect(data.isDigitalWalletSupported).to.equal(true)
})
it('should return isDigitalWalletSupported=false for sandbox account when ALLOW_ENABLING_DIGITAL_WALLETS_FOR_SANDBOX_ACCOUNT is not set', () => {
const data = displayConverter({
account: {
type: 'test',
payment_provider: 'sandbox'
}
}, {}, {})
expect(data.isDigitalWalletSupported).to.equal(false)
})

it('should return isDigitalWalletSupported=false for sandbox account when ALLOW_ENABLING_DIGITAL_WALLETS_FOR_SANDBOX_ACCOUNT is false', () => {
process.env.ALLOW_ENABLING_DIGITAL_WALLETS_FOR_SANDBOX_ACCOUNT = 'false'
const data = displayConverter({
account: {
type: 'test',
payment_provider: 'sandbox'
}
}, {}, {})
expect(data.isDigitalWalletSupported).to.equal(false)
})

it('should return isDigitalWalletSupported=true for sandbox account when ALLOW_ENABLING_DIGITAL_WALLETS_FOR_SANDBOX_ACCOUNT is true', () => {
process.env.ALLOW_ENABLING_DIGITAL_WALLETS_FOR_SANDBOX_ACCOUNT = 'true'
const data = displayConverter({
account: {
type: 'test',
payment_provider: 'sandbox'
}
}, {}, {})
expect(data.isDigitalWalletSupported).to.equal(true)
})
})
10 changes: 9 additions & 1 deletion app/views/dashboard/demo-payment/mock-card-details.njk
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
{% extends "../../layout.njk" %}

{% set card %}
{% if currentGatewayAccount.payment_provider === 'stripe' %}
<p class="govuk-!-font-size-24 govuk-!-font-weight-bold">4000<span class="govuk-!-padding-left-3 govuk-!-padding-right-3">0582</span><span class="govuk-!-padding-right-3">6000</span>0005</p>
{% else %}
<p class="govuk-!-font-size-24 govuk-!-font-weight-bold">4000<span class="govuk-!-padding-left-3 govuk-!-padding-right-3">0566</span><span class="govuk-!-padding-right-3">5566</span>5556</p>
{% endif %}
{% endset %}

{% block pageTitle %}
Mock card numbers for demo payment - {{currentService.name}} {{currentGatewayAccount.full_type}} - GOV.UK Pay
{% endblock %}
Expand All @@ -21,7 +29,7 @@

{{
govukInsetText({
html: '<p class="govuk-!-font-size-24 govuk-!-font-weight-bold">4000<span class="govuk-!-padding-left-3 govuk-!-padding-right-3">0566</span><span class="govuk-!-padding-right-3">5566</span>5556</p>'
html: card
})
}}

Expand Down
4 changes: 2 additions & 2 deletions app/views/team-members/team-member-invite.njk
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Invite a new team member - GOV.UK Pay
label: {
classes: "govuk-label--s"
},
checked: true,
checked: false,
hint: {
html: "View transactions<br>
Cannot refund payments<br>
Expand Down Expand Up @@ -155,7 +155,7 @@ Invite a new team member - GOV.UK Pay
label: {
classes: "govuk-label--s"
},
checked: true,
checked: false,
hint: {
html: "View transactions<br>
Cannot refund payments<br>
Expand Down
Loading