generated from hmcts/expressjs-monorepo-template
-
Notifications
You must be signed in to change notification settings - Fork 2
VIBE-221 Subscription Fulfilment Email #155
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
Open
junaidiqbalmoj
wants to merge
41
commits into
master
Choose a base branch
from
feature/VIBE-221-subscription-fulfilment-email
base: master
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.
Open
Changes from 28 commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
e24e24e
Add technical planning for VIBE-221: Subscription Email Notifications
github-actions[bot] 4906e0f
Add technical planning documentation for VIBE-221
github-actions[bot] 4ec68ca
Add technical planning for VIBE-221
github-actions[bot] c7956a7
Add technical planning documentation for VIBE-221
github-actions[bot] f314634
docs: Add technical plan for VIBE-221 - Email notification backend
github-actions[bot] a394aac
Merge branch 'master' into feature/VIBE-221-subscription-fulfilment-e…
junaidiqbalmoj dfe5ea0
WIP
junaidiqbalmoj b1fc68b
add notifications, fix tests
junaidiqbalmoj 0f83f5e
Merge branch 'feature/VIBE-221-subscription-fulfilment-email' of http…
junaidiqbalmoj 203d22c
chore: remove old notification library (singular)
junaidiqbalmoj 010ca9c
fix: update import from @hmcts/notification to @hmcts/notifications
junaidiqbalmoj 88f8587
revert changes
junaidiqbalmoj 0611033
remove files not needed
junaidiqbalmoj 0f756f6
fix: resolve govnotify-client test failure
junaidiqbalmoj 874a266
fix: correct notification service API for manual uploads
junaidiqbalmoj 1cec266
fix: make database migrations idempotent
junaidiqbalmoj 72975eb
fix: remove duplicate conflicting migration
junaidiqbalmoj 54f3093
fix: make notification audit log migration fully idempotent
junaidiqbalmoj 8a31e67
fix sonar issue
junaidiqbalmoj bda15fa
add code coverage
junaidiqbalmoj 7e59f0b
add end to end tests
junaidiqbalmoj 96271e3
add end to end tests
junaidiqbalmoj b7dca26
fix bug
junaidiqbalmoj cb9ba2d
fix end to end tests
junaidiqbalmoj 7d65b1b
end to end tests on pipeline
junaidiqbalmoj 8137cbf
add readme file for github secret setup
junaidiqbalmoj 698e4c3
fix build
junaidiqbalmoj c5f21bd
fix end to end tests build
junaidiqbalmoj 728987e
fix end to end to use CFT verified user
junaidiqbalmoj 62993b1
add subscription for location which exists in db
junaidiqbalmoj 3f79d49
fix end to end tests
junaidiqbalmoj 56bbb97
fix code review comments
junaidiqbalmoj 72a0d7b
fix tests and code review comments
junaidiqbalmoj b1b3958
fix build
junaidiqbalmoj aafca23
Merge branch 'master' into feature/VIBE-221-subscription-fulfilment-e…
junaidiqbalmoj 91ea006
fix bug
junaidiqbalmoj 9fe6e4a
fix end to end tests
junaidiqbalmoj 719c03c
fix build
junaidiqbalmoj 61ad3b3
fix build
junaidiqbalmoj 40a88ff
Delete .claude/.DS_Store
junaidiqbalmoj ce6dbca
refactoring
junaidiqbalmoj 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 hidden or 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 hidden or 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
55 changes: 55 additions & 0 deletions
55
apps/postgres/prisma/migrations/20251201095418_add_notification_audit_log/migration.sql
This file contains hidden or 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,55 @@ | ||
| -- DropForeignKey (only if exists) | ||
| ALTER TABLE "ingestion_log" DROP CONSTRAINT IF EXISTS "fk_blob_artefact"; | ||
|
|
||
| -- AlterTable (only if DEFAULT exists) | ||
| DO $$ BEGIN | ||
| IF EXISTS ( | ||
| SELECT 1 FROM information_schema.columns | ||
| WHERE table_name = 'ingestion_log' | ||
| AND column_name = 'id' | ||
| AND column_default IS NOT NULL | ||
| ) THEN | ||
| ALTER TABLE "ingestion_log" ALTER COLUMN "id" DROP DEFAULT; | ||
| END IF; | ||
| END $$; | ||
|
|
||
| -- CreateTable (only if not exists) | ||
| CREATE TABLE IF NOT EXISTS "notification_audit_log" ( | ||
| "notification_id" UUID NOT NULL, | ||
| "subscription_id" UUID NOT NULL, | ||
| "user_id" UUID NOT NULL, | ||
| "publication_id" UUID NOT NULL, | ||
| "status" TEXT NOT NULL DEFAULT 'Pending', | ||
| "error_message" TEXT, | ||
| "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| "sent_at" TIMESTAMP(3), | ||
|
|
||
| CONSTRAINT "notification_audit_log_pkey" PRIMARY KEY ("notification_id") | ||
| ); | ||
|
|
||
| -- CreateIndex (only if not exists) | ||
| CREATE INDEX IF NOT EXISTS "notification_audit_log_publication_id_idx" ON "notification_audit_log"("publication_id"); | ||
|
|
||
| -- CreateIndex (only if not exists) | ||
| CREATE INDEX IF NOT EXISTS "notification_audit_log_status_idx" ON "notification_audit_log"("status"); | ||
|
|
||
| -- CreateIndex (only if not exists) | ||
| CREATE UNIQUE INDEX IF NOT EXISTS "notification_audit_log_user_id_publication_id_key" ON "notification_audit_log"("user_id", "publication_id"); | ||
|
|
||
| -- AddForeignKey (only if not exists) | ||
| DO $$ BEGIN | ||
| IF NOT EXISTS ( | ||
| SELECT 1 FROM pg_constraint WHERE conname = 'ingestion_log_artefact_id_fkey' | ||
| ) THEN | ||
| ALTER TABLE "ingestion_log" ADD CONSTRAINT "ingestion_log_artefact_id_fkey" FOREIGN KEY ("artefact_id") REFERENCES "artefact"("artefact_id") ON DELETE SET NULL ON UPDATE CASCADE; | ||
| END IF; | ||
| END $$; | ||
|
|
||
| -- AddForeignKey (only if not exists) | ||
| DO $$ BEGIN | ||
| IF NOT EXISTS ( | ||
| SELECT 1 FROM pg_constraint WHERE conname = 'notification_audit_log_subscription_id_fkey' | ||
| ) THEN | ||
| ALTER TABLE "notification_audit_log" ADD CONSTRAINT "notification_audit_log_subscription_id_fkey" FOREIGN KEY ("subscription_id") REFERENCES "subscription"("subscription_id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
| END IF; | ||
| END $$; |
15 changes: 15 additions & 0 deletions
15
apps/postgres/prisma/migrations/20251201155125_add_gov_notify_id/migration.sql
This file contains hidden or 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,15 @@ | ||
| -- Add gov_notify_id column to notification_audit_log (idempotent) | ||
| DO $$ BEGIN | ||
| IF NOT EXISTS ( | ||
| SELECT 1 FROM information_schema.columns | ||
| WHERE table_name = 'notification_audit_log' | ||
| AND column_name = 'gov_notify_id' | ||
| ) THEN | ||
| ALTER TABLE "notification_audit_log" | ||
| ADD COLUMN "gov_notify_id" TEXT; | ||
| END IF; | ||
| END $$; | ||
|
|
||
| -- Create index for gov_notify_id lookups (idempotent) | ||
| CREATE INDEX IF NOT EXISTS "notification_audit_log_gov_notify_id_idx" | ||
| ON "notification_audit_log"("gov_notify_id"); |
2 changes: 2 additions & 0 deletions
2
...gres/prisma/migrations/20251202095746_remove_notification_unique_constraint/migration.sql
This file contains hidden or 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 @@ | ||
| -- DropIndex | ||
| DROP INDEX "notification_audit_log_user_id_publication_id_key"; |
This file contains hidden or 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 hidden or 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,7 +1,8 @@ | ||
| // Schema discovery functionality for module integration | ||
| import { prismaSchemas as locationSchemas } from "@hmcts/location/config"; | ||
| import { prismaSchemas as notificationsSchemas } from "@hmcts/notifications/config"; | ||
| import { prismaSchemas as subscriptionsSchemas } from "@hmcts/subscriptions/config"; | ||
|
|
||
| export function getPrismaSchemas(): string[] { | ||
| return [subscriptionsSchemas, locationSchemas]; | ||
| return [subscriptionsSchemas, locationSchemas, notificationsSchemas]; | ||
| } |
This file contains hidden or 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 hidden or 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,119 @@ | ||
| # GitHub Secrets Configuration | ||
|
|
||
| This document describes the GitHub Secrets required for running E2E tests in CI/CD pipelines. | ||
|
|
||
| ## Required Secrets | ||
|
|
||
| The following secrets must be configured in your GitHub repository settings (`Settings` > `Secrets and variables` > `Actions`): | ||
|
|
||
| ### API Authentication (Blob Ingestion & Notifications) | ||
|
|
||
| | Secret Name | Description | Used By | | ||
| |------------|-------------|---------| | ||
| | `APP_TENANT_ID` | Azure AD Tenant ID | API authentication | | ||
| | `APP_PIP_DATA_MANAGEMENT_ID` | Azure AD Application Client ID | API authentication | | ||
| | `APP_PIP_DATA_MANAGEMENT_PWD` | Azure AD Application Client Secret | API authentication | | ||
| | `APP_PIP_DATA_MANAGEMENT_SCOPE` | Azure AD Application Scope | API authentication | | ||
|
|
||
| ### GOV.UK Notify (Email Notifications) | ||
|
|
||
| | Secret Name | Description | Used By | | ||
| |------------|-------------|---------| | ||
| | `GOVUK_NOTIFY_API_KEY` | GOV.UK Notify API Key | Notification E2E tests | | ||
| | `GOVUK_NOTIFY_TEMPLATE_ID_SUBSCRIPTION` | GOV.UK Notify Template ID for subscription notifications | Notification E2E tests | | ||
|
|
||
| ### SSO Authentication | ||
|
|
||
| | Secret Name | Description | | ||
| |------------|-------------| | ||
| | `SESSION_SECRET` | Session encryption secret | | ||
| | `SSO_CLIENT_ID` | SSO Client ID | | ||
| | `SSO_CLIENT_SECRET` | SSO Client Secret | | ||
| | `SSO_CONFIG_ENDPOINT` | SSO configuration endpoint | | ||
| | `SSO_SG_SYSTEM_ADMIN` | SSO System Admin Group ID | | ||
| | `SSO_SG_ADMIN_CTSC` | SSO CTSC Admin Group ID | | ||
| | `SSO_SG_ADMIN_LOCAL` | SSO Local Admin Group ID | | ||
|
|
||
| ### Test User Credentials (SSO) | ||
|
|
||
| | Secret Name | Description | | ||
| |------------|-------------| | ||
| | `SSO_TEST_SYSTEM_ADMIN_ACCOUNT_USER` | System Admin test user email | | ||
| | `SSO_TEST_SYSTEM_ADMIN_ACCOUNT_PWD` | System Admin test user password | | ||
| | `SSO_TEST_ADMIN_LOCAL_ACCOUNT_USER` | Local Admin test user email | | ||
| | `SSO_TEST_ADMIN_LOCAL_ACCOUNT_PWD` | Local Admin test user password | | ||
| | `SSO_TEST_ADMIN_ACCOUNT_CTSC_USER` | CTSC Admin test user email | | ||
| | `SSO_TEST_ADMIN_ACCOUNT_CTSC_PWD` | CTSC Admin test user password | | ||
| | `SSO_TEST_NO_ROLES_ACCOUNT_USER` | No roles test user email | | ||
| | `SSO_TEST_NO_ROLES_ACCOUNT_PWD` | No roles test user password | | ||
|
|
||
| ### Test User Credentials (CFT IDAM) | ||
|
|
||
| | Secret Name | Description | | ||
| |------------|-------------| | ||
| | `CFT_IDAM_CLIENT_SECRET` | CFT IDAM Client Secret | | ||
| | `CFT_VALID_TEST_ACCOUNT` | CFT IDAM valid test account email | | ||
| | `CFT_VALID_TEST_ACCOUNT_PASSWORD` | CFT IDAM valid test account password | | ||
| | `CFT_INVALID_TEST_ACCOUNT` | CFT IDAM invalid test account email | | ||
| | `CFT_INVALID_TEST_ACCOUNT_PASSWORD` | CFT IDAM invalid test account password | | ||
|
|
||
| ## Workflow Configuration | ||
|
|
||
| The E2E tests workflow (`.github/workflows/e2e.yml`) automatically uses these secrets when running tests on: | ||
| - Pull requests to `master` or `main` branches | ||
| - Direct pushes to `master` or `main` branches | ||
|
|
||
| ## Local Development | ||
|
|
||
| For local E2E test execution, the `run-with-credentials.js` script loads secrets from Azure Key Vault using Azure CLI authentication: | ||
|
|
||
| ```bash | ||
| # Authenticate with Azure | ||
| az login | ||
|
|
||
| # Run E2E tests with Azure Key Vault credentials | ||
| cd e2e-tests | ||
| node run-with-credentials.js blob-ingestion-notifications | ||
| ``` | ||
|
|
||
| The script automatically detects if running in CI (via `CI=true` environment variable) and uses GitHub Secrets instead of Azure Key Vault. | ||
|
|
||
| ## Environment Variables Mapping | ||
|
|
||
| The secrets are mapped to the following environment variables in the GitHub Actions workflow: | ||
|
|
||
| ```yaml | ||
| # API Authentication | ||
| AZURE_TENANT_ID: ${{ secrets.APP_TENANT_ID }} | ||
| AZURE_API_CLIENT_ID: ${{ secrets.APP_PIP_DATA_MANAGEMENT_ID }} | ||
| AZURE_API_CLIENT_SECRET: ${{ secrets.APP_PIP_DATA_MANAGEMENT_PWD }} | ||
| APP_PIP_DATA_MANAGEMENT_SCOPE: ${{ secrets.APP_PIP_DATA_MANAGEMENT_SCOPE }} | ||
|
|
||
| # GOV.UK Notify | ||
| GOVUK_NOTIFY_API_KEY: ${{ secrets.GOVUK_NOTIFY_API_KEY }} | ||
| GOVUK_NOTIFY_TEMPLATE_ID_SUBSCRIPTION: ${{ secrets.GOVUK_NOTIFY_TEMPLATE_ID_SUBSCRIPTION }} | ||
| ``` | ||
|
|
||
| ## Notification E2E Tests | ||
|
|
||
| The notification E2E tests (`blob-ingestion-notifications.spec.ts`) will: | ||
| - **Skip** the "verify GOV.UK Notify email content" test if `GOVUK_NOTIFY_API_KEY` is not set | ||
| - **Run** all other notification tests (email validation, skipped notifications, etc.) | ||
|
|
||
| To enable the full test suite in CI, ensure both `GOVUK_NOTIFY_API_KEY` and `GOVUK_NOTIFY_TEMPLATE_ID_SUBSCRIPTION` secrets are configured. | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| ### Tests are skipped in CI | ||
| - Verify all required secrets are configured in GitHub repository settings | ||
| - Check the GitHub Actions workflow logs for missing environment variables | ||
|
|
||
| ### Local tests fail to authenticate | ||
| - Ensure you're logged in to Azure CLI: `az login` | ||
| - Verify you have access to the `pip-bootstrap-stg-kv` Key Vault | ||
| - Check your Azure subscription is set correctly: `az account show` | ||
|
|
||
| ### API authentication errors | ||
| - Verify the Azure AD application credentials are correct | ||
| - Ensure the application has the required permissions/scopes | ||
| - Check the tenant ID matches your Azure AD tenant |
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.
Uh oh!
There was an error while loading. Please reload this page.