Skip to content

Commit

Permalink
AUT-1706: Remove form-action header from /enter-code page
Browse files Browse the repository at this point in the history
  • Loading branch information
pskushwaha1 authored and LazarAlexandru-Constantin committed Nov 14, 2023
1 parent 858d8cc commit 1b5e7f2
Show file tree
Hide file tree
Showing 17 changed files with 370 additions and 141 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/build-and-push-frontend.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Build frontend
env:
DEPLOYER_ROLE: arn:aws:iam::114407264696:role/deployers/github-actions-publish-to-s3-for-code-signing
AWS_REGION: eu-west-2

#Deployer role is github actions publish code signing role & ECR repo are from Prod AWS Tooling acct

on:
push:
Expand All @@ -17,18 +19,18 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up AWS credentials
- name: Assume AWS DEPLOYER role in tooling acct
uses: aws-actions/configure-aws-credentials@v1-node16
with:
role-to-assume: ${{ env.DEPLOYER_ROLE }}
aws-region: eu-west-2
role-to-assume: ${{ secrets.DEPLOYER_ROLE }}
aws-region: ${{ env.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, tag, and push frontend
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: frontend-image-repository
ECR_REPOSITORY: ${{ secrets.TOOLING_ECR_FRONTEND_REPO }}
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
Expand All @@ -37,7 +39,7 @@ jobs:
working-directory: basic-auth-sidecar
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: basic-auth-sidecar-image-repository
ECR_REPOSITORY: ${{ secrets.BASIC_SIDECAR_ECR_REPO }}
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/deploy-frontend.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name: Deploy frontend

env:
DEPLOY_ROLE: arn:aws:iam::761723964695:role/build-auth-deploy-pipeline-GitHubActionsRole-160U5ADTRKQ2O
ARTIFACT_BUCKET: build-auth-deploy-pipeli-githubartifactsourcebuck-1o4hcrnik6ayv
AWS_REGION: eu-west-2

# Deploy role & Artificate buckets are Logical id GitHubActionsRole & GitHubArtifactSourceBucket Value from Build Pipeline

on:
push:
Expand All @@ -28,15 +29,15 @@ jobs:
- name: Set up AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ env.DEPLOY_ROLE }}
aws-region: eu-west-2
role-to-assume: ${{ secrets.DEPLOY_ROLE }}
aws-region: ${{ env.AWS_REGION }}

- name: Upload frontend Terraform files
working-directory: ci/terraform
run: |
zip -r frontend.zip .
S3_RESPONSE=`aws s3api put-object \
--bucket ${{ env.ARTIFACT_BUCKET }} \
--bucket ${{ secrets.ARTIFACT_BUCKET }} \
--key frontend.zip \
--body frontend.zip \
--metadata "repository=$GITHUB_REPOSITORY,commitsha=$GITHUB_SHA,committag=$GIT_TAG,commitmessage=$COMMIT_MSG"`
Expand Down
5 changes: 5 additions & 0 deletions src/app.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,17 @@ export const ZENDESK_THEMES = {
};

export const ZENDESK_FIELD_MAX_LENGTH = 1200;
export const ZENDESK_COUNTRY_MAX_LENGTH = 256;

export const PLACEHOLDER_REPLACEMENTS = [
{
search: "[maximumCharacters]",
replacement: ZENDESK_FIELD_MAX_LENGTH.toLocaleString(),
},
{
search: "[maximumCountryCharacters]",
replacement: ZENDESK_COUNTRY_MAX_LENGTH.toLocaleString(),
},
];

export enum NOTIFICATION_TYPE {
Expand Down
5 changes: 2 additions & 3 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import i18nextMiddleware from "i18next-http-middleware";
import * as path from "path";
import { configureNunjucks } from "./config/nunchucks";
import { i18nextConfigurationOptions } from "./config/i18next";
import { helmetConfiguration } from "./config/helmet";
import helmet from "helmet";

import { setHtmlLangMiddleware } from "./middleware/html-lang-middleware";
import i18next from "i18next";
Expand Down Expand Up @@ -83,6 +81,7 @@ import { setInternationalPhoneNumberSupportMiddleware } from "./middleware/set-i
import { checkYourEmailSecurityCodesRouter } from "./components/account-recovery/check-your-email-security-codes/check-your-email-security-codes-routes";
import { changeSecurityCodesConfirmationRouter } from "./components/account-recovery/change-security-codes-confirmation/change-security-codes-confirmation-routes";
import { outboundContactUsLinksMiddleware } from "./middleware/outbound-contact-us-links-middleware";
import { setCspHeaders } from "./middleware/set-csp-headers-middleware";

const APP_VIEWS = [
path.join(__dirname, "components"),
Expand Down Expand Up @@ -164,7 +163,7 @@ async function createApp(): Promise<express.Application> {
);

app.use(i18nextMiddleware.handle(i18next));
app.use(helmet(helmetConfiguration()));
app.use(setCspHeaders);

const redisConfig = isProduction
? await getRedisConfig(getAppEnv())
Expand Down
14 changes: 13 additions & 1 deletion src/components/contact-us/contact-us-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
SUPPORT_TYPE,
ZENDESK_THEMES,
ZENDESK_FIELD_MAX_LENGTH,
ZENDESK_COUNTRY_MAX_LENGTH,
CONTACT_US_REFERER_ALLOWLIST,
} from "../../app.constants";
import { contactUsService } from "./contact-us-service";
Expand Down Expand Up @@ -355,6 +356,7 @@ export function contactUsQuestionsGet(req: Request, res: Response): void {
}),
pageTitleHeading: pageTitle,
zendeskFieldMaxLength: ZENDESK_FIELD_MAX_LENGTH,
zendeskCountryMaxLength: ZENDESK_COUNTRY_MAX_LENGTH,
ipnSupport: res.locals.ipnSupport,
appErrorCode: getAppErrorCode(req.query.appErrorCode as string),
appSessionId: getAppSessionId(req.query.appSessionId as string),
Expand Down Expand Up @@ -395,6 +397,7 @@ export function contactUsQuestionsFormPostToSmartAgent(
optionalDescription: req.body.optionalDescription,
moreDetailDescription: req.body.moreDetailDescription,
serviceTryingToUse: req.body.serviceTryingToUse,
countryPhoneNumberFrom: req.body.countryPhoneNumberFrom,
},
themes: { theme: req.body.theme, subtheme: req.body.subtheme },
subject: "GOV.UK One Login",
Expand Down Expand Up @@ -449,6 +452,7 @@ export function contactUsQuestionsFormPostToZendesk(
optionalDescription: req.body.optionalDescription,
moreDetailDescription: req.body.moreDetailDescription,
serviceTryingToUse: req.body.serviceTryingToUse,
countryPhoneNumberFrom: req.body.countryPhoneNumberFrom,
},
themes: { theme: req.body.theme, subtheme: req.body.subtheme },
subject: "GOV.UK One Login",
Expand Down Expand Up @@ -566,10 +570,18 @@ export function getQuestionsFromFormTypeForMessageBody(
),
},
signInPhoneNumberIssue: {
moreDetailDescription: req.t(
issueDescription: req.t(
"pages.contactUsQuestions.signInPhoneNumberIssue.section1.header",
{ lng: "en" }
),
additionalDescription: req.t(
"pages.contactUsQuestions.signInPhoneNumberIssue.section2.header",
{ lng: "en" }
),
countryPhoneNumberFrom: req.t(
"pages.contactUsQuestions.signInPhoneNumberIssue.section3.header",
{ lng: "en" }
),
},
signingInProblem: {
issueDescription: req.t(
Expand Down
33 changes: 32 additions & 1 deletion src/components/contact-us/contact-us-questions-validation.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { body, check } from "express-validator";
import { validateBodyMiddleware } from "../../middleware/form-validation-middleware";
import { ValidationChainFunc } from "../../types";
import { ZENDESK_FIELD_MAX_LENGTH, ZENDESK_THEMES } from "../../app.constants";
import {
ZENDESK_FIELD_MAX_LENGTH,
ZENDESK_THEMES,
ZENDESK_COUNTRY_MAX_LENGTH,
} from "../../app.constants";
import { supportWelshInSupportForms } from "../../config";

export function setLanguageToReflectSupportForWelsh(
Expand Down Expand Up @@ -150,6 +154,24 @@ export function validateContactUsQuestionsRequest(): ValidationChainFunc {
{ value, lng: setLanguageToReflectSupportForWelsh(req.i18n.lng) }
);
}),
body("countryPhoneNumberFrom")
.optional()
.notEmpty()
.withMessage((value, { req }) => {
return req.t(
"pages.contactUsQuestions.signInPhoneNumberIssue.section3.ifBlankErrorMessage",
{ value, lng: setLanguageToReflectSupportForWelsh(req.i18n.lng) }
);
}),
body("countryPhoneNumberFrom")
.optional()
.isLength({ max: ZENDESK_COUNTRY_MAX_LENGTH })
.withMessage((value, { req }) => {
return req.t(
"pages.contactUsQuestions.signInPhoneNumberIssue.section3.ifTooLongErrorMessage",
{ value, lng: setLanguageToReflectSupportForWelsh(req.i18n.lng) }
);
}),
validateBodyMiddleware("contact-us/questions/index.njk"),
];
}
Expand Down Expand Up @@ -223,6 +245,9 @@ export function getErrorMessageForAccountCreationIssueDescription(
if (subtheme === ZENDESK_THEMES.AUTHENTICATOR_APP_PROBLEM) {
return "pages.contactUsQuestions.anotherProblem.section1.errorMessage";
}
if (subtheme === ZENDESK_THEMES.SIGN_IN_PHONE_NUMBER_ISSUE) {
return "pages.contactUsQuestions.signInPhoneNumberIssue.section1.errorMessage";
}
}

export function getErrorMessageForSigningInIssueDescription(
Expand Down Expand Up @@ -294,6 +319,9 @@ export function getLengthExceededErrorMessageForAccountCreationIssueDescription(
if (subtheme === ZENDESK_THEMES.SOMETHING_ELSE) {
return "pages.contactUsQuestions.issueDescriptionErrorMessage.anythingElseTooLongMessage";
}
if (subtheme === ZENDESK_THEMES.SIGN_IN_PHONE_NUMBER_ISSUE) {
return "pages.contactUsQuestions.issueDescriptionErrorMessage.entryTooLongMessage";
}
}

export function getLengthExceededErrorMessageForIdCheckAppIssueDescription(
Expand Down Expand Up @@ -365,4 +393,7 @@ export function getErrorMessageForAdditionalDescription(
) {
return "pages.contactUsQuestions.provingIdentityFaceToFaceSomethingElse.section2.errorMessage";
}
if (subtheme === ZENDESK_THEMES.SIGN_IN_PHONE_NUMBER_ISSUE) {
return "pages.contactUsQuestions.signInPhoneNumberIssue.section2.errorMessage";
}
}
5 changes: 5 additions & 0 deletions src/components/contact-us/contact-us-service-smart-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ export function contactUsServiceSmartAgent(
message.push(`<p>${descriptions.moreDetailDescription}</p>`);
}

if (descriptions.countryPhoneNumberFrom) {
message.push(`<h3>${questions.countryPhoneNumberFrom}</h3>`);
message.push(`<p>${descriptions.countryPhoneNumberFrom}</p>`);
}

return message.join("");
}

Expand Down
5 changes: 5 additions & 0 deletions src/components/contact-us/contact-us-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,11 @@ export function contactUsService(
htmlBody.push(`<p>${descriptions.serviceTryingToUse}</p>`);
}

if (descriptions.countryPhoneNumberFrom) {
htmlBody.push(`<span>[${questions.countryPhoneNumberFrom}]</span>`);
htmlBody.push(`<p>${descriptions.countryPhoneNumberFrom}</p>`);
}

htmlBody.push(`<span>[Ticket Identifier]</span>`);
if (optionalData.ticketIdentifier) {
htmlBody.push(`<p>${optionalData.ticketIdentifier}</p>`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,36 @@
text: 'pages.contactUsQuestions.signInPhoneNumberIssue.section1.header' | translateEnOnly,
classes: "govuk-label--s"
},
id: "issueDescription",
name: "issueDescription",
maxlength: zendeskFieldMaxLength,
value: issueDescription,
charactersAtLimitText: 'pages.contactUsQuestions.characterCountComponent.charactersAtLimitText' | translateEnOnly,
charactersUnderLimitText: {
other: 'pages.contactUsQuestions.characterCountComponent.charactersUnderLimitText.other' | translateEnOnly,
one: 'pages.contactUsQuestions.characterCountComponent.charactersUnderLimitText.one' | translateEnOnly
},
charactersOverLimitText: {
other: 'pages.contactUsQuestions.characterCountComponent.charactersOverLimitText.other' | translateEnOnly,
one: 'pages.contactUsQuestions.characterCountComponent.charactersOverLimitText.one' | translateEnOnly
},
errorMessage: {
text: errors['issueDescription'].text | translateEnOnly | replace('[maximumCharacters]', zendeskFieldMaxLength.toLocaleString())
} if (errors['issueDescription'])
}) }}

{{ govukCharacterCount({
label: {
text: 'pages.contactUsQuestions.signInPhoneNumberIssue.section2.header' | translateEnOnly,
classes: "govuk-label--s"
},
hint: {
text: 'pages.contactUsQuestions.signInPhoneNumberIssue.section1.paragraph1' | translateEnOnly
text: 'pages.contactUsQuestions.signInPhoneNumberIssue.section2.hintText' | translateEnOnly
},
id: "moreDetailDescription",
name: "moreDetailDescription",
id: "additionalDescription",
name: "additionalDescription",
maxlength: zendeskFieldMaxLength,
value: moreDetailDescription,
value: additionalDescription,
charactersAtLimitText: 'pages.contactUsQuestions.characterCountComponent.charactersAtLimitText' | translateEnOnly,
charactersUnderLimitText: {
other: 'pages.contactUsQuestions.characterCountComponent.charactersUnderLimitText.other' | translateEnOnly,
Expand All @@ -35,12 +58,28 @@
one: 'pages.contactUsQuestions.characterCountComponent.charactersOverLimitText.one' | translateEnOnly
},
errorMessage: {
text: errors['moreDetailDescription'].text | translateEnOnly | replace('[maximumCharacters]', zendeskFieldMaxLength.toLocaleString())
} if (errors['moreDetailDescription'])
text: errors['additionalDescription'].text | translateEnOnly | replace('[maximumCharacters]', zendeskFieldMaxLength.toLocaleString())
} if (errors['additionalDescription'])
}) }}

{{ govukInput({
label: {
text: 'pages.contactUsQuestions.signInPhoneNumberIssue.section3.header' | translateEnOnly,
classes: "govuk-label--s"
},
hint: {
text: 'pages.contactUsQuestions.signInPhoneNumberIssue.section3.hintText' | translateEnOnly
},
id: "countryPhoneNumberFrom",
name: "countryPhoneNumberFrom",
value: countryPhoneNumberFrom,
errorMessage: {
text: errors['countryPhoneNumberFrom'].text | translateEnOnly
} if (errors['countryPhoneNumberFrom'])
}) }}

{{ govukWarningText({
text:'pages.contactUsQuestions.personalInformation.paragraph1' | translateEnOnly,
text:'pages.contactUsQuestions.signInPhoneNumberIssue.personalInformation.paragraph' | translateEnOnly,
iconFallbackText: "Warning"
}) }}

Expand Down
Loading

0 comments on commit 1b5e7f2

Please sign in to comment.