generated from NHSDigital/nhs-notify-repository-template
-
Notifications
You must be signed in to change notification settings - Fork 0
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
CCM-7465: implement backend api PT.2 #260
Open
bhansell1
wants to merge
50
commits into
main
Choose a base branch
from
feature/CCM-7465_backend-api
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,825
−801
Open
Changes from 49 commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
8fd1458
CCM-7465: use JWT sub as owner field in ddb
bhansell1 1e04f87
CCM-7465: use subject for owner
bhansell1 33bd151
CCM-7465: remove undefined from API response
bhansell1 583b521
CCM-7465: implement backend api and update automated tests
bhansell1 e5252c3
CCM-7465: add dynamoDB to tf outputs and allow SRP auth flow. Which I…
bhansell1 d99ed4f
CCM-7465: update automated tests to check for logout link
bhansell1 9cb6154
CCM-7465: add the auth pages when in CI for automated tests
bhansell1 8ce2733
CCM-7465: don't build the backend
bhansell1 0c9b889
CCM-7465: don't deploy backend resources
bhansell1 6b8eeb2
CCM-7465: don't deploy backend resources
bhansell1 73544b6
CCM-7465: don't deploy backend resources
bhansell1 6be7690
CCM-7465: don't deploy backend resources
bhansell1 223bc6a
CCM-7465: don't deploy backend resources
bhansell1 c4c5cf3
CCM-7465: don't deploy backend resources
bhansell1 861937c
CCM-7465: add protected routes
bhansell1 cab3b5b
CCM-7465: add middleware
bhansell1 428cb83
CCM-7465: temporarily redirect back home
bhansell1 bbedfe9
CCM-7465: temporarily redirect back home
bhansell1 620f193
CCM-7465: set env vars required for amplify and next app
bhansell1 04cf3e6
CCM-7465: disable route protection
bhansell1 7cb6bb9
CCM-7465: change from bash to JS version of creating amplify outputs
bhansell1 3fb681c
CCM-7465: create a .env file for the CI tests
bhansell1 340e3ad
CCM-7465: clean up unused files
bhansell1 5b57282
Merge branch 'feature/CCM-7465_use-jwt-sub' of https://github.com/NHS…
bhansell1 5362455
CCM-7465: re-add protected routes
bhansell1 86eb40f
CCM-7465: add stdout logs to paywright for debugging
bhansell1 050dfe2
CCM-7465: add a 2 minute timeout for webserver load while debugging
bhansell1 49927ff
CCM-7465: remove authorization caching. Which is causing tests to fail
bhansell1 4c5abd4
CCM-7465: set retries to 3 to see if a retry helps with the tests.
bhansell1 61bd097
CCM-7465: fix automated test by creating a new page when asserting ba…
bhansell1 e3f8699
CCM-7465: update docs with tips. Fix linting and unit tests
bhansell1 1a83326
CCM-7465: pull meta from amplify_outputs in automated tests
bhansell1 bb724ad
CCM-7465: re-add redirect location when not signed in
bhansell1 5a5ec5a
CCM-7465: update token check in form-actions
bhansell1 c80a321
Merge branch 'main' of https://github.com/NHSDigital/nhs-notify-web-t…
bhansell1 b9424c8
CCM-7465: update artifacts upload to v4
bhansell1 2d61411
CCM-7465: force manage templates to be SSR'd
bhansell1 41b7cf4
CCM-7465: update common tests to assert logout link
bhansell1 78b44ae
Fix accessibility tests
chris-elliott-nhsd cfc1835
Fix deleted check
chris-elliott-nhsd ff5853e
CCM-7465: update ttl on api. Turn off automated tests debugging
bhansell1 ad03634
Merge branch 'feature/CCM-7465_use_backend-api' of https://github.com…
bhansell1 c4cae3d
CCM-7465: revert new'ing up page in common tests
bhansell1 ab3edef
empty
bhansell1 f627f0d
CCM-7465: change ubuntu version to 22.04 which has TF installed
bhansell1 8a4d509
CCM-7465: update timeouts to 30 seconds and 10 seconds for expect. Cr…
bhansell1 93c3969
CCM-7465: fix linting
bhansell1 892e12a
CCM-7465: revert change to create a new page.
bhansell1 f81c1dd
CCM-7465: update comment about forcing dynamically rendered page
bhansell1 cbf9d1c
CCM-7465: update logout link to redirect back to ~templates
bhansell1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,37 +40,9 @@ permissions: | |
contents: read # This is required for actions/checkout | ||
|
||
jobs: | ||
environment-set-up: | ||
name: "Environment set up" | ||
runs-on: ubuntu-latest | ||
environment: dev | ||
timeout-minutes: 15 | ||
steps: | ||
- name: "Checkout code" | ||
uses: actions/checkout@v4 | ||
- name: "Repo setup" | ||
run: | | ||
npm ci | ||
- name: "Generate dependencies" | ||
run: | | ||
npm run generate-dependencies --workspaces --if-present | ||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ secrets.AWS_ASSUME_ROLE_NAME }} | ||
role-session-name: deployInfra | ||
aws-region: ${{ env.AWS_REGION }} | ||
- name: "Create Amplify sandbox" | ||
run: | | ||
./scripts/create_amplify_sandbox.sh | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: amplify_outputs.json | ||
path: frontend/amplify_outputs.json | ||
|
||
sandbox-set-up: | ||
name: "Sandbox set up" | ||
runs-on: ubuntu-latest | ||
runs-on: ubuntu-22.04 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See #259 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Once the above PR is merged into main I'll revert this change. |
||
environment: dev | ||
timeout-minutes: 15 | ||
steps: | ||
|
@@ -92,11 +64,10 @@ jobs: | |
with: | ||
name: sandbox_tf_outputs.json | ||
path: sandbox_tf_outputs.json | ||
|
||
test-security: | ||
name: "Security test" | ||
runs-on: ubuntu-latest | ||
needs: [environment-set-up, sandbox-set-up] | ||
runs-on: ubuntu-22.04 | ||
needs: [sandbox-set-up] | ||
timeout-minutes: 10 | ||
steps: | ||
- name: "Checkout code" | ||
|
@@ -109,17 +80,19 @@ jobs: | |
echo "Nothing to save" | ||
test-accessibility: | ||
name: "Accessibility test" | ||
runs-on: ubuntu-latest | ||
needs: [environment-set-up, sandbox-set-up] | ||
runs-on: ubuntu-22.04 | ||
needs: [sandbox-set-up] | ||
environment: dev | ||
env: | ||
INCLUDE_AUTH_PAGES: 'true' | ||
timeout-minutes: 10 | ||
steps: | ||
- name: "Checkout code" | ||
uses: actions/checkout@v4 | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: amplify_outputs.json | ||
path: frontend/ | ||
name: sandbox_tf_outputs.json | ||
path: ./ | ||
- name: "Repo setup" | ||
run: | | ||
npm ci | ||
|
@@ -133,25 +106,29 @@ jobs: | |
role-session-name: deployInfra | ||
aws-region: eu-west-2 | ||
- name: "Run accessibility test" | ||
run: make test-accessibility | ||
run: | | ||
npm run create-amplify-outputs file | ||
make test-accessibility | ||
- name: Archive accessibility results | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: accessibility | ||
path: ".reports/accessibility" | ||
test-ui-component: | ||
name: "UI Component test" | ||
runs-on: ubuntu-latest | ||
needs: [environment-set-up, sandbox-set-up] | ||
runs-on: ubuntu-22.04 | ||
needs: [sandbox-set-up] | ||
environment: dev | ||
env: | ||
INCLUDE_AUTH_PAGES: 'true' | ||
timeout-minutes: 10 | ||
steps: | ||
- name: "Checkout code" | ||
uses: actions/checkout@v4 | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: amplify_outputs.json | ||
path: frontend/ | ||
name: sandbox_tf_outputs.json | ||
path: ./ | ||
- name: "Repo setup" | ||
run: | | ||
npm ci | ||
|
@@ -168,45 +145,19 @@ jobs: | |
aws-region: eu-west-2 | ||
- name: "Run ui component test" | ||
run: | | ||
npm run create-amplify-outputs file | ||
cd tests/test-team | ||
npm run test:local-ui | ||
- name: Archive component test results | ||
if: success() || failure() | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: component test report | ||
path: "tests/test-team/playwright-report" | ||
environment-tear-down: | ||
name: "Environment tear down" | ||
if: success() || failure() | ||
runs-on: ubuntu-latest | ||
needs: [test-accessibility, test-ui-component] | ||
environment: dev | ||
steps: | ||
- name: "Checkout code" | ||
uses: actions/checkout@v4 | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: amplify_outputs.json | ||
path: frontend/ | ||
- name: "Repo setup" | ||
run: | | ||
npm ci | ||
- name: "Generate dependencies" | ||
run: | | ||
npm run generate-dependencies --workspaces --if-present | ||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ secrets.AWS_ASSUME_ROLE_NAME }} | ||
role-session-name: deployInfra | ||
aws-region: eu-west-2 | ||
- name: "Destroy Amplify sandbox" | ||
run: | | ||
(cd frontend && npm run destroy-sandbox -- --identifier "wf-${GITHUB_RUN_ID}") | ||
sandbox-tear-down: | ||
name: "Sandbox tear down" | ||
if: success() || failure() | ||
runs-on: ubuntu-latest | ||
runs-on: ubuntu-22.04 | ||
needs: [test-accessibility, test-ui-component] | ||
environment: dev | ||
steps: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,3 +82,4 @@ sandbox_cognito_auth_token.json | |
|
||
frontend/public/testing | ||
.vscode/launch.json | ||
auth.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Includes auth pages when building web frontend in production mode. | ||
INCLUDE_AUTH_PAGES='' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1 @@ | ||
import { defineBackend } from '@aws-amplify/backend'; | ||
import { PolicyStatement, Effect } from 'aws-cdk-lib/aws-iam'; | ||
import { auth } from './auth/resource'; | ||
import { data } from './data/resource'; | ||
import { sendEmail } from './functions/send-email/resource'; | ||
|
||
const backend = defineBackend({ | ||
auth, | ||
data, | ||
sendEmail, | ||
}); | ||
|
||
const sendEmailLambda = backend.sendEmail.resources.lambda; | ||
|
||
const attachPolicy = new PolicyStatement({ | ||
sid: 'AmplifySendEmail', | ||
effect: Effect.ALLOW, | ||
actions: ['ses:SendRawEmail'], | ||
resources: [`arn:aws:ses:eu-west-2:${process.env.ACCOUNT_ID}:identity/*`], | ||
}); | ||
|
||
sendEmailLambda.addToRolePolicy(attachPolicy); | ||
|
||
backend.data.resources.cfnResources.amplifyDynamoDbTables.TemplateStorage.timeToLiveAttribute = | ||
{ | ||
attributeName: 'ttl', | ||
enabled: true, | ||
}; | ||
/* eslint-disable unicorn/no-empty-file */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GitHub was failing due to V3 being depreciated.