From 5231de0d1390334cd13604a3a53c5ec552934b55 Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Tue, 8 Aug 2023 12:00:59 -0300 Subject: [PATCH 01/59] ci(cypress): add cypress workflow to CI --- .github/workflows/cypress.yaml | 52 ++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/cypress.yaml diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml new file mode 100644 index 0000000000..44f984b0f0 --- /dev/null +++ b/.github/workflows/cypress.yaml @@ -0,0 +1,52 @@ +name: Cypress tests + +on: + push: + +jobs: + cypress-tests: + runs-on: ubuntu-latest + services: + postgres: + image: postgres:11.17-bullseye + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: test_notification_api + ports: + - 5432:5432 + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + + steps: + - name: Install libcurl + run: sudo apt-get update && sudo apt-get install libssl-dev libcurl4-openssl-dev + - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 + - name: Set up Python 3.10 + uses: actions/setup-python@57ded4d7d5e986d7296eab16560982c6dd7c923b # v4.6.0 + with: + python-version: '3.10' + - name: Upgrade pip + run: python -m pip install --upgrade pip + - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + - name: Install poetry + env: + POETRY_VERSION: 1.3.2 + run: pip install poetry==${POETRY_VERSION} && poetry --version + - name: Check poetry.lock aligns with pyproject.toml + run: poetry lock --check + - name: Install requirements + run: poetry install --with test + - name: Run cypress tests + uses: cypress-io/github-action@d79d2d530a66e641eb4a5f227e13bc985c60b964 # v4.2.2 + env: + CYPRESS_BASE_URL: http://localhost:6011 + with: + record: false + build: npx cypress info + working-directory: tests_cypress + spec: cypress/e2e/admin/api/sanity_check.cy.js \ No newline at end of file From 793346114b8b4d18d3ef69c14b0a4ac7b2f8b251 Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Tue, 8 Aug 2023 12:01:23 -0300 Subject: [PATCH 02/59] test: add a sanity check to see if the API is running in cypress --- tests_cypress/cypress/Notify/NotifyAPI.js | 10 +++++++++- tests_cypress/cypress/e2e/api/sanity_check.cy.js | 15 +++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 tests_cypress/cypress/e2e/api/sanity_check.cy.js diff --git a/tests_cypress/cypress/Notify/NotifyAPI.js b/tests_cypress/cypress/Notify/NotifyAPI.js index 714a6c7450..d4c35aa36b 100644 --- a/tests_cypress/cypress/Notify/NotifyAPI.js +++ b/tests_cypress/cypress/Notify/NotifyAPI.js @@ -105,7 +105,15 @@ const API = { } }); }, - + GetAPIStatus: () => { + return cy.request({ + url: '/', + method: 'GET', + headers: { + 'Content-Type': 'application/json', + }, + }); + } } export default { API, Utilities, Admin }; diff --git a/tests_cypress/cypress/e2e/api/sanity_check.cy.js b/tests_cypress/cypress/e2e/api/sanity_check.cy.js new file mode 100644 index 0000000000..2a2122f16d --- /dev/null +++ b/tests_cypress/cypress/e2e/api/sanity_check.cy.js @@ -0,0 +1,15 @@ +/// + +import config from '../../../config'; +import Notify from "../../Notify/NotifyAPI"; + +describe(`Sanity check [${config.CONFIG_NAME}]`, () => { + it("Can connect to API", () => { + Notify.API.GetAPIStatus().as('apiStatus'); + + cy.get('@apiStatus').then(resp => { + expect(resp.status).to.eq(200); + }); + }); +}); + From 1e169f64aaa99a5188f5a583b8464471542825ed Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Tue, 8 Aug 2023 12:08:52 -0300 Subject: [PATCH 03/59] fix(cypress workflow): pass cypress the cypress.env.json file --- .github/workflows/cypress.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index 44f984b0f0..a6ec9c9eab 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -21,10 +21,12 @@ jobs: - name: Install libcurl run: sudo apt-get update && sudo apt-get install libssl-dev libcurl4-openssl-dev - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 + - name: Set up Python 3.10 uses: actions/setup-python@57ded4d7d5e986d7296eab16560982c6dd7c923b # v4.6.0 with: python-version: '3.10' + - name: Upgrade pip run: python -m pip install --upgrade pip - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 @@ -33,14 +35,25 @@ jobs: key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }} restore-keys: | ${{ runner.os }}-pip- + - name: Install poetry env: POETRY_VERSION: 1.3.2 run: pip install poetry==${POETRY_VERSION} && poetry --version + - name: Check poetry.lock aligns with pyproject.toml run: poetry lock --check + - name: Install requirements run: poetry install --with test + + - name: run notify api + run: poetry run make run + + - name: Write the cypress.env.json file + run: | + echo '${{ secrets.CYPRESS_ENV_JSON }}' > tests_cypress/cypress.env.json + - name: Run cypress tests uses: cypress-io/github-action@d79d2d530a66e641eb4a5f227e13bc985c60b964 # v4.2.2 env: From 3c8da4d77a1d1517372c1d1728cb940718b36f90 Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Tue, 8 Aug 2023 15:29:45 +0000 Subject: [PATCH 04/59] fix: pass env to flask --- .github/workflows/cypress.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index a6ec9c9eab..96b0243bd8 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -48,7 +48,12 @@ jobs: run: poetry install --with test - name: run notify api - run: poetry run make run + env: + NOTIFY_ENVIRONMENT: test + run: | + poetry run flask db upgrade + poetry run make run + - name: Write the cypress.env.json file run: | From 05a481c57ebcbaa90b61dcdfb286486fd6ddc99e Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Tue, 8 Aug 2023 15:36:00 +0000 Subject: [PATCH 05/59] fix(cypress ci): pass more env vars --- .github/workflows/cypress.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index 96b0243bd8..c56e6b72d5 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -50,6 +50,7 @@ jobs: - name: run notify api env: NOTIFY_ENVIRONMENT: test + FLASK_APP: application.py run: | poetry run flask db upgrade poetry run make run From 26c48cc4026242682d6ad12075cc0af707ce3275 Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Tue, 8 Aug 2023 16:06:33 +0000 Subject: [PATCH 06/59] chore(ci/cypress): remove db upgrade for now --- .github/workflows/cypress.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index c56e6b72d5..0301f4d575 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -52,9 +52,7 @@ jobs: NOTIFY_ENVIRONMENT: test FLASK_APP: application.py run: | - poetry run flask db upgrade poetry run make run - - name: Write the cypress.env.json file run: | From 63e0af90cbc3a4ebe5cda5807a7d6f778bbb27b3 Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Tue, 8 Aug 2023 16:24:24 +0000 Subject: [PATCH 07/59] chore(ci): try to get the db and redis setup --- .github/workflows/cypress.yaml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index 0301f4d575..559fe4546f 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -16,12 +16,12 @@ jobs: ports: - 5432:5432 options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + redis: + image: redis:6.2@sha256:9e75c88539241ad7f61bc9c39ea4913b354064b8a75ca5fc40e1cef41b645bc0 + options: >- + --port 6380 steps: - - name: Install libcurl - run: sudo apt-get update && sudo apt-get install libssl-dev libcurl4-openssl-dev - - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 - - name: Set up Python 3.10 uses: actions/setup-python@57ded4d7d5e986d7296eab16560982c6dd7c923b # v4.6.0 with: @@ -47,11 +47,18 @@ jobs: - name: Install requirements run: poetry install --with test - - name: run notify api + - name: prep db and run notify api env: NOTIFY_ENVIRONMENT: test FLASK_APP: application.py + REDIS_ENABLED: 1 + REDIS_URL: redis://host.docker.internal:6380 + REDIS_PUBLISH_URL: redis://host.docker.internal:6380 + SQLALCHEMY_DATABASE_URI: postgresql://postgres:postgres@localhost:5432/test_notification_api + SQLALCHEMY_DATABASE_READER_URI: postgresql://reader:postgres@localhost:5432/test_notification_api run: | + createdb --user=postgres test_notification_api + poetry run flask db upgrade poetry run make run - name: Write the cypress.env.json file From 07b855ee3fa81c934b621f259fac1d65c8b7d532 Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Tue, 8 Aug 2023 16:28:13 +0000 Subject: [PATCH 08/59] chore(ci): update redis port config --- .github/workflows/cypress.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index 559fe4546f..044357b578 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -18,8 +18,8 @@ jobs: options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 redis: image: redis:6.2@sha256:9e75c88539241ad7f61bc9c39ea4913b354064b8a75ca5fc40e1cef41b645bc0 - options: >- - --port 6380 + ports: + - 6379:6379 steps: - name: Set up Python 3.10 @@ -52,8 +52,8 @@ jobs: NOTIFY_ENVIRONMENT: test FLASK_APP: application.py REDIS_ENABLED: 1 - REDIS_URL: redis://host.docker.internal:6380 - REDIS_PUBLISH_URL: redis://host.docker.internal:6380 + REDIS_URL: redis://host.docker.internal:6379 + REDIS_PUBLISH_URL: redis://host.docker.internal:6379 SQLALCHEMY_DATABASE_URI: postgresql://postgres:postgres@localhost:5432/test_notification_api SQLALCHEMY_DATABASE_READER_URI: postgresql://reader:postgres@localhost:5432/test_notification_api run: | From bd1edf651577abdaf6e5b04375ff8166f7bf5539 Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Tue, 8 Aug 2023 16:33:27 +0000 Subject: [PATCH 09/59] chore(ci): checkout the app :facepalm: --- .github/workflows/cypress.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index 044357b578..a946f05f31 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -22,6 +22,9 @@ jobs: - 6379:6379 steps: + - name: Checkout + uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 + - name: Set up Python 3.10 uses: actions/setup-python@57ded4d7d5e986d7296eab16560982c6dd7c923b # v4.6.0 with: From 8c25a10f1e0d388c1555e0ad990b353a1518c68d Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Tue, 8 Aug 2023 16:43:53 +0000 Subject: [PATCH 10/59] chore(ci): restore libcurl jobs --- .github/workflows/cypress.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index a946f05f31..40732253d3 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -22,8 +22,9 @@ jobs: - 6379:6379 steps: - - name: Checkout - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 + - name: Install libcurl + run: sudo apt-get update && sudo apt-get install libssl-dev libcurl4-openssl-dev + - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 - name: Set up Python 3.10 uses: actions/setup-python@57ded4d7d5e986d7296eab16560982c6dd7c923b # v4.6.0 From d5c3d431b49cb1ed82aeeab3d25141ecdec1a4e3 Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Tue, 8 Aug 2023 16:54:32 +0000 Subject: [PATCH 11/59] chore(ci): updated db url --- .github/workflows/cypress.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index 40732253d3..4f37344e15 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -58,8 +58,8 @@ jobs: REDIS_ENABLED: 1 REDIS_URL: redis://host.docker.internal:6379 REDIS_PUBLISH_URL: redis://host.docker.internal:6379 - SQLALCHEMY_DATABASE_URI: postgresql://postgres:postgres@localhost:5432/test_notification_api - SQLALCHEMY_DATABASE_READER_URI: postgresql://reader:postgres@localhost:5432/test_notification_api + SQLALCHEMY_DATABASE_URI: postgresql://postgres:postgres@postgres:5432/test_notification_api + SQLALCHEMY_DATABASE_READER_URI: postgresql://reader:postgres@postgres:5432/test_notification_api run: | createdb --user=postgres test_notification_api poetry run flask db upgrade From 7bbe305625b5b29715f185d0d023ec2f8e02290b Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Tue, 8 Aug 2023 17:02:06 +0000 Subject: [PATCH 12/59] chore(ci): add host to createdb command --- .github/workflows/cypress.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index 4f37344e15..ed62af1a5b 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -61,7 +61,7 @@ jobs: SQLALCHEMY_DATABASE_URI: postgresql://postgres:postgres@postgres:5432/test_notification_api SQLALCHEMY_DATABASE_READER_URI: postgresql://reader:postgres@postgres:5432/test_notification_api run: | - createdb --user=postgres test_notification_api + createdb --user=postgres --host host.docker.internal test_notification_api poetry run flask db upgrade poetry run make run From 052331c3c7b967627515caf963cb41c6d3b8ed6e Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Tue, 8 Aug 2023 17:09:15 +0000 Subject: [PATCH 13/59] chore(ci): try a different hostname --- .github/workflows/cypress.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index ed62af1a5b..f24239fd9c 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -56,12 +56,12 @@ jobs: NOTIFY_ENVIRONMENT: test FLASK_APP: application.py REDIS_ENABLED: 1 - REDIS_URL: redis://host.docker.internal:6379 - REDIS_PUBLISH_URL: redis://host.docker.internal:6379 + REDIS_URL: redis://redis:6379 + REDIS_PUBLISH_URL: redis://redis:6379 SQLALCHEMY_DATABASE_URI: postgresql://postgres:postgres@postgres:5432/test_notification_api SQLALCHEMY_DATABASE_READER_URI: postgresql://reader:postgres@postgres:5432/test_notification_api run: | - createdb --user=postgres --host host.docker.internal test_notification_api + createdb --user=postgres --host postgres test_notification_api poetry run flask db upgrade poetry run make run From 914e5a8a985664e192e88e281c0a2d8414f1f2e8 Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Tue, 8 Aug 2023 17:13:52 +0000 Subject: [PATCH 14/59] chore(ci): try localhost --- .github/workflows/cypress.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index f24239fd9c..b97be973e2 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -61,7 +61,7 @@ jobs: SQLALCHEMY_DATABASE_URI: postgresql://postgres:postgres@postgres:5432/test_notification_api SQLALCHEMY_DATABASE_READER_URI: postgresql://reader:postgres@postgres:5432/test_notification_api run: | - createdb --user=postgres --host postgres test_notification_api + createdb --user=postgres --host localhost test_notification_api poetry run flask db upgrade poetry run make run From 574ad57367e24b38d7c87d467eafaddf67c2dd38 Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Tue, 8 Aug 2023 17:19:56 +0000 Subject: [PATCH 15/59] chore(ci): remove createdb step --- .github/workflows/cypress.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index b97be973e2..b06d62b910 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -61,7 +61,6 @@ jobs: SQLALCHEMY_DATABASE_URI: postgresql://postgres:postgres@postgres:5432/test_notification_api SQLALCHEMY_DATABASE_READER_URI: postgresql://reader:postgres@postgres:5432/test_notification_api run: | - createdb --user=postgres --host localhost test_notification_api poetry run flask db upgrade poetry run make run From a31ecae0579dd402ca3312ec5aeb00d4e59255ff Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Tue, 8 Aug 2023 17:25:57 +0000 Subject: [PATCH 16/59] chore(ci): temporarily remove db upgrade command --- .github/workflows/cypress.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index b06d62b910..4896413e29 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -61,7 +61,6 @@ jobs: SQLALCHEMY_DATABASE_URI: postgresql://postgres:postgres@postgres:5432/test_notification_api SQLALCHEMY_DATABASE_READER_URI: postgresql://reader:postgres@postgres:5432/test_notification_api run: | - poetry run flask db upgrade poetry run make run - name: Write the cypress.env.json file From 76e02f1af5a2070e2c86e38bcb99b01bf97725f9 Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Tue, 8 Aug 2023 14:45:14 -0300 Subject: [PATCH 17/59] chore(ci): flail wildly --- .github/workflows/cypress.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index 4896413e29..30daf4ab91 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -51,6 +51,18 @@ jobs: - name: Install requirements run: poetry install --with test + - name: Copy site-packages in workspace + working-directory: ${{ github.workspace }} + shell: bash + run: | + mkdir -p "${{ github.workspace }}/env/" && cp -fR $(poetry env list | poetry env info -p)/lib/python3.10/site-packages "${{ github.workspace }}/env/" + + - name: Install development .env file + working-directory: ${{ github.workspace }} + shell: bash + run: | + cp -f .env.example .env + - name: prep db and run notify api env: NOTIFY_ENVIRONMENT: test From e8e8f8afd14a96341038c3ea535ec253c88e43e4 Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Tue, 8 Aug 2023 15:03:23 -0300 Subject: [PATCH 18/59] chore(ci): add flask debug --- .github/workflows/cypress.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index 30daf4ab91..f9607983cd 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -72,6 +72,7 @@ jobs: REDIS_PUBLISH_URL: redis://redis:6379 SQLALCHEMY_DATABASE_URI: postgresql://postgres:postgres@postgres:5432/test_notification_api SQLALCHEMY_DATABASE_READER_URI: postgresql://reader:postgres@postgres:5432/test_notification_api + FLASK_DEBUG: true run: | poetry run make run From 634fee7e6148234edf35058c070d73a05669caa4 Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Wed, 9 Aug 2023 17:29:23 +0000 Subject: [PATCH 19/59] chore(ci): add missing env vars to job (not passing any actual secrets yet) --- .github/workflows/cypress.yaml | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index f9607983cd..cfee63ac86 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -65,14 +65,36 @@ jobs: - name: prep db and run notify api env: - NOTIFY_ENVIRONMENT: test - FLASK_APP: application.py - REDIS_ENABLED: 1 + NOTIFICATION_QUEUE_PREFIX: 'andrewl-dev-notification-canada-ca' + + AWS_ACCESS_KEY_ID: not-a-real-secret + AWS_SECRET_ACCESS_KEY: not-a-real-secret + AWS_REGION: ca-central-1 + ASSET_DOMAIN: example.com + ASSET_UPLOAD_BUCKET_NAME: not-a-real-secret + CSV_UPLOAD_BUCKET_NAME: not-a-real-secret + DOCUMENTS_BUCKET: not-a-real-secret + NOTIFY_EMAIL_DOMAIN: not-a-real-secret + + ADMIN_CLIENT_SECRET: local_app REDIS_URL: redis://redis:6379 REDIS_PUBLISH_URL: redis://redis:6379 - SQLALCHEMY_DATABASE_URI: postgresql://postgres:postgres@postgres:5432/test_notification_api - SQLALCHEMY_DATABASE_READER_URI: postgresql://reader:postgres@postgres:5432/test_notification_api + SQLALCHEMY_DATABASE_TEST_URI: postgresql://postgres:postgres@postgres:5432/test_notification_api + DOCUMENT_DOWNLOAD_API_HOST: http://host.docker.internal:7000 + + FF_REDIS_BATCH_SAVING: true + FF_BATCH_INSERTION: true + REDIS_ENABLED: true + FF_CLOUDWATCH_METRICS_ENABLED: false + FF_SPIKE_SMS_DAILY_LIMIT: true + FRESH_DESK_ENABLED: false + + SECRET_KEY: local_secret_key + DANGEROUS_SALT: local_dangerous_salt + NOTIFY_ENVIRONMENT: test + FLASK_APP: application.py FLASK_DEBUG: true + WERKZEUG_DEBUG_PIN: off run: | poetry run make run From 66fd0cdb1db3ab6e44a93272eb9481140073c938 Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Wed, 9 Aug 2023 17:47:34 +0000 Subject: [PATCH 20/59] fix(ci): setup .env a different way --- .github/workflows/cypress.yaml | 61 +++++++++++++++------------------- 1 file changed, 27 insertions(+), 34 deletions(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index cfee63ac86..b32b9eb5a7 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -57,44 +57,37 @@ jobs: run: | mkdir -p "${{ github.workspace }}/env/" && cp -fR $(poetry env list | poetry env info -p)/lib/python3.10/site-packages "${{ github.workspace }}/env/" - - name: Install development .env file + - name: Setup .env working-directory: ${{ github.workspace }} - shell: bash run: | - cp -f .env.example .env + echo 'NOTIFICATION_QUEUE_PREFIX: andrewl-dev-notification-canada-ca' > .env + echo 'AWS_ACCESS_KEY_ID: not-a-real-secret' >> .env + echo 'AWS_SECRET_ACCESS_KEY: not-a-real-secret' >> .env + echo 'AWS_REGION: ca-central-1' >> .env + echo 'ASSET_DOMAIN: example.com' >> .env + echo 'ASSET_UPLOAD_BUCKET_NAME: not-a-real-secret' >> .env + echo 'CSV_UPLOAD_BUCKET_NAME: not-a-real-secret' >> .env + echo 'DOCUMENTS_BUCKET: not-a-real-secret' >> .env + echo 'NOTIFY_EMAIL_DOMAIN: not-a-real-secret' >> .env + echo 'ADMIN_CLIENT_SECRET: local_app' >> .env + echo 'REDIS_URL: redis://redis:6379' >> .env + echo 'REDIS_PUBLISH_URL: redis://redis:6379' >> .env + echo 'SQLALCHEMY_DATABASE_TEST_URI: postgresql://postgres:postgres@postgres:5432/test_notification_api' >> .env + echo 'DOCUMENT_DOWNLOAD_API_HOST: http://host.docker.internal:7000' >> .env + echo 'FF_REDIS_BATCH_SAVING: true' >> .env + echo 'FF_BATCH_INSERTION: true' >> .env + echo 'REDIS_ENABLED: true' >> .env + echo 'FF_CLOUDWATCH_METRICS_ENABLED: false' >> .env + echo 'FF_SPIKE_SMS_DAILY_LIMIT: true' >> .env + echo 'FRESH_DESK_ENABLED: false' >> .env + echo 'SECRET_KEY: local_secret_key' >> .env + echo 'DANGEROUS_SALT: local_dangerous_salt' >> .env + echo 'NOTIFY_ENVIRONMENT: test' >> .env + echo 'FLASK_APP: application.py' >> .env + echo 'FLASK_DEBUG: true' >> .env + echo 'WERKZEUG_DEBUG_PIN: off' >> .env - name: prep db and run notify api - env: - NOTIFICATION_QUEUE_PREFIX: 'andrewl-dev-notification-canada-ca' - - AWS_ACCESS_KEY_ID: not-a-real-secret - AWS_SECRET_ACCESS_KEY: not-a-real-secret - AWS_REGION: ca-central-1 - ASSET_DOMAIN: example.com - ASSET_UPLOAD_BUCKET_NAME: not-a-real-secret - CSV_UPLOAD_BUCKET_NAME: not-a-real-secret - DOCUMENTS_BUCKET: not-a-real-secret - NOTIFY_EMAIL_DOMAIN: not-a-real-secret - - ADMIN_CLIENT_SECRET: local_app - REDIS_URL: redis://redis:6379 - REDIS_PUBLISH_URL: redis://redis:6379 - SQLALCHEMY_DATABASE_TEST_URI: postgresql://postgres:postgres@postgres:5432/test_notification_api - DOCUMENT_DOWNLOAD_API_HOST: http://host.docker.internal:7000 - - FF_REDIS_BATCH_SAVING: true - FF_BATCH_INSERTION: true - REDIS_ENABLED: true - FF_CLOUDWATCH_METRICS_ENABLED: false - FF_SPIKE_SMS_DAILY_LIMIT: true - FRESH_DESK_ENABLED: false - - SECRET_KEY: local_secret_key - DANGEROUS_SALT: local_dangerous_salt - NOTIFY_ENVIRONMENT: test - FLASK_APP: application.py - FLASK_DEBUG: true - WERKZEUG_DEBUG_PIN: off run: | poetry run make run From 367a09d553d7ea41c3bf700672c5cd651139301d Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Wed, 9 Aug 2023 17:53:55 +0000 Subject: [PATCH 21/59] fix(ci): use correct env file syntax --- .github/workflows/cypress.yaml | 52 +++++++++++++++++----------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index b32b9eb5a7..cff19ae6c5 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -60,32 +60,32 @@ jobs: - name: Setup .env working-directory: ${{ github.workspace }} run: | - echo 'NOTIFICATION_QUEUE_PREFIX: andrewl-dev-notification-canada-ca' > .env - echo 'AWS_ACCESS_KEY_ID: not-a-real-secret' >> .env - echo 'AWS_SECRET_ACCESS_KEY: not-a-real-secret' >> .env - echo 'AWS_REGION: ca-central-1' >> .env - echo 'ASSET_DOMAIN: example.com' >> .env - echo 'ASSET_UPLOAD_BUCKET_NAME: not-a-real-secret' >> .env - echo 'CSV_UPLOAD_BUCKET_NAME: not-a-real-secret' >> .env - echo 'DOCUMENTS_BUCKET: not-a-real-secret' >> .env - echo 'NOTIFY_EMAIL_DOMAIN: not-a-real-secret' >> .env - echo 'ADMIN_CLIENT_SECRET: local_app' >> .env - echo 'REDIS_URL: redis://redis:6379' >> .env - echo 'REDIS_PUBLISH_URL: redis://redis:6379' >> .env - echo 'SQLALCHEMY_DATABASE_TEST_URI: postgresql://postgres:postgres@postgres:5432/test_notification_api' >> .env - echo 'DOCUMENT_DOWNLOAD_API_HOST: http://host.docker.internal:7000' >> .env - echo 'FF_REDIS_BATCH_SAVING: true' >> .env - echo 'FF_BATCH_INSERTION: true' >> .env - echo 'REDIS_ENABLED: true' >> .env - echo 'FF_CLOUDWATCH_METRICS_ENABLED: false' >> .env - echo 'FF_SPIKE_SMS_DAILY_LIMIT: true' >> .env - echo 'FRESH_DESK_ENABLED: false' >> .env - echo 'SECRET_KEY: local_secret_key' >> .env - echo 'DANGEROUS_SALT: local_dangerous_salt' >> .env - echo 'NOTIFY_ENVIRONMENT: test' >> .env - echo 'FLASK_APP: application.py' >> .env - echo 'FLASK_DEBUG: true' >> .env - echo 'WERKZEUG_DEBUG_PIN: off' >> .env + echo 'NOTIFICATION_QUEUE_PREFIX=andrewl-dev-notification-canada-ca' > .env + echo 'AWS_ACCESS_KEY_ID=not-a-real-secret' >> .env + echo 'AWS_SECRET_ACCESS_KEY=not-a-real-secret' >> .env + echo 'AWS_REGION=ca-central-1' >> .env + echo 'ASSET_DOMAIN=example.com' >> .env + echo 'ASSET_UPLOAD_BUCKET_NAME=not-a-real-secret' >> .env + echo 'CSV_UPLOAD_BUCKET_NAME=not-a-real-secret' >> .env + echo 'DOCUMENTS_BUCKET=not-a-real-secret' >> .env + echo 'NOTIFY_EMAIL_DOMAIN=not-a-real-secret' >> .env + echo 'ADMIN_CLIENT_SECRET=local_app' >> .env + echo 'REDIS_URL=redis://redis:6379' >> .env + echo 'REDIS_PUBLISH_URL=redis://redis:6379' >> .env + echo 'SQLALCHEMY_DATABASE_TEST_URI=postgresql://postgres:postgres@postgres:5432/test_notification_api' >> .env + echo 'DOCUMENT_DOWNLOAD_API_HOST=http://host.docker.internal:7000' >> .env + echo 'FF_REDIS_BATCH_SAVING=true' >> .env + echo 'FF_BATCH_INSERTION=true' >> .env + echo 'REDIS_ENABLED=true' >> .env + echo 'FF_CLOUDWATCH_METRICS_ENABLED=false' >> .env + echo 'FF_SPIKE_SMS_DAILY_LIMIT=true' >> .env + echo 'FRESH_DESK_ENABLED=false' >> .env + echo 'SECRET_KEY=local_secret_key' >> .env + echo 'DANGEROUS_SALT=local_dangerous_salt' >> .env + echo 'NOTIFY_ENVIRONMENT=test' >> .env + echo 'FLASK_APP=application.py' >> .env + echo 'FLASK_DEBUG=true' >> .env + echo 'WERKZEUG_DEBUG_PIN=off' >> .env - name: prep db and run notify api run: | From 75414f1c2729923467a61cc5bfb726626ec51401 Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Wed, 9 Aug 2023 17:58:35 +0000 Subject: [PATCH 22/59] fix(ci): :pray: --- .github/workflows/cypress.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index cff19ae6c5..faea4840d9 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -58,7 +58,6 @@ jobs: mkdir -p "${{ github.workspace }}/env/" && cp -fR $(poetry env list | poetry env info -p)/lib/python3.10/site-packages "${{ github.workspace }}/env/" - name: Setup .env - working-directory: ${{ github.workspace }} run: | echo 'NOTIFICATION_QUEUE_PREFIX=andrewl-dev-notification-canada-ca' > .env echo 'AWS_ACCESS_KEY_ID=not-a-real-secret' >> .env From c98764453b0bc37106e73711554dda0daeaf97c5 Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Wed, 9 Aug 2023 18:10:28 +0000 Subject: [PATCH 23/59] chore(ci): add some debugging statements --- .github/workflows/cypress.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index faea4840d9..7195213bad 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -85,9 +85,10 @@ jobs: echo 'FLASK_APP=application.py' >> .env echo 'FLASK_DEBUG=true' >> .env echo 'WERKZEUG_DEBUG_PIN=off' >> .env - + pwd - name: prep db and run notify api run: | + pwd poetry run make run - name: Write the cypress.env.json file From 7ee009281415f45f3a90f612ac136da3aa01bd42 Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Wed, 9 Aug 2023 18:22:34 +0000 Subject: [PATCH 24/59] fix(ci): add version file :/ --- .github/workflows/cypress.yaml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index 7195213bad..f84f366415 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -50,6 +50,16 @@ jobs: - name: Install requirements run: poetry install --with test + + - name: Get python version + run: | + python_version=$(python -V | cut -d' ' -f2) + echo "python_version=${python_version}" >> $GITHUB_ENV + + - name: Make version file + run: | + printf '__commit_sha__ = "09cfe03100443fb9071bba88d5c8775ff54a9ebc"\n__time__ = "2022-07-25:15:11:05"\n' > version.py + cp version.py "${{ github.workspace }}/app/" - name: Copy site-packages in workspace working-directory: ${{ github.workspace }} @@ -88,7 +98,7 @@ jobs: pwd - name: prep db and run notify api run: | - pwd + poetry run make run - name: Write the cypress.env.json file From 4ddc4b5b989664ea7a87a10b17ca56cba1407a7c Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Wed, 9 Aug 2023 18:31:06 +0000 Subject: [PATCH 25/59] fix(ci): force flask to the bg --- .github/workflows/cypress.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index f84f366415..6795bb65d6 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -98,8 +98,7 @@ jobs: pwd - name: prep db and run notify api run: | - - poetry run make run + poetry run make run & - name: Write the cypress.env.json file run: | From a60e3a3c3d3dd5840002265b72ec688c2362f2d7 Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Wed, 9 Aug 2023 18:38:21 +0000 Subject: [PATCH 26/59] fix(ci): correct path to test --- .github/workflows/cypress.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index 6795bb65d6..7f10ce06c6 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -112,4 +112,4 @@ jobs: record: false build: npx cypress info working-directory: tests_cypress - spec: cypress/e2e/admin/api/sanity_check.cy.js \ No newline at end of file + spec: cypress/e2e/api/sanity_check.cy.js \ No newline at end of file From 60092c9ce1246d78e89c12f9832f9b92e41b326d Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Wed, 9 Aug 2023 18:52:27 +0000 Subject: [PATCH 27/59] fix(ci): update db credentials --- .github/workflows/cypress.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index 7f10ce06c6..de11d08771 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -81,7 +81,8 @@ jobs: echo 'ADMIN_CLIENT_SECRET=local_app' >> .env echo 'REDIS_URL=redis://redis:6379' >> .env echo 'REDIS_PUBLISH_URL=redis://redis:6379' >> .env - echo 'SQLALCHEMY_DATABASE_TEST_URI=postgresql://postgres:postgres@postgres:5432/test_notification_api' >> .env + echo 'SQLALCHEMY_DATABASE_URI=postgresql://postgres:postgres@host.docker.internal:5432/notification_api' >> .env + echo 'SQLALCHEMY_DATABASE_READER_URI=postgresql://postgres:postgres@host.docker.internal:5432/notification_api' >> .env echo 'DOCUMENT_DOWNLOAD_API_HOST=http://host.docker.internal:7000' >> .env echo 'FF_REDIS_BATCH_SAVING=true' >> .env echo 'FF_BATCH_INSERTION=true' >> .env From d92abdb82e7c58392ea7499de066df22d80fc66f Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Wed, 9 Aug 2023 18:57:55 +0000 Subject: [PATCH 28/59] fix(ci): update db uri --- .github/workflows/cypress.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index de11d08771..ddb3f44d66 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -81,8 +81,8 @@ jobs: echo 'ADMIN_CLIENT_SECRET=local_app' >> .env echo 'REDIS_URL=redis://redis:6379' >> .env echo 'REDIS_PUBLISH_URL=redis://redis:6379' >> .env - echo 'SQLALCHEMY_DATABASE_URI=postgresql://postgres:postgres@host.docker.internal:5432/notification_api' >> .env - echo 'SQLALCHEMY_DATABASE_READER_URI=postgresql://postgres:postgres@host.docker.internal:5432/notification_api' >> .env + echo 'SQLALCHEMY_DATABASE_URI=postgresql://postgres:postgres@postgres:5432/notification_api' >> .env + echo 'SQLALCHEMY_DATABASE_READER_URI=postgresql://postgres:postgres@postgres:5432/notification_api' >> .env echo 'DOCUMENT_DOWNLOAD_API_HOST=http://host.docker.internal:7000' >> .env echo 'FF_REDIS_BATCH_SAVING=true' >> .env echo 'FF_BATCH_INSERTION=true' >> .env From 06141cf289bdd4e82e93ddaded5c1f625bdab92c Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Wed, 9 Aug 2023 19:02:48 +0000 Subject: [PATCH 29/59] fix(ci): update db uri again --- .github/workflows/cypress.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index ddb3f44d66..af3902e520 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -81,8 +81,8 @@ jobs: echo 'ADMIN_CLIENT_SECRET=local_app' >> .env echo 'REDIS_URL=redis://redis:6379' >> .env echo 'REDIS_PUBLISH_URL=redis://redis:6379' >> .env - echo 'SQLALCHEMY_DATABASE_URI=postgresql://postgres:postgres@postgres:5432/notification_api' >> .env - echo 'SQLALCHEMY_DATABASE_READER_URI=postgresql://postgres:postgres@postgres:5432/notification_api' >> .env + echo 'SQLALCHEMY_DATABASE_URI=postgresql://postgres:postgres@localhost:5432/notification_api' >> .env + echo 'SQLALCHEMY_DATABASE_READER_URI=postgresql://postgres:postgres@localhost:5432/notification_api' >> .env echo 'DOCUMENT_DOWNLOAD_API_HOST=http://host.docker.internal:7000' >> .env echo 'FF_REDIS_BATCH_SAVING=true' >> .env echo 'FF_BATCH_INSERTION=true' >> .env From 9cdee56b8c44eeb9b43ec211964415a27c6cba1c Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Wed, 9 Aug 2023 20:16:23 +0000 Subject: [PATCH 30/59] fix(ci): update database name in URI --- .github/workflows/cypress.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index af3902e520..2f1dd68636 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -81,8 +81,8 @@ jobs: echo 'ADMIN_CLIENT_SECRET=local_app' >> .env echo 'REDIS_URL=redis://redis:6379' >> .env echo 'REDIS_PUBLISH_URL=redis://redis:6379' >> .env - echo 'SQLALCHEMY_DATABASE_URI=postgresql://postgres:postgres@localhost:5432/notification_api' >> .env - echo 'SQLALCHEMY_DATABASE_READER_URI=postgresql://postgres:postgres@localhost:5432/notification_api' >> .env + echo 'SQLALCHEMY_DATABASE_URI=postgresql://postgres:postgres@localhost:5432/test_notification_api' >> .env + echo 'SQLALCHEMY_DATABASE_READER_URI=postgresql://postgres:postgres@localhost:5432/test_notification_api' >> .env echo 'DOCUMENT_DOWNLOAD_API_HOST=http://host.docker.internal:7000' >> .env echo 'FF_REDIS_BATCH_SAVING=true' >> .env echo 'FF_BATCH_INSERTION=true' >> .env From 8b355bca79029a00b010806503d4a4900162a593 Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Thu, 10 Aug 2023 01:08:27 +0000 Subject: [PATCH 31/59] feat(ci): migrate the db before running the tests --- .github/workflows/cypress.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index 2f1dd68636..c4af965f3e 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -99,6 +99,7 @@ jobs: pwd - name: prep db and run notify api run: | + poetry run flask db upgrade poetry run make run & - name: Write the cypress.env.json file From 93eafb25490a54205d3e8805e2ae6f8063095f99 Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Thu, 10 Aug 2023 13:34:00 +0000 Subject: [PATCH 32/59] fix(ci): use secrets from github secrets; seed db with test data --- .github/workflows/cypress.yaml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index c4af965f3e..15938f8192 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -69,15 +69,15 @@ jobs: - name: Setup .env run: | - echo 'NOTIFICATION_QUEUE_PREFIX=andrewl-dev-notification-canada-ca' > .env - echo 'AWS_ACCESS_KEY_ID=not-a-real-secret' >> .env - echo 'AWS_SECRET_ACCESS_KEY=not-a-real-secret' >> .env + echo 'NOTIFICATION_QUEUE_PREFIX=api-pr-notification-canada-ca' > .env + echo 'AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }}' >> .env + echo 'AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }}' >> .env echo 'AWS_REGION=ca-central-1' >> .env echo 'ASSET_DOMAIN=example.com' >> .env echo 'ASSET_UPLOAD_BUCKET_NAME=not-a-real-secret' >> .env echo 'CSV_UPLOAD_BUCKET_NAME=not-a-real-secret' >> .env echo 'DOCUMENTS_BUCKET=not-a-real-secret' >> .env - echo 'NOTIFY_EMAIL_DOMAIN=not-a-real-secret' >> .env + echo 'NOTIFY_EMAIL_DOMAIN=staging.notification.cdssandbox.xyz' >> .env echo 'ADMIN_CLIENT_SECRET=local_app' >> .env echo 'REDIS_URL=redis://redis:6379' >> .env echo 'REDIS_PUBLISH_URL=redis://redis:6379' >> .env @@ -100,6 +100,7 @@ jobs: - name: prep db and run notify api run: | poetry run flask db upgrade + python tests_cypress/seed_db.py poetry run make run & - name: Write the cypress.env.json file @@ -114,4 +115,4 @@ jobs: record: false build: npx cypress info working-directory: tests_cypress - spec: cypress/e2e/api/sanity_check.cy.js \ No newline at end of file + spec: cypress/e2e/api/all.cy.js \ No newline at end of file From ec70f39533978f58b7512456c9bcea1af47dab41 Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Thu, 10 Aug 2023 13:34:35 +0000 Subject: [PATCH 33/59] feat(seed): 1st attempt at seeding data for cypress tests --- tests_cypress/seed_db.py | 47 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 tests_cypress/seed_db.py diff --git a/tests_cypress/seed_db.py b/tests_cypress/seed_db.py new file mode 100644 index 0000000000..bd6a9a0d06 --- /dev/null +++ b/tests_cypress/seed_db.py @@ -0,0 +1,47 @@ +import os + +SQLALCHEMY_DATABASE_URI = os.getenv("SQLALCHEMY_DATABASE_URI") +print(SQLALCHEMY_DATABASE_URI) + +import sqlalchemy as sa + +# set connection URI here ↓ +engine = sa.create_engine(SQLALCHEMY_DATABASE_URI) + +with engine.connect() as conn: + with conn.begin(): + insert_user = """ + INSERT INTO "public"."users"("id","name","email_address","created_at","updated_at","_password","mobile_number","password_changed_at","logged_in_at","failed_login_count","state","platform_admin","current_session_id","auth_type","blocked","additional_information","password_expired") + VALUES + (E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',E'Notify UI Tests',E'notify-uid-tests@cds-snc.ca',E'2023-05-24 13:41:48.022737',E'2023-08-01 13:20:08.017647',E'$2b$10$jwj45gXRLUIteNBwhRgEV.4P7uHGH11O2PhNiDK6SY6oRPSdKhg2u',E'6139863526',E'2023-05-24 13:41:48.017676',E'2023-08-01 13:20:08.014524',0,E'active',FALSE,E'8f6e79df-782d-4620-b86c-adf1ea933934',E'email_auth',FALSE,E'{}',FALSE); + """ + + insert_service = """ + INSERT INTO "public"."services"("id","name","created_at","updated_at","active","message_limit","restricted","email_from","created_by_id","version","research_mode","organisation_type","prefix_sms","crown","rate_limit","contact_link","consent_to_research","volume_email","volume_letter","volume_sms","count_as_live","go_live_at","go_live_user_id","organisation_id","sending_domain","default_branding_is_french","sms_daily_limit","organisation_notes") + VALUES + (E'4049c2d0-0cab-455c-8f4c-f356dff51810',E'Cypress',E'2023-05-16 15:02:43.663183',E'2023-05-24 14:01:51.335072',TRUE,10000,FALSE,E'bounce',E'6af522d0-2915-4e52-83a3-3690455a5fe6',5,FALSE,E'central',TRUE,TRUE,1000,NULL,NULL,NULL,NULL,NULL,FALSE,E'2023-05-16 15:08:46.692247',NULL,E'93413f91-227f-4704-b229-b8210d1ecc0a',NULL,FALSE,1000,NULL); + """ + + insert_templates = """ + INSERT INTO "public"."templates"("id","name","template_type","created_at","updated_at","content","service_id","subject","created_by_id","version","archived","process_type","service_letter_contact_id","hidden","postage") + VALUES + (E'136e951e-05c8-4db4-bc50-fe122d72fcaa',E'SMOKE_TEST_EMAIL',E'email',E'2023-05-24 13:31:40.907915',NULL,E'# This is a smoke test from Cypress\n\nSMOKE_TEST_EMAIL',E'4049c2d0-0cab-455c-8f4c-f356dff51810',E'SMOKE_TEST_EMAIL',E'0840b12a-8139-4627-b27a-58872913ae14',1,FALSE,E'bulk',NULL,FALSE,NULL), + (E'258d8617-da88-4faa-ad28-46cc69f5a458',E'VARIABLES_EMAIL_TEMPLATE_ID',E'email',E'2023-07-10 16:38:43.913184',NULL,E'Hi ((name))\n\n((has_stuff??You have stuff!))',E'4049c2d0-0cab-455c-8f4c-f356dff51810',E'TESTING',E'0840b12a-8139-4627-b27a-58872913ae14',1,FALSE,E'bulk',NULL,FALSE,NULL), + (E'2d52d997-42d3-4ac0-a597-7afc94d4339a',E'SMOKE_TEST_EMAIL_LINK',E'email',E'2023-05-24 13:32:49.286647',NULL,E'# This is a smoke test from Cypress\n\nSMOKE_TEST_EMAIL_LINK\n\n((link_to_file))',E'4049c2d0-0cab-455c-8f4c-f356dff51810',E'SMOKE_TEST_EMAIL_LINK',E'0840b12a-8139-4627-b27a-58872913ae14',1,FALSE,E'bulk',NULL,FALSE,NULL), + (E'48207d93-144d-4ebb-92c5-99ff1f1baead',E'SMOKE_TEST_EMAIL_BULK',E'email',E'2023-05-24 13:32:24.912515',NULL,E'# This is a smoke test from Cypress\n\nSMOKE_TEST_EMAIL_BULK',E'4049c2d0-0cab-455c-8f4c-f356dff51810',E'SMOKE_TEST_EMAIL_BULK',E'0840b12a-8139-4627-b27a-58872913ae14',1,FALSE,E'bulk',NULL,FALSE,NULL), + (E'58db03d6-a9d8-4482-8621-26f473f3980a',E'SMOKE_TEST_EMAIL_ATTACH',E'email',E'2023-05-24 13:32:03.754124',NULL,E'# This is a smoke test from Cypress\n\nSMOKE_TEST_EMAIL_ATTACH',E'4049c2d0-0cab-455c-8f4c-f356dff51810',E'SMOKE_TEST_EMAIL_ATTACH',E'0840b12a-8139-4627-b27a-58872913ae14',1,FALSE,E'bulk',NULL,FALSE,NULL), + (E'5945e2f0-3e37-4813-9a60-e0665e02e9c8',E'SMOKE_TEST_SMS',E'sms',E'2023-05-24 13:33:20.936811',NULL,E'SMOKE_TEST_SMS',E'4049c2d0-0cab-455c-8f4c-f356dff51810',NULL,E'0840b12a-8139-4627-b27a-58872913ae14',1,FALSE,E'bulk',NULL,FALSE,NULL), + (E'b4692883-4182-4a23-b1b9-7b9df66a66e8',E'SIMPLE_EMAIL_TEMPLATE_ID',E'email',E'2023-07-10 16:33:10.288618',NULL,E'TESTING',E'4049c2d0-0cab-455c-8f4c-f356dff51810',E'TESTING',E'0840b12a-8139-4627-b27a-58872913ae14',1,FALSE,E'bulk',NULL,FALSE,NULL); + """ + + insert_api_keys = """ + INSERT INTO "public"."api_keys"("id","name","secret","service_id","expiry_date","created_at","created_by_id","updated_at","version","key_type") + VALUES + (E'076fc5ba-8578-44d6-8b69-122ac3a7b206',E'CYPRESS_TEST_KEY',E'IjY3YTViZmU4LWMxNjktNDQ0NS04OGVjLWRkNWExZDA3NjFmYSI.wLt-AQOYG3vgab_qP1p0Djw_r-8',E'4049c2d0-0cab-455c-8f4c-f356dff51810',NULL,E'2023-07-10 16:44:13.025984',E'6af522d0-2915-4e52-83a3-3690455a5fe6',NULL,1,E'test'), + (E'61a3f8e1-516d-446c-bc3a-c2dac33c9474',E'CYPRESS',E'IjhmYmE3MzUwLTIwN2ItNDRhYi1iNmYwLTVkZjk3ZjAzNjZlMyI.xiQ94d2oAedkohXNhx83B6cWr_0',E'4049c2d0-0cab-455c-8f4c-f356dff51810',NULL,E'2023-05-24 13:48:23.93561',E'6af522d0-2915-4e52-83a3-3690455a5fe6',NULL,1,E'normal'), + (E'74a06881-7742-4d4a-85ff-b91ae71e1bcd',E'CYPRESS_TEAM_KEY',E'IjYxZjhhYzU3LTNlZGEtNDE3MS1iMDcyLTJjNTY0OWEzODI4ZSI.p6K5JNnYp6Pcn3OEQg1kDM1UHAY',E'4049c2d0-0cab-455c-8f4c-f356dff51810',NULL,E'2023-07-10 16:43:19.425995',E'6af522d0-2915-4e52-83a3-3690455a5fe6',NULL,1,E'team'); + """# Optional: start a transaction + # conn.execute(sa.text(insert_user)) + conn.execute(sa.text(insert_service)) + conn.execute(sa.text(insert_templates)) + conn.execute(sa.text(insert_api_keys)) From 532e5a286a3caad9a9479063020775c4c3dff53f Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Thu, 10 Aug 2023 13:41:25 +0000 Subject: [PATCH 34/59] fix(ci): trigger seeding with poetry --- .github/workflows/cypress.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index 15938f8192..25ec180d03 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -100,7 +100,7 @@ jobs: - name: prep db and run notify api run: | poetry run flask db upgrade - python tests_cypress/seed_db.py + poetry run python tests_cypress/seed_db.py poetry run make run & - name: Write the cypress.env.json file From e22de4e0998621761997aed832afea39e9ac9cf4 Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Thu, 10 Aug 2023 13:48:08 +0000 Subject: [PATCH 35/59] fix(ci): hardcode db uri for now --- tests_cypress/seed_db.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests_cypress/seed_db.py b/tests_cypress/seed_db.py index bd6a9a0d06..a72e3e44c2 100644 --- a/tests_cypress/seed_db.py +++ b/tests_cypress/seed_db.py @@ -1,6 +1,6 @@ import os -SQLALCHEMY_DATABASE_URI = os.getenv("SQLALCHEMY_DATABASE_URI") +SQLALCHEMY_DATABASE_URI = "postgresql://postgres:postgres@localhost:5432/test_notification_api" #os.getenv("SQLALCHEMY_DATABASE_URI") print(SQLALCHEMY_DATABASE_URI) import sqlalchemy as sa From 2fe2b01442237105fc250c017add6032a2f1db1d Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Thu, 10 Aug 2023 14:42:34 +0000 Subject: [PATCH 36/59] fix(seeding): update seed script --- tests_cypress/seed_db.py | 41 +++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/tests_cypress/seed_db.py b/tests_cypress/seed_db.py index a72e3e44c2..063b87a4b6 100644 --- a/tests_cypress/seed_db.py +++ b/tests_cypress/seed_db.py @@ -1,6 +1,6 @@ import os -SQLALCHEMY_DATABASE_URI = "postgresql://postgres:postgres@localhost:5432/test_notification_api" #os.getenv("SQLALCHEMY_DATABASE_URI") +SQLALCHEMY_DATABASE_URI = os.getenv("SQLALCHEMY_DATABASE_URI") #"postgresql://postgres:postgres@localhost:5432/test_notification_api" print(SQLALCHEMY_DATABASE_URI) import sqlalchemy as sa @@ -10,38 +10,41 @@ with engine.connect() as conn: with conn.begin(): - insert_user = """ - INSERT INTO "public"."users"("id","name","email_address","created_at","updated_at","_password","mobile_number","password_changed_at","logged_in_at","failed_login_count","state","platform_admin","current_session_id","auth_type","blocked","additional_information","password_expired") - VALUES - (E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',E'Notify UI Tests',E'notify-uid-tests@cds-snc.ca',E'2023-05-24 13:41:48.022737',E'2023-08-01 13:20:08.017647',E'$2b$10$jwj45gXRLUIteNBwhRgEV.4P7uHGH11O2PhNiDK6SY6oRPSdKhg2u',E'6139863526',E'2023-05-24 13:41:48.017676',E'2023-08-01 13:20:08.014524',0,E'active',FALSE,E'8f6e79df-782d-4620-b86c-adf1ea933934',E'email_auth',FALSE,E'{}',FALSE); - """ + org_id = conn.execute(sa.text("SELECT id FROM organisation where active = 'true' LIMIT 1")).fetchone()[0] + print(org_id) + + # insert_user = """ + # INSERT INTO "public"."users"("id","name","email_address","created_at","updated_at","_password","mobile_number","password_changed_at","logged_in_at","failed_login_count","state","platform_admin","current_session_id","auth_type","blocked","additional_information","password_expired") + # VALUES + # (E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',E'Notify UI Tests',E'notify-uid-tests@cds-snc.ca',E'2023-05-24 13:41:48.022737',E'2023-08-01 13:20:08.017647',E'$2b$10$jwj45gXRLUIteNBwhRgEV.4P7uHGH11O2PhNiDK6SY6oRPSdKhg2u',E'6139863526',E'2023-05-24 13:41:48.017676',E'2023-08-01 13:20:08.014524',0,E'active',FALSE,E'8f6e79df-782d-4620-b86c-adf1ea933934',E'email_auth',FALSE,E'{}',FALSE); + # """ insert_service = """ INSERT INTO "public"."services"("id","name","created_at","updated_at","active","message_limit","restricted","email_from","created_by_id","version","research_mode","organisation_type","prefix_sms","crown","rate_limit","contact_link","consent_to_research","volume_email","volume_letter","volume_sms","count_as_live","go_live_at","go_live_user_id","organisation_id","sending_domain","default_branding_is_french","sms_daily_limit","organisation_notes") VALUES - (E'4049c2d0-0cab-455c-8f4c-f356dff51810',E'Cypress',E'2023-05-16 15:02:43.663183',E'2023-05-24 14:01:51.335072',TRUE,10000,FALSE,E'bounce',E'6af522d0-2915-4e52-83a3-3690455a5fe6',5,FALSE,E'central',TRUE,TRUE,1000,NULL,NULL,NULL,NULL,NULL,FALSE,E'2023-05-16 15:08:46.692247',NULL,E'93413f91-227f-4704-b229-b8210d1ecc0a',NULL,FALSE,1000,NULL); + (E'4049c2d0-0cab-455c-8f4c-f356dff51811',E'Cypress2',E'2023-05-16 15:02:43.663183',E'2023-05-24 14:01:51.335072',TRUE,10000,FALSE,E'bouncey',E'6af522d0-2915-4e52-83a3-3690455a5fe6',5,FALSE,E'central',TRUE,TRUE,1000,NULL,NULL,NULL,NULL,NULL,FALSE,E'2023-05-16 15:08:46.692247',NULL,E'{}',NULL,FALSE,1000,NULL); """ insert_templates = """ INSERT INTO "public"."templates"("id","name","template_type","created_at","updated_at","content","service_id","subject","created_by_id","version","archived","process_type","service_letter_contact_id","hidden","postage") VALUES - (E'136e951e-05c8-4db4-bc50-fe122d72fcaa',E'SMOKE_TEST_EMAIL',E'email',E'2023-05-24 13:31:40.907915',NULL,E'# This is a smoke test from Cypress\n\nSMOKE_TEST_EMAIL',E'4049c2d0-0cab-455c-8f4c-f356dff51810',E'SMOKE_TEST_EMAIL',E'0840b12a-8139-4627-b27a-58872913ae14',1,FALSE,E'bulk',NULL,FALSE,NULL), - (E'258d8617-da88-4faa-ad28-46cc69f5a458',E'VARIABLES_EMAIL_TEMPLATE_ID',E'email',E'2023-07-10 16:38:43.913184',NULL,E'Hi ((name))\n\n((has_stuff??You have stuff!))',E'4049c2d0-0cab-455c-8f4c-f356dff51810',E'TESTING',E'0840b12a-8139-4627-b27a-58872913ae14',1,FALSE,E'bulk',NULL,FALSE,NULL), - (E'2d52d997-42d3-4ac0-a597-7afc94d4339a',E'SMOKE_TEST_EMAIL_LINK',E'email',E'2023-05-24 13:32:49.286647',NULL,E'# This is a smoke test from Cypress\n\nSMOKE_TEST_EMAIL_LINK\n\n((link_to_file))',E'4049c2d0-0cab-455c-8f4c-f356dff51810',E'SMOKE_TEST_EMAIL_LINK',E'0840b12a-8139-4627-b27a-58872913ae14',1,FALSE,E'bulk',NULL,FALSE,NULL), - (E'48207d93-144d-4ebb-92c5-99ff1f1baead',E'SMOKE_TEST_EMAIL_BULK',E'email',E'2023-05-24 13:32:24.912515',NULL,E'# This is a smoke test from Cypress\n\nSMOKE_TEST_EMAIL_BULK',E'4049c2d0-0cab-455c-8f4c-f356dff51810',E'SMOKE_TEST_EMAIL_BULK',E'0840b12a-8139-4627-b27a-58872913ae14',1,FALSE,E'bulk',NULL,FALSE,NULL), - (E'58db03d6-a9d8-4482-8621-26f473f3980a',E'SMOKE_TEST_EMAIL_ATTACH',E'email',E'2023-05-24 13:32:03.754124',NULL,E'# This is a smoke test from Cypress\n\nSMOKE_TEST_EMAIL_ATTACH',E'4049c2d0-0cab-455c-8f4c-f356dff51810',E'SMOKE_TEST_EMAIL_ATTACH',E'0840b12a-8139-4627-b27a-58872913ae14',1,FALSE,E'bulk',NULL,FALSE,NULL), - (E'5945e2f0-3e37-4813-9a60-e0665e02e9c8',E'SMOKE_TEST_SMS',E'sms',E'2023-05-24 13:33:20.936811',NULL,E'SMOKE_TEST_SMS',E'4049c2d0-0cab-455c-8f4c-f356dff51810',NULL,E'0840b12a-8139-4627-b27a-58872913ae14',1,FALSE,E'bulk',NULL,FALSE,NULL), - (E'b4692883-4182-4a23-b1b9-7b9df66a66e8',E'SIMPLE_EMAIL_TEMPLATE_ID',E'email',E'2023-07-10 16:33:10.288618',NULL,E'TESTING',E'4049c2d0-0cab-455c-8f4c-f356dff51810',E'TESTING',E'0840b12a-8139-4627-b27a-58872913ae14',1,FALSE,E'bulk',NULL,FALSE,NULL); + (E'136e951e-05c8-4db4-bc50-fe122d72fcaa',E'SMOKE_TEST_EMAIL',E'email',E'2023-05-24 13:31:40.907915',NULL,E'# This is a smoke test from Cypress\n\nSMOKE_TEST_EMAIL',E'4049c2d0-0cab-455c-8f4c-f356dff51811',E'SMOKE_TEST_EMAIL',E'0840b12a-8139-4627-b27a-58872913ae14',1,FALSE,E'bulk',NULL,FALSE,NULL), + (E'258d8617-da88-4faa-ad28-46cc69f5a458',E'VARIABLES_EMAIL_TEMPLATE_ID',E'email',E'2023-07-10 16:38:43.913184',NULL,E'Hi ((name))\n\n((has_stuff??You have stuff!))',E'4049c2d0-0cab-455c-8f4c-f356dff51811',E'TESTING',E'0840b12a-8139-4627-b27a-58872913ae14',1,FALSE,E'bulk',NULL,FALSE,NULL), + (E'2d52d997-42d3-4ac0-a597-7afc94d4339a',E'SMOKE_TEST_EMAIL_LINK',E'email',E'2023-05-24 13:32:49.286647',NULL,E'# This is a smoke test from Cypress\n\nSMOKE_TEST_EMAIL_LINK\n\n((link_to_file))',E'4049c2d0-0cab-455c-8f4c-f356dff51811',E'SMOKE_TEST_EMAIL_LINK',E'0840b12a-8139-4627-b27a-58872913ae14',1,FALSE,E'bulk',NULL,FALSE,NULL), + (E'48207d93-144d-4ebb-92c5-99ff1f1baead',E'SMOKE_TEST_EMAIL_BULK',E'email',E'2023-05-24 13:32:24.912515',NULL,E'# This is a smoke test from Cypress\n\nSMOKE_TEST_EMAIL_BULK',E'4049c2d0-0cab-455c-8f4c-f356dff51811',E'SMOKE_TEST_EMAIL_BULK',E'0840b12a-8139-4627-b27a-58872913ae14',1,FALSE,E'bulk',NULL,FALSE,NULL), + (E'58db03d6-a9d8-4482-8621-26f473f3980a',E'SMOKE_TEST_EMAIL_ATTACH',E'email',E'2023-05-24 13:32:03.754124',NULL,E'# This is a smoke test from Cypress\n\nSMOKE_TEST_EMAIL_ATTACH',E'4049c2d0-0cab-455c-8f4c-f356dff51811',E'SMOKE_TEST_EMAIL_ATTACH',E'0840b12a-8139-4627-b27a-58872913ae14',1,FALSE,E'bulk',NULL,FALSE,NULL), + (E'5945e2f0-3e37-4813-9a60-e0665e02e9c8',E'SMOKE_TEST_SMS',E'sms',E'2023-05-24 13:33:20.936811',NULL,E'SMOKE_TEST_SMS',E'4049c2d0-0cab-455c-8f4c-f356dff51811',NULL,E'0840b12a-8139-4627-b27a-58872913ae14',1,FALSE,E'bulk',NULL,FALSE,NULL), + (E'b4692883-4182-4a23-b1b9-7b9df66a66e8',E'SIMPLE_EMAIL_TEMPLATE_ID',E'email',E'2023-07-10 16:33:10.288618',NULL,E'TESTING',E'4049c2d0-0cab-455c-8f4c-f356dff51811',E'TESTING',E'0840b12a-8139-4627-b27a-58872913ae14',1,FALSE,E'bulk',NULL,FALSE,NULL); """ insert_api_keys = """ INSERT INTO "public"."api_keys"("id","name","secret","service_id","expiry_date","created_at","created_by_id","updated_at","version","key_type") VALUES - (E'076fc5ba-8578-44d6-8b69-122ac3a7b206',E'CYPRESS_TEST_KEY',E'IjY3YTViZmU4LWMxNjktNDQ0NS04OGVjLWRkNWExZDA3NjFmYSI.wLt-AQOYG3vgab_qP1p0Djw_r-8',E'4049c2d0-0cab-455c-8f4c-f356dff51810',NULL,E'2023-07-10 16:44:13.025984',E'6af522d0-2915-4e52-83a3-3690455a5fe6',NULL,1,E'test'), - (E'61a3f8e1-516d-446c-bc3a-c2dac33c9474',E'CYPRESS',E'IjhmYmE3MzUwLTIwN2ItNDRhYi1iNmYwLTVkZjk3ZjAzNjZlMyI.xiQ94d2oAedkohXNhx83B6cWr_0',E'4049c2d0-0cab-455c-8f4c-f356dff51810',NULL,E'2023-05-24 13:48:23.93561',E'6af522d0-2915-4e52-83a3-3690455a5fe6',NULL,1,E'normal'), - (E'74a06881-7742-4d4a-85ff-b91ae71e1bcd',E'CYPRESS_TEAM_KEY',E'IjYxZjhhYzU3LTNlZGEtNDE3MS1iMDcyLTJjNTY0OWEzODI4ZSI.p6K5JNnYp6Pcn3OEQg1kDM1UHAY',E'4049c2d0-0cab-455c-8f4c-f356dff51810',NULL,E'2023-07-10 16:43:19.425995',E'6af522d0-2915-4e52-83a3-3690455a5fe6',NULL,1,E'team'); - """# Optional: start a transaction + (E'076fc5ba-8578-44d6-8b69-122ac3a7b206',E'CYPRESS_TEST_KEY',E'IjY3YTViZmU4LWMxNjktNDQ0NS04OGVjLWRkNWExZDA3NjFmYSI.wLt-AQOYG3vgab_qP1p0Djw_r-8',E'4049c2d0-0cab-455c-8f4c-f356dff51811',NULL,E'2023-07-10 16:44:13.025984',E'6af522d0-2915-4e52-83a3-3690455a5fe6',NULL,1,E'test'), + (E'61a3f8e1-516d-446c-bc3a-c2dac33c9474',E'CYPRESS',E'IjhmYmE3MzUwLTIwN2ItNDRhYi1iNmYwLTVkZjk3ZjAzNjZlMyI.xiQ94d2oAedkohXNhx83B6cWr_0',E'4049c2d0-0cab-455c-8f4c-f356dff51811',NULL,E'2023-05-24 13:48:23.93561',E'6af522d0-2915-4e52-83a3-3690455a5fe6',NULL,1,E'normal'), + (E'74a06881-7742-4d4a-85ff-b91ae71e1bcd',E'CYPRESS_TEAM_KEY',E'IjYxZjhhYzU3LTNlZGEtNDE3MS1iMDcyLTJjNTY0OWEzODI4ZSI.p6K5JNnYp6Pcn3OEQg1kDM1UHAY',E'4049c2d0-0cab-455c-8f4c-f356dff51811',NULL,E'2023-07-10 16:43:19.425995',E'6af522d0-2915-4e52-83a3-3690455a5fe6',NULL,1,E'team'); + """ # conn.execute(sa.text(insert_user)) - conn.execute(sa.text(insert_service)) + conn.execute(sa.text(insert_service.format(org_id))) conn.execute(sa.text(insert_templates)) conn.execute(sa.text(insert_api_keys)) From cfdfea35dd30c92afee0b308d8029cf33174995b Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Thu, 10 Aug 2023 14:49:14 +0000 Subject: [PATCH 37/59] fix(ci): use temp db uri --- tests_cypress/seed_db.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests_cypress/seed_db.py b/tests_cypress/seed_db.py index 063b87a4b6..e900357605 100644 --- a/tests_cypress/seed_db.py +++ b/tests_cypress/seed_db.py @@ -1,6 +1,6 @@ import os -SQLALCHEMY_DATABASE_URI = os.getenv("SQLALCHEMY_DATABASE_URI") #"postgresql://postgres:postgres@localhost:5432/test_notification_api" +SQLALCHEMY_DATABASE_URI = "postgresql://postgres:postgres@localhost:5432/test_notification_api" #os.getenv("SQLALCHEMY_DATABASE_URI") print(SQLALCHEMY_DATABASE_URI) import sqlalchemy as sa From 48c4679aa5bd46b13d9c365c87268956d4357e86 Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Thu, 10 Aug 2023 14:56:46 +0000 Subject: [PATCH 38/59] fix(ci): insert org first --- tests_cypress/seed_db.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tests_cypress/seed_db.py b/tests_cypress/seed_db.py index e900357605..585a7dc244 100644 --- a/tests_cypress/seed_db.py +++ b/tests_cypress/seed_db.py @@ -9,20 +9,21 @@ engine = sa.create_engine(SQLALCHEMY_DATABASE_URI) with engine.connect() as conn: - with conn.begin(): - org_id = conn.execute(sa.text("SELECT id FROM organisation where active = 'true' LIMIT 1")).fetchone()[0] - print(org_id) - + with conn.begin(): # insert_user = """ # INSERT INTO "public"."users"("id","name","email_address","created_at","updated_at","_password","mobile_number","password_changed_at","logged_in_at","failed_login_count","state","platform_admin","current_session_id","auth_type","blocked","additional_information","password_expired") # VALUES # (E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',E'Notify UI Tests',E'notify-uid-tests@cds-snc.ca',E'2023-05-24 13:41:48.022737',E'2023-08-01 13:20:08.017647',E'$2b$10$jwj45gXRLUIteNBwhRgEV.4P7uHGH11O2PhNiDK6SY6oRPSdKhg2u',E'6139863526',E'2023-05-24 13:41:48.017676',E'2023-08-01 13:20:08.014524',0,E'active',FALSE,E'8f6e79df-782d-4620-b86c-adf1ea933934',E'email_auth',FALSE,E'{}',FALSE); # """ - + insert_org = """ + INSERT INTO "public"."organisation"("id","name","active","created_at","updated_at","email_branding_id","letter_branding_id","agreement_signed","agreement_signed_at","agreement_signed_by_id","agreement_signed_version","crown","organisation_type","request_to_go_live_notes","agreement_signed_on_behalf_of_email_address","agreement_signed_on_behalf_of_name","default_branding_is_french") + VALUES + (E'93413f91-227f-4704-b229-b8210d1ecc0a',E'GOC',TRUE,E'2023-05-16 15:08:29.552525',NULL,NULL,NULL,FALSE,NULL,NULL,NULL,TRUE,E'central',NULL,NULL,NULL,FALSE); + """ insert_service = """ INSERT INTO "public"."services"("id","name","created_at","updated_at","active","message_limit","restricted","email_from","created_by_id","version","research_mode","organisation_type","prefix_sms","crown","rate_limit","contact_link","consent_to_research","volume_email","volume_letter","volume_sms","count_as_live","go_live_at","go_live_user_id","organisation_id","sending_domain","default_branding_is_french","sms_daily_limit","organisation_notes") VALUES - (E'4049c2d0-0cab-455c-8f4c-f356dff51811',E'Cypress2',E'2023-05-16 15:02:43.663183',E'2023-05-24 14:01:51.335072',TRUE,10000,FALSE,E'bouncey',E'6af522d0-2915-4e52-83a3-3690455a5fe6',5,FALSE,E'central',TRUE,TRUE,1000,NULL,NULL,NULL,NULL,NULL,FALSE,E'2023-05-16 15:08:46.692247',NULL,E'{}',NULL,FALSE,1000,NULL); + (E'4049c2d0-0cab-455c-8f4c-f356dff51811',E'Cypress2',E'2023-05-16 15:02:43.663183',E'2023-05-24 14:01:51.335072',TRUE,10000,FALSE,E'bouncey',E'6af522d0-2915-4e52-83a3-3690455a5fe6',5,FALSE,E'central',TRUE,TRUE,1000,NULL,NULL,NULL,NULL,NULL,FALSE,E'2023-05-16 15:08:46.692247',NULL,E'93413f91-227f-4704-b229-b8210d1ecc0a',NULL,FALSE,1000,NULL); """ insert_templates = """ @@ -45,6 +46,6 @@ (E'74a06881-7742-4d4a-85ff-b91ae71e1bcd',E'CYPRESS_TEAM_KEY',E'IjYxZjhhYzU3LTNlZGEtNDE3MS1iMDcyLTJjNTY0OWEzODI4ZSI.p6K5JNnYp6Pcn3OEQg1kDM1UHAY',E'4049c2d0-0cab-455c-8f4c-f356dff51811',NULL,E'2023-07-10 16:43:19.425995',E'6af522d0-2915-4e52-83a3-3690455a5fe6',NULL,1,E'team'); """ # conn.execute(sa.text(insert_user)) - conn.execute(sa.text(insert_service.format(org_id))) + conn.execute(sa.text(insert_service)) conn.execute(sa.text(insert_templates)) conn.execute(sa.text(insert_api_keys)) From e8c92e567932f486292fb558f13b47dd9d8a5c9d Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Thu, 10 Aug 2023 15:12:45 +0000 Subject: [PATCH 39/59] fix(ci): insert org first --- tests_cypress/seed_db.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests_cypress/seed_db.py b/tests_cypress/seed_db.py index 585a7dc244..b862dcde97 100644 --- a/tests_cypress/seed_db.py +++ b/tests_cypress/seed_db.py @@ -45,7 +45,7 @@ (E'61a3f8e1-516d-446c-bc3a-c2dac33c9474',E'CYPRESS',E'IjhmYmE3MzUwLTIwN2ItNDRhYi1iNmYwLTVkZjk3ZjAzNjZlMyI.xiQ94d2oAedkohXNhx83B6cWr_0',E'4049c2d0-0cab-455c-8f4c-f356dff51811',NULL,E'2023-05-24 13:48:23.93561',E'6af522d0-2915-4e52-83a3-3690455a5fe6',NULL,1,E'normal'), (E'74a06881-7742-4d4a-85ff-b91ae71e1bcd',E'CYPRESS_TEAM_KEY',E'IjYxZjhhYzU3LTNlZGEtNDE3MS1iMDcyLTJjNTY0OWEzODI4ZSI.p6K5JNnYp6Pcn3OEQg1kDM1UHAY',E'4049c2d0-0cab-455c-8f4c-f356dff51811',NULL,E'2023-07-10 16:43:19.425995',E'6af522d0-2915-4e52-83a3-3690455a5fe6',NULL,1,E'team'); """ - # conn.execute(sa.text(insert_user)) + conn.execute(sa.text(insert_org)) conn.execute(sa.text(insert_service)) conn.execute(sa.text(insert_templates)) conn.execute(sa.text(insert_api_keys)) From fca91ffbb3c306b317f1e238e1f3cbab95552299 Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Thu, 10 Aug 2023 15:18:30 +0000 Subject: [PATCH 40/59] fix(ci): insert user --- tests_cypress/seed_db.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/tests_cypress/seed_db.py b/tests_cypress/seed_db.py index b862dcde97..fa1e0fe1c2 100644 --- a/tests_cypress/seed_db.py +++ b/tests_cypress/seed_db.py @@ -10,11 +10,11 @@ with engine.connect() as conn: with conn.begin(): - # insert_user = """ - # INSERT INTO "public"."users"("id","name","email_address","created_at","updated_at","_password","mobile_number","password_changed_at","logged_in_at","failed_login_count","state","platform_admin","current_session_id","auth_type","blocked","additional_information","password_expired") - # VALUES - # (E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',E'Notify UI Tests',E'notify-uid-tests@cds-snc.ca',E'2023-05-24 13:41:48.022737',E'2023-08-01 13:20:08.017647',E'$2b$10$jwj45gXRLUIteNBwhRgEV.4P7uHGH11O2PhNiDK6SY6oRPSdKhg2u',E'6139863526',E'2023-05-24 13:41:48.017676',E'2023-08-01 13:20:08.014524',0,E'active',FALSE,E'8f6e79df-782d-4620-b86c-adf1ea933934',E'email_auth',FALSE,E'{}',FALSE); - # """ + insert_user = """ + INSERT INTO "public"."users"("id","name","email_address","created_at","updated_at","_password","mobile_number","password_changed_at","logged_in_at","failed_login_count","state","platform_admin","current_session_id","auth_type","blocked","additional_information","password_expired") + VALUES + (E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',E'Notify UI Tests',E'notify-ui-tests@cds-snc.ca',E'2023-05-24 13:41:48.022737',E'2023-08-01 13:20:08.017647',E'$2b$10$jwj45gXRLUIteNBwhRgEV.4P7uHGH11O2PhNiDK6SY6oRPSdKhg2u',E'6139863526',E'2023-05-24 13:41:48.017676',E'2023-08-01 13:20:08.014524',0,E'active',FALSE,E'8f6e79df-782d-4620-b86c-adf1ea933934',E'email_auth',FALSE,E'{}',FALSE); + """ insert_org = """ INSERT INTO "public"."organisation"("id","name","active","created_at","updated_at","email_branding_id","letter_branding_id","agreement_signed","agreement_signed_at","agreement_signed_by_id","agreement_signed_version","crown","organisation_type","request_to_go_live_notes","agreement_signed_on_behalf_of_email_address","agreement_signed_on_behalf_of_name","default_branding_is_french") VALUES @@ -23,7 +23,7 @@ insert_service = """ INSERT INTO "public"."services"("id","name","created_at","updated_at","active","message_limit","restricted","email_from","created_by_id","version","research_mode","organisation_type","prefix_sms","crown","rate_limit","contact_link","consent_to_research","volume_email","volume_letter","volume_sms","count_as_live","go_live_at","go_live_user_id","organisation_id","sending_domain","default_branding_is_french","sms_daily_limit","organisation_notes") VALUES - (E'4049c2d0-0cab-455c-8f4c-f356dff51811',E'Cypress2',E'2023-05-16 15:02:43.663183',E'2023-05-24 14:01:51.335072',TRUE,10000,FALSE,E'bouncey',E'6af522d0-2915-4e52-83a3-3690455a5fe6',5,FALSE,E'central',TRUE,TRUE,1000,NULL,NULL,NULL,NULL,NULL,FALSE,E'2023-05-16 15:08:46.692247',NULL,E'93413f91-227f-4704-b229-b8210d1ecc0a',NULL,FALSE,1000,NULL); + (E'4049c2d0-0cab-455c-8f4c-f356dff51811',E'Cypress2',E'2023-05-16 15:02:43.663183',E'2023-05-24 14:01:51.335072',TRUE,10000,FALSE,E'bouncey',E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',5,FALSE,E'central',TRUE,TRUE,1000,NULL,NULL,NULL,NULL,NULL,FALSE,E'2023-05-16 15:08:46.692247',NULL,E'93413f91-227f-4704-b229-b8210d1ecc0a',NULL,FALSE,1000,NULL); """ insert_templates = """ @@ -41,10 +41,11 @@ insert_api_keys = """ INSERT INTO "public"."api_keys"("id","name","secret","service_id","expiry_date","created_at","created_by_id","updated_at","version","key_type") VALUES - (E'076fc5ba-8578-44d6-8b69-122ac3a7b206',E'CYPRESS_TEST_KEY',E'IjY3YTViZmU4LWMxNjktNDQ0NS04OGVjLWRkNWExZDA3NjFmYSI.wLt-AQOYG3vgab_qP1p0Djw_r-8',E'4049c2d0-0cab-455c-8f4c-f356dff51811',NULL,E'2023-07-10 16:44:13.025984',E'6af522d0-2915-4e52-83a3-3690455a5fe6',NULL,1,E'test'), - (E'61a3f8e1-516d-446c-bc3a-c2dac33c9474',E'CYPRESS',E'IjhmYmE3MzUwLTIwN2ItNDRhYi1iNmYwLTVkZjk3ZjAzNjZlMyI.xiQ94d2oAedkohXNhx83B6cWr_0',E'4049c2d0-0cab-455c-8f4c-f356dff51811',NULL,E'2023-05-24 13:48:23.93561',E'6af522d0-2915-4e52-83a3-3690455a5fe6',NULL,1,E'normal'), - (E'74a06881-7742-4d4a-85ff-b91ae71e1bcd',E'CYPRESS_TEAM_KEY',E'IjYxZjhhYzU3LTNlZGEtNDE3MS1iMDcyLTJjNTY0OWEzODI4ZSI.p6K5JNnYp6Pcn3OEQg1kDM1UHAY',E'4049c2d0-0cab-455c-8f4c-f356dff51811',NULL,E'2023-07-10 16:43:19.425995',E'6af522d0-2915-4e52-83a3-3690455a5fe6',NULL,1,E'team'); + (E'076fc5ba-8578-44d6-8b69-122ac3a7b206',E'CYPRESS_TEST_KEY',E'IjY3YTViZmU4LWMxNjktNDQ0NS04OGVjLWRkNWExZDA3NjFmYSI.wLt-AQOYG3vgab_qP1p0Djw_r-8',E'4049c2d0-0cab-455c-8f4c-f356dff51811',NULL,E'2023-07-10 16:44:13.025984',E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',NULL,1,E'test'), + (E'61a3f8e1-516d-446c-bc3a-c2dac33c9474',E'CYPRESS',E'IjhmYmE3MzUwLTIwN2ItNDRhYi1iNmYwLTVkZjk3ZjAzNjZlMyI.xiQ94d2oAedkohXNhx83B6cWr_0',E'4049c2d0-0cab-455c-8f4c-f356dff51811',NULL,E'2023-05-24 13:48:23.93561',E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',NULL,1,E'normal'), + (E'74a06881-7742-4d4a-85ff-b91ae71e1bcd',E'CYPRESS_TEAM_KEY',E'IjYxZjhhYzU3LTNlZGEtNDE3MS1iMDcyLTJjNTY0OWEzODI4ZSI.p6K5JNnYp6Pcn3OEQg1kDM1UHAY',E'4049c2d0-0cab-455c-8f4c-f356dff51811',NULL,E'2023-07-10 16:43:19.425995',E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',NULL,1,E'team'); """ + conn.execute(sa.text(insert_user)) conn.execute(sa.text(insert_org)) conn.execute(sa.text(insert_service)) conn.execute(sa.text(insert_templates)) From 3d1acaa8d1b7f577d9b36dd337263e39e4fbf99e Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Thu, 10 Aug 2023 15:28:13 +0000 Subject: [PATCH 41/59] fix(ci): fix user id --- tests_cypress/seed_db.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests_cypress/seed_db.py b/tests_cypress/seed_db.py index fa1e0fe1c2..45e961fb3b 100644 --- a/tests_cypress/seed_db.py +++ b/tests_cypress/seed_db.py @@ -29,13 +29,13 @@ insert_templates = """ INSERT INTO "public"."templates"("id","name","template_type","created_at","updated_at","content","service_id","subject","created_by_id","version","archived","process_type","service_letter_contact_id","hidden","postage") VALUES - (E'136e951e-05c8-4db4-bc50-fe122d72fcaa',E'SMOKE_TEST_EMAIL',E'email',E'2023-05-24 13:31:40.907915',NULL,E'# This is a smoke test from Cypress\n\nSMOKE_TEST_EMAIL',E'4049c2d0-0cab-455c-8f4c-f356dff51811',E'SMOKE_TEST_EMAIL',E'0840b12a-8139-4627-b27a-58872913ae14',1,FALSE,E'bulk',NULL,FALSE,NULL), - (E'258d8617-da88-4faa-ad28-46cc69f5a458',E'VARIABLES_EMAIL_TEMPLATE_ID',E'email',E'2023-07-10 16:38:43.913184',NULL,E'Hi ((name))\n\n((has_stuff??You have stuff!))',E'4049c2d0-0cab-455c-8f4c-f356dff51811',E'TESTING',E'0840b12a-8139-4627-b27a-58872913ae14',1,FALSE,E'bulk',NULL,FALSE,NULL), - (E'2d52d997-42d3-4ac0-a597-7afc94d4339a',E'SMOKE_TEST_EMAIL_LINK',E'email',E'2023-05-24 13:32:49.286647',NULL,E'# This is a smoke test from Cypress\n\nSMOKE_TEST_EMAIL_LINK\n\n((link_to_file))',E'4049c2d0-0cab-455c-8f4c-f356dff51811',E'SMOKE_TEST_EMAIL_LINK',E'0840b12a-8139-4627-b27a-58872913ae14',1,FALSE,E'bulk',NULL,FALSE,NULL), - (E'48207d93-144d-4ebb-92c5-99ff1f1baead',E'SMOKE_TEST_EMAIL_BULK',E'email',E'2023-05-24 13:32:24.912515',NULL,E'# This is a smoke test from Cypress\n\nSMOKE_TEST_EMAIL_BULK',E'4049c2d0-0cab-455c-8f4c-f356dff51811',E'SMOKE_TEST_EMAIL_BULK',E'0840b12a-8139-4627-b27a-58872913ae14',1,FALSE,E'bulk',NULL,FALSE,NULL), - (E'58db03d6-a9d8-4482-8621-26f473f3980a',E'SMOKE_TEST_EMAIL_ATTACH',E'email',E'2023-05-24 13:32:03.754124',NULL,E'# This is a smoke test from Cypress\n\nSMOKE_TEST_EMAIL_ATTACH',E'4049c2d0-0cab-455c-8f4c-f356dff51811',E'SMOKE_TEST_EMAIL_ATTACH',E'0840b12a-8139-4627-b27a-58872913ae14',1,FALSE,E'bulk',NULL,FALSE,NULL), - (E'5945e2f0-3e37-4813-9a60-e0665e02e9c8',E'SMOKE_TEST_SMS',E'sms',E'2023-05-24 13:33:20.936811',NULL,E'SMOKE_TEST_SMS',E'4049c2d0-0cab-455c-8f4c-f356dff51811',NULL,E'0840b12a-8139-4627-b27a-58872913ae14',1,FALSE,E'bulk',NULL,FALSE,NULL), - (E'b4692883-4182-4a23-b1b9-7b9df66a66e8',E'SIMPLE_EMAIL_TEMPLATE_ID',E'email',E'2023-07-10 16:33:10.288618',NULL,E'TESTING',E'4049c2d0-0cab-455c-8f4c-f356dff51811',E'TESTING',E'0840b12a-8139-4627-b27a-58872913ae14',1,FALSE,E'bulk',NULL,FALSE,NULL); + (E'136e951e-05c8-4db4-bc50-fe122d72fcaa',E'SMOKE_TEST_EMAIL',E'email',E'2023-05-24 13:31:40.907915',NULL,E'# This is a smoke test from Cypress\n\nSMOKE_TEST_EMAIL',E'4049c2d0-0cab-455c-8f4c-f356dff51811',E'SMOKE_TEST_EMAIL',E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',1,FALSE,E'bulk',NULL,FALSE,NULL), + (E'258d8617-da88-4faa-ad28-46cc69f5a458',E'VARIABLES_EMAIL_TEMPLATE_ID',E'email',E'2023-07-10 16:38:43.913184',NULL,E'Hi ((name))\n\n((has_stuff??You have stuff!))',E'4049c2d0-0cab-455c-8f4c-f356dff51811',E'TESTING',E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',1,FALSE,E'bulk',NULL,FALSE,NULL), + (E'2d52d997-42d3-4ac0-a597-7afc94d4339a',E'SMOKE_TEST_EMAIL_LINK',E'email',E'2023-05-24 13:32:49.286647',NULL,E'# This is a smoke test from Cypress\n\nSMOKE_TEST_EMAIL_LINK\n\n((link_to_file))',E'4049c2d0-0cab-455c-8f4c-f356dff51811',E'SMOKE_TEST_EMAIL_LINK',E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',1,FALSE,E'bulk',NULL,FALSE,NULL), + (E'48207d93-144d-4ebb-92c5-99ff1f1baead',E'SMOKE_TEST_EMAIL_BULK',E'email',E'2023-05-24 13:32:24.912515',NULL,E'# This is a smoke test from Cypress\n\nSMOKE_TEST_EMAIL_BULK',E'4049c2d0-0cab-455c-8f4c-f356dff51811',E'SMOKE_TEST_EMAIL_BULK',E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',1,FALSE,E'bulk',NULL,FALSE,NULL), + (E'58db03d6-a9d8-4482-8621-26f473f3980a',E'SMOKE_TEST_EMAIL_ATTACH',E'email',E'2023-05-24 13:32:03.754124',NULL,E'# This is a smoke test from Cypress\n\nSMOKE_TEST_EMAIL_ATTACH',E'4049c2d0-0cab-455c-8f4c-f356dff51811',E'SMOKE_TEST_EMAIL_ATTACH',E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',1,FALSE,E'bulk',NULL,FALSE,NULL), + (E'5945e2f0-3e37-4813-9a60-e0665e02e9c8',E'SMOKE_TEST_SMS',E'sms',E'2023-05-24 13:33:20.936811',NULL,E'SMOKE_TEST_SMS',E'4049c2d0-0cab-455c-8f4c-f356dff51811',NULL,E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',1,FALSE,E'bulk',NULL,FALSE,NULL), + (E'b4692883-4182-4a23-b1b9-7b9df66a66e8',E'SIMPLE_EMAIL_TEMPLATE_ID',E'email',E'2023-07-10 16:33:10.288618',NULL,E'TESTING',E'4049c2d0-0cab-455c-8f4c-f356dff51811',E'TESTING',E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',1,FALSE,E'bulk',NULL,FALSE,NULL); """ insert_api_keys = """ From f5ad1078d2e415fd8c9e0b54de2c9d15fa3a5141 Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Thu, 10 Aug 2023 15:42:31 +0000 Subject: [PATCH 42/59] fix(ci): use differetn secret key and dangerous salt --- .github/workflows/cypress.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index 25ec180d03..defbaa7f8e 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -90,8 +90,8 @@ jobs: echo 'FF_CLOUDWATCH_METRICS_ENABLED=false' >> .env echo 'FF_SPIKE_SMS_DAILY_LIMIT=true' >> .env echo 'FRESH_DESK_ENABLED=false' >> .env - echo 'SECRET_KEY=local_secret_key' >> .env - echo 'DANGEROUS_SALT=local_dangerous_salt' >> .env + echo 'SECRET_KEY=${{ secrets.SECRET_KEY }}' >> .env + echo 'DANGEROUS_SALT=${{ secrets.DANGEROUS_SALT }}' >> .env echo 'NOTIFY_ENVIRONMENT=test' >> .env echo 'FLASK_APP=application.py' >> .env echo 'FLASK_DEBUG=true' >> .env From cc9e0b7e0b09b8f322f9e8a8db5a8229be9c22e0 Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Thu, 10 Aug 2023 16:12:58 +0000 Subject: [PATCH 43/59] fix(ci): use local config --- tests_cypress/config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests_cypress/config.js b/tests_cypress/config.js index 5cd94f0e18..14a0d05951 100644 --- a/tests_cypress/config.js +++ b/tests_cypress/config.js @@ -72,6 +72,6 @@ const config = { }; // choose which config to use here -const ConfigToUse = config.STAGING; +const ConfigToUse = config.LOCAL; module.exports = ConfigToUse; From df2f799e152b6a036df07e864f13006b6c8c1402 Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Thu, 10 Aug 2023 16:21:46 +0000 Subject: [PATCH 44/59] fix(seed): insert service permissions --- tests_cypress/seed_db.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests_cypress/seed_db.py b/tests_cypress/seed_db.py index 45e961fb3b..e263054443 100644 --- a/tests_cypress/seed_db.py +++ b/tests_cypress/seed_db.py @@ -15,17 +15,28 @@ VALUES (E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',E'Notify UI Tests',E'notify-ui-tests@cds-snc.ca',E'2023-05-24 13:41:48.022737',E'2023-08-01 13:20:08.017647',E'$2b$10$jwj45gXRLUIteNBwhRgEV.4P7uHGH11O2PhNiDK6SY6oRPSdKhg2u',E'6139863526',E'2023-05-24 13:41:48.017676',E'2023-08-01 13:20:08.014524',0,E'active',FALSE,E'8f6e79df-782d-4620-b86c-adf1ea933934',E'email_auth',FALSE,E'{}',FALSE); """ + insert_org = """ INSERT INTO "public"."organisation"("id","name","active","created_at","updated_at","email_branding_id","letter_branding_id","agreement_signed","agreement_signed_at","agreement_signed_by_id","agreement_signed_version","crown","organisation_type","request_to_go_live_notes","agreement_signed_on_behalf_of_email_address","agreement_signed_on_behalf_of_name","default_branding_is_french") VALUES (E'93413f91-227f-4704-b229-b8210d1ecc0a',E'GOC',TRUE,E'2023-05-16 15:08:29.552525',NULL,NULL,NULL,FALSE,NULL,NULL,NULL,TRUE,E'central',NULL,NULL,NULL,FALSE); """ + insert_service = """ INSERT INTO "public"."services"("id","name","created_at","updated_at","active","message_limit","restricted","email_from","created_by_id","version","research_mode","organisation_type","prefix_sms","crown","rate_limit","contact_link","consent_to_research","volume_email","volume_letter","volume_sms","count_as_live","go_live_at","go_live_user_id","organisation_id","sending_domain","default_branding_is_french","sms_daily_limit","organisation_notes") VALUES (E'4049c2d0-0cab-455c-8f4c-f356dff51811',E'Cypress2',E'2023-05-16 15:02:43.663183',E'2023-05-24 14:01:51.335072',TRUE,10000,FALSE,E'bouncey',E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',5,FALSE,E'central',TRUE,TRUE,1000,NULL,NULL,NULL,NULL,NULL,FALSE,E'2023-05-16 15:08:46.692247',NULL,E'93413f91-227f-4704-b229-b8210d1ecc0a',NULL,FALSE,1000,NULL); """ - + + insert_s_permissions = """ + INSERT INTO "public"."service_permissions"("service_id","permission","created_at") + VALUES + (E'4049c2d0-0cab-455c-8f4c-f356dff51810',E'email',E'2023-05-16 15:02:43.706537'), + (E'4049c2d0-0cab-455c-8f4c-f356dff51810',E'international_sms',E'2023-05-16 15:02:43.706543'), + (E'4049c2d0-0cab-455c-8f4c-f356dff51810',E'sms',E'2023-05-16 15:02:43.706528'), + (E'4049c2d0-0cab-455c-8f4c-f356dff51810',E'upload_document',E'2023-05-24 14:01:51.321006'); + """ + insert_templates = """ INSERT INTO "public"."templates"("id","name","template_type","created_at","updated_at","content","service_id","subject","created_by_id","version","archived","process_type","service_letter_contact_id","hidden","postage") VALUES @@ -48,5 +59,6 @@ conn.execute(sa.text(insert_user)) conn.execute(sa.text(insert_org)) conn.execute(sa.text(insert_service)) + conn.execute(sa.text(insert_s_permissions)) conn.execute(sa.text(insert_templates)) conn.execute(sa.text(insert_api_keys)) From 660c0795302bc521b80d91e71b8154dd255e6cc4 Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Thu, 10 Aug 2023 16:27:20 +0000 Subject: [PATCH 45/59] fix(ci): make service id consistent with api keys --- tests_cypress/seed_db.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests_cypress/seed_db.py b/tests_cypress/seed_db.py index e263054443..2a67727f70 100644 --- a/tests_cypress/seed_db.py +++ b/tests_cypress/seed_db.py @@ -25,7 +25,7 @@ insert_service = """ INSERT INTO "public"."services"("id","name","created_at","updated_at","active","message_limit","restricted","email_from","created_by_id","version","research_mode","organisation_type","prefix_sms","crown","rate_limit","contact_link","consent_to_research","volume_email","volume_letter","volume_sms","count_as_live","go_live_at","go_live_user_id","organisation_id","sending_domain","default_branding_is_french","sms_daily_limit","organisation_notes") VALUES - (E'4049c2d0-0cab-455c-8f4c-f356dff51811',E'Cypress2',E'2023-05-16 15:02:43.663183',E'2023-05-24 14:01:51.335072',TRUE,10000,FALSE,E'bouncey',E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',5,FALSE,E'central',TRUE,TRUE,1000,NULL,NULL,NULL,NULL,NULL,FALSE,E'2023-05-16 15:08:46.692247',NULL,E'93413f91-227f-4704-b229-b8210d1ecc0a',NULL,FALSE,1000,NULL); + (E'4049c2d0-0cab-455c-8f4c-f356dff51810',E'Cypress2',E'2023-05-16 15:02:43.663183',E'2023-05-24 14:01:51.335072',TRUE,10000,FALSE,E'bouncey',E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',5,FALSE,E'central',TRUE,TRUE,1000,NULL,NULL,NULL,NULL,NULL,FALSE,E'2023-05-16 15:08:46.692247',NULL,E'93413f91-227f-4704-b229-b8210d1ecc0a',NULL,FALSE,1000,NULL); """ insert_s_permissions = """ @@ -40,21 +40,21 @@ insert_templates = """ INSERT INTO "public"."templates"("id","name","template_type","created_at","updated_at","content","service_id","subject","created_by_id","version","archived","process_type","service_letter_contact_id","hidden","postage") VALUES - (E'136e951e-05c8-4db4-bc50-fe122d72fcaa',E'SMOKE_TEST_EMAIL',E'email',E'2023-05-24 13:31:40.907915',NULL,E'# This is a smoke test from Cypress\n\nSMOKE_TEST_EMAIL',E'4049c2d0-0cab-455c-8f4c-f356dff51811',E'SMOKE_TEST_EMAIL',E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',1,FALSE,E'bulk',NULL,FALSE,NULL), - (E'258d8617-da88-4faa-ad28-46cc69f5a458',E'VARIABLES_EMAIL_TEMPLATE_ID',E'email',E'2023-07-10 16:38:43.913184',NULL,E'Hi ((name))\n\n((has_stuff??You have stuff!))',E'4049c2d0-0cab-455c-8f4c-f356dff51811',E'TESTING',E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',1,FALSE,E'bulk',NULL,FALSE,NULL), - (E'2d52d997-42d3-4ac0-a597-7afc94d4339a',E'SMOKE_TEST_EMAIL_LINK',E'email',E'2023-05-24 13:32:49.286647',NULL,E'# This is a smoke test from Cypress\n\nSMOKE_TEST_EMAIL_LINK\n\n((link_to_file))',E'4049c2d0-0cab-455c-8f4c-f356dff51811',E'SMOKE_TEST_EMAIL_LINK',E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',1,FALSE,E'bulk',NULL,FALSE,NULL), - (E'48207d93-144d-4ebb-92c5-99ff1f1baead',E'SMOKE_TEST_EMAIL_BULK',E'email',E'2023-05-24 13:32:24.912515',NULL,E'# This is a smoke test from Cypress\n\nSMOKE_TEST_EMAIL_BULK',E'4049c2d0-0cab-455c-8f4c-f356dff51811',E'SMOKE_TEST_EMAIL_BULK',E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',1,FALSE,E'bulk',NULL,FALSE,NULL), - (E'58db03d6-a9d8-4482-8621-26f473f3980a',E'SMOKE_TEST_EMAIL_ATTACH',E'email',E'2023-05-24 13:32:03.754124',NULL,E'# This is a smoke test from Cypress\n\nSMOKE_TEST_EMAIL_ATTACH',E'4049c2d0-0cab-455c-8f4c-f356dff51811',E'SMOKE_TEST_EMAIL_ATTACH',E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',1,FALSE,E'bulk',NULL,FALSE,NULL), - (E'5945e2f0-3e37-4813-9a60-e0665e02e9c8',E'SMOKE_TEST_SMS',E'sms',E'2023-05-24 13:33:20.936811',NULL,E'SMOKE_TEST_SMS',E'4049c2d0-0cab-455c-8f4c-f356dff51811',NULL,E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',1,FALSE,E'bulk',NULL,FALSE,NULL), - (E'b4692883-4182-4a23-b1b9-7b9df66a66e8',E'SIMPLE_EMAIL_TEMPLATE_ID',E'email',E'2023-07-10 16:33:10.288618',NULL,E'TESTING',E'4049c2d0-0cab-455c-8f4c-f356dff51811',E'TESTING',E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',1,FALSE,E'bulk',NULL,FALSE,NULL); + (E'136e951e-05c8-4db4-bc50-fe122d72fcaa',E'SMOKE_TEST_EMAIL',E'email',E'2023-05-24 13:31:40.907915',NULL,E'# This is a smoke test from Cypress\n\nSMOKE_TEST_EMAIL',E'4049c2d0-0cab-455c-8f4c-f356dff51810',E'SMOKE_TEST_EMAIL',E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',1,FALSE,E'bulk',NULL,FALSE,NULL), + (E'258d8617-da88-4faa-ad28-46cc69f5a458',E'VARIABLES_EMAIL_TEMPLATE_ID',E'email',E'2023-07-10 16:38:43.913184',NULL,E'Hi ((name))\n\n((has_stuff??You have stuff!))',E'4049c2d0-0cab-455c-8f4c-f356dff51810',E'TESTING',E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',1,FALSE,E'bulk',NULL,FALSE,NULL), + (E'2d52d997-42d3-4ac0-a597-7afc94d4339a',E'SMOKE_TEST_EMAIL_LINK',E'email',E'2023-05-24 13:32:49.286647',NULL,E'# This is a smoke test from Cypress\n\nSMOKE_TEST_EMAIL_LINK\n\n((link_to_file))',E'4049c2d0-0cab-455c-8f4c-f356dff51810',E'SMOKE_TEST_EMAIL_LINK',E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',1,FALSE,E'bulk',NULL,FALSE,NULL), + (E'48207d93-144d-4ebb-92c5-99ff1f1baead',E'SMOKE_TEST_EMAIL_BULK',E'email',E'2023-05-24 13:32:24.912515',NULL,E'# This is a smoke test from Cypress\n\nSMOKE_TEST_EMAIL_BULK',E'4049c2d0-0cab-455c-8f4c-f356dff51810',E'SMOKE_TEST_EMAIL_BULK',E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',1,FALSE,E'bulk',NULL,FALSE,NULL), + (E'58db03d6-a9d8-4482-8621-26f473f3980a',E'SMOKE_TEST_EMAIL_ATTACH',E'email',E'2023-05-24 13:32:03.754124',NULL,E'# This is a smoke test from Cypress\n\nSMOKE_TEST_EMAIL_ATTACH',E'4049c2d0-0cab-455c-8f4c-f356dff51810',E'SMOKE_TEST_EMAIL_ATTACH',E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',1,FALSE,E'bulk',NULL,FALSE,NULL), + (E'5945e2f0-3e37-4813-9a60-e0665e02e9c8',E'SMOKE_TEST_SMS',E'sms',E'2023-05-24 13:33:20.936811',NULL,E'SMOKE_TEST_SMS',E'4049c2d0-0cab-455c-8f4c-f356dff51810',NULL,E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',1,FALSE,E'bulk',NULL,FALSE,NULL), + (E'b4692883-4182-4a23-b1b9-7b9df66a66e8',E'SIMPLE_EMAIL_TEMPLATE_ID',E'email',E'2023-07-10 16:33:10.288618',NULL,E'TESTING',E'4049c2d0-0cab-455c-8f4c-f356dff51810',E'TESTING',E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',1,FALSE,E'bulk',NULL,FALSE,NULL); """ insert_api_keys = """ INSERT INTO "public"."api_keys"("id","name","secret","service_id","expiry_date","created_at","created_by_id","updated_at","version","key_type") VALUES - (E'076fc5ba-8578-44d6-8b69-122ac3a7b206',E'CYPRESS_TEST_KEY',E'IjY3YTViZmU4LWMxNjktNDQ0NS04OGVjLWRkNWExZDA3NjFmYSI.wLt-AQOYG3vgab_qP1p0Djw_r-8',E'4049c2d0-0cab-455c-8f4c-f356dff51811',NULL,E'2023-07-10 16:44:13.025984',E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',NULL,1,E'test'), - (E'61a3f8e1-516d-446c-bc3a-c2dac33c9474',E'CYPRESS',E'IjhmYmE3MzUwLTIwN2ItNDRhYi1iNmYwLTVkZjk3ZjAzNjZlMyI.xiQ94d2oAedkohXNhx83B6cWr_0',E'4049c2d0-0cab-455c-8f4c-f356dff51811',NULL,E'2023-05-24 13:48:23.93561',E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',NULL,1,E'normal'), - (E'74a06881-7742-4d4a-85ff-b91ae71e1bcd',E'CYPRESS_TEAM_KEY',E'IjYxZjhhYzU3LTNlZGEtNDE3MS1iMDcyLTJjNTY0OWEzODI4ZSI.p6K5JNnYp6Pcn3OEQg1kDM1UHAY',E'4049c2d0-0cab-455c-8f4c-f356dff51811',NULL,E'2023-07-10 16:43:19.425995',E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',NULL,1,E'team'); + (E'076fc5ba-8578-44d6-8b69-122ac3a7b206',E'CYPRESS_TEST_KEY',E'IjY3YTViZmU4LWMxNjktNDQ0NS04OGVjLWRkNWExZDA3NjFmYSI.wLt-AQOYG3vgab_qP1p0Djw_r-8',E'4049c2d0-0cab-455c-8f4c-f356dff51810',NULL,E'2023-07-10 16:44:13.025984',E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',NULL,1,E'test'), + (E'61a3f8e1-516d-446c-bc3a-c2dac33c9474',E'CYPRESS',E'IjhmYmE3MzUwLTIwN2ItNDRhYi1iNmYwLTVkZjk3ZjAzNjZlMyI.xiQ94d2oAedkohXNhx83B6cWr_0',E'4049c2d0-0cab-455c-8f4c-f356dff51810',NULL,E'2023-05-24 13:48:23.93561',E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',NULL,1,E'normal'), + (E'74a06881-7742-4d4a-85ff-b91ae71e1bcd',E'CYPRESS_TEAM_KEY',E'IjYxZjhhYzU3LTNlZGEtNDE3MS1iMDcyLTJjNTY0OWEzODI4ZSI.p6K5JNnYp6Pcn3OEQg1kDM1UHAY',E'4049c2d0-0cab-455c-8f4c-f356dff51810',NULL,E'2023-07-10 16:43:19.425995',E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',NULL,1,E'team'); """ conn.execute(sa.text(insert_user)) conn.execute(sa.text(insert_org)) From 3ff62d35b219f20dc7ee222228820ab094ed422d Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Thu, 10 Aug 2023 16:36:25 +0000 Subject: [PATCH 46/59] fix(ci): run less tests to troubleshoot --- tests_cypress/cypress/e2e/api/email_notifications.cy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests_cypress/cypress/e2e/api/email_notifications.cy.js b/tests_cypress/cypress/e2e/api/email_notifications.cy.js index a1a4a3f79c..dfd3cca833 100644 --- a/tests_cypress/cypress/e2e/api/email_notifications.cy.js +++ b/tests_cypress/cypress/e2e/api/email_notifications.cy.js @@ -13,7 +13,7 @@ describe(`Email notifications test[${config.CONFIG_NAME}]`, () => { for (const api_key in keys) { context(`With ${api_key} api key`, () => { - it('can send email notification without personalisation', () => { + it.only('can send email notification without personalisation', () => { Notify.API.SendEmail({ api_key: keys[api_key], to: api_key === 'TEAM' ? config.Users.Team[0] : config.Users.Simulated[1], From b88cf5cecca7965f6fe3edd9382a777ca9dff70e Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Thu, 10 Aug 2023 17:01:53 +0000 Subject: [PATCH 47/59] fix(cypress config): update config to use notify-ui-tests@cds-snc.ca --- tests_cypress/config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests_cypress/config.js b/tests_cypress/config.js index 14a0d05951..2a19e406d9 100644 --- a/tests_cypress/config.js +++ b/tests_cypress/config.js @@ -20,7 +20,7 @@ let STAGING = { 'SMOKE_TEST_SMS': '16cae0b3-1d44-47ad-a537-fd12cc0646b6' }, Users: { - Team: ['andrew.leith+bannertest@cds-snc.ca'], + Team: ['notify-ui-tests@cds-snc.ca'], NonTeam: ['person@example.com'], Simulated: ['simulate-delivered-2@notification.canada.ca', 'simulate-delivered-3@notification.canada.ca', 'success@simulator.amazonses.com'], SimulatedPhone: ['+16132532222', '+16132532223', '+16132532224'] From d21f469ba1e84ace6cfc83816f5fe6e631bfcdab Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Thu, 10 Aug 2023 17:08:54 +0000 Subject: [PATCH 48/59] fix(cypress config): update the correct config this time --- tests_cypress/config.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests_cypress/config.js b/tests_cypress/config.js index 2a19e406d9..9e2ce96d97 100644 --- a/tests_cypress/config.js +++ b/tests_cypress/config.js @@ -20,7 +20,7 @@ let STAGING = { 'SMOKE_TEST_SMS': '16cae0b3-1d44-47ad-a537-fd12cc0646b6' }, Users: { - Team: ['notify-ui-tests@cds-snc.ca'], + Team: ['andrew.leith+bannertest@cds-snc.ca'], NonTeam: ['person@example.com'], Simulated: ['simulate-delivered-2@notification.canada.ca', 'simulate-delivered-3@notification.canada.ca', 'success@simulator.amazonses.com'], SimulatedPhone: ['+16132532222', '+16132532223', '+16132532224'] @@ -54,7 +54,7 @@ let LOCAL = { 'SMOKE_TEST_SMS': '5945e2f0-3e37-4813-9a60-e0665e02e9c8' }, Users: { - Team: ['andrew.leith+bannertest@cds-snc.ca'], + Team: ['notify-ui-tests@cds-snc.ca'], NonTeam: ['person@example.com'], Simulated: ['simulate-delivered-2@notification.canada.ca', 'simulate-delivered-3@notification.canada.ca', 'success@simulator.amazonses.com'], SimulatedPhone: ['+16132532222', '+16132532223', '+16132532224'] From a8b7dbda064b37b1faed3021de176a521b0172be Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Thu, 10 Aug 2023 17:16:39 +0000 Subject: [PATCH 49/59] fix(seed): add test user to service team --- tests_cypress/seed_db.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests_cypress/seed_db.py b/tests_cypress/seed_db.py index 2a67727f70..44157b1f99 100644 --- a/tests_cypress/seed_db.py +++ b/tests_cypress/seed_db.py @@ -36,7 +36,13 @@ (E'4049c2d0-0cab-455c-8f4c-f356dff51810',E'sms',E'2023-05-16 15:02:43.706528'), (E'4049c2d0-0cab-455c-8f4c-f356dff51810',E'upload_document',E'2023-05-24 14:01:51.321006'); """ - + + insert_user_to_service = """ + INSERT INTO "public"."user_to_service"("user_id","service_id") + VALUES + (E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',E'4049c2d0-0cab-455c-8f4c-f356dff51810'); + """ + insert_templates = """ INSERT INTO "public"."templates"("id","name","template_type","created_at","updated_at","content","service_id","subject","created_by_id","version","archived","process_type","service_letter_contact_id","hidden","postage") VALUES From 35ad21e45438c18169d479466afd64174c96afb2 Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Thu, 10 Aug 2023 17:37:46 +0000 Subject: [PATCH 50/59] fix(seeding): update permissions --- tests_cypress/seed_db.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests_cypress/seed_db.py b/tests_cypress/seed_db.py index 44157b1f99..9c8d53c679 100644 --- a/tests_cypress/seed_db.py +++ b/tests_cypress/seed_db.py @@ -36,7 +36,16 @@ (E'4049c2d0-0cab-455c-8f4c-f356dff51810',E'sms',E'2023-05-16 15:02:43.706528'), (E'4049c2d0-0cab-455c-8f4c-f356dff51810',E'upload_document',E'2023-05-24 14:01:51.321006'); """ - + insert_permissions = """ + INSERT INTO "public"."permissions"("id","service_id","user_id","permission","created_at") + VALUES + (E'074d892e-4608-45e7-b24f-53203ad75482',E'4049c2d0-0cab-455c-8f4c-f356dff51810',E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',E'view_activity',E'2023-05-24 13:41:57.755493'), + (E'1e59292c-ff05-466b-ac11-d77378d94aac',E'4049c2d0-0cab-455c-8f4c-f356dff51810',E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',E'manage_users',E'2023-05-24 13:41:57.755452'), + (E'20a1fb31-0e64-43a7-8d5e-fdd5ae97b006',E'4049c2d0-0cab-455c-8f4c-f356dff51810',E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',E'manage_api_keys',E'2023-05-24 13:41:57.755534'), + (E'544cbafa-a979-43aa-8727-45082af5c901',E'4049c2d0-0cab-455c-8f4c-f356dff51810',E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',E'manage_templates',E'2023-05-24 13:41:57.755554'), + (E'5ec04af6-4842-4c94-9294-b53cdaaf2166',E'4049c2d0-0cab-455c-8f4c-f356dff51810',E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',E'send_emails',E'2023-05-24 13:41:57.75558'), + (E'7b3a128a-45ea-4ec7-b897-c5bb1ce515d8',E'4049c2d0-0cab-455c-8f4c-f356dff51810',E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',E'send_letters',E'2023-05-24 13:41:57.755425'); + """ insert_user_to_service = """ INSERT INTO "public"."user_to_service"("user_id","service_id") VALUES From 3a3a28d7556b1e67c698c53d19354b5522251277 Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Thu, 10 Aug 2023 18:05:35 +0000 Subject: [PATCH 51/59] fix(ci): actually run all the SQL commands --- tests_cypress/seed_db.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests_cypress/seed_db.py b/tests_cypress/seed_db.py index 9c8d53c679..2408a5c760 100644 --- a/tests_cypress/seed_db.py +++ b/tests_cypress/seed_db.py @@ -71,9 +71,12 @@ (E'61a3f8e1-516d-446c-bc3a-c2dac33c9474',E'CYPRESS',E'IjhmYmE3MzUwLTIwN2ItNDRhYi1iNmYwLTVkZjk3ZjAzNjZlMyI.xiQ94d2oAedkohXNhx83B6cWr_0',E'4049c2d0-0cab-455c-8f4c-f356dff51810',NULL,E'2023-05-24 13:48:23.93561',E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',NULL,1,E'normal'), (E'74a06881-7742-4d4a-85ff-b91ae71e1bcd',E'CYPRESS_TEAM_KEY',E'IjYxZjhhYzU3LTNlZGEtNDE3MS1iMDcyLTJjNTY0OWEzODI4ZSI.p6K5JNnYp6Pcn3OEQg1kDM1UHAY',E'4049c2d0-0cab-455c-8f4c-f356dff51810',NULL,E'2023-07-10 16:43:19.425995',E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',NULL,1,E'team'); """ + conn.execute(sa.text(insert_user)) conn.execute(sa.text(insert_org)) conn.execute(sa.text(insert_service)) conn.execute(sa.text(insert_s_permissions)) + conn.execute(sa.text(insert_permissions)) + conn.execute(sa.text(insert_user_to_service)) conn.execute(sa.text(insert_templates)) conn.execute(sa.text(insert_api_keys)) From c3f0777324fb6adeac67a7c17430f682d7744b58 Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Fri, 11 Aug 2023 11:49:52 +0000 Subject: [PATCH 52/59] fix: remove team key tests --- tests_cypress/cypress/e2e/api/email_notifications.cy.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests_cypress/cypress/e2e/api/email_notifications.cy.js b/tests_cypress/cypress/e2e/api/email_notifications.cy.js index dfd3cca833..5cbaee594a 100644 --- a/tests_cypress/cypress/e2e/api/email_notifications.cy.js +++ b/tests_cypress/cypress/e2e/api/email_notifications.cy.js @@ -6,14 +6,14 @@ import Notify from "../../Notify/NotifyAPI"; describe(`Email notifications test[${config.CONFIG_NAME}]`, () => { var keys = { LIVE: Cypress.env(config.CONFIG_NAME).API_KEY_LIVE, - TEAM: Cypress.env(config.CONFIG_NAME).API_KEY_TEAM, - TEST: Cypress.env(config.CONFIG_NAME).API_KEY_TEST, + // TEAM: Cypress.env(config.CONFIG_NAME).API_KEY_TEAM, + // TEST: Cypress.env(config.CONFIG_NAME).API_KEY_TEST, }; for (const api_key in keys) { context(`With ${api_key} api key`, () => { - it.only('can send email notification without personalisation', () => { + it('can send email notification without personalisation', () => { Notify.API.SendEmail({ api_key: keys[api_key], to: api_key === 'TEAM' ? config.Users.Team[0] : config.Users.Simulated[1], From 362b342d35bf07639583f90611297e37bd601867 Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Fri, 11 Aug 2023 13:08:46 +0000 Subject: [PATCH 53/59] fix(cypress ci): change db connection string to the same as dev --- .github/workflows/cypress.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index defbaa7f8e..ba48b67ae8 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -11,8 +11,8 @@ jobs: image: postgres:11.17-bullseye env: POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - POSTGRES_DB: test_notification_api + POSTGRES_PASSWORD: chummy + POSTGRES_DB: notification_api ports: - 5432:5432 options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 @@ -75,14 +75,14 @@ jobs: echo 'AWS_REGION=ca-central-1' >> .env echo 'ASSET_DOMAIN=example.com' >> .env echo 'ASSET_UPLOAD_BUCKET_NAME=not-a-real-secret' >> .env - echo 'CSV_UPLOAD_BUCKET_NAME=not-a-real-secret' >> .env + echo 'CSV_UPLOAD_BUCKET_NAME=notification-canada-ca-staging-csv-upload' >> .env echo 'DOCUMENTS_BUCKET=not-a-real-secret' >> .env echo 'NOTIFY_EMAIL_DOMAIN=staging.notification.cdssandbox.xyz' >> .env echo 'ADMIN_CLIENT_SECRET=local_app' >> .env echo 'REDIS_URL=redis://redis:6379' >> .env echo 'REDIS_PUBLISH_URL=redis://redis:6379' >> .env - echo 'SQLALCHEMY_DATABASE_URI=postgresql://postgres:postgres@localhost:5432/test_notification_api' >> .env - echo 'SQLALCHEMY_DATABASE_READER_URI=postgresql://postgres:postgres@localhost:5432/test_notification_api' >> .env + echo 'SQLALCHEMY_DATABASE_URI=postgresql://postgres:chummy@localhost:5432/notification_api' >> .env + echo 'SQLALCHEMY_DATABASE_READER_URI=postgresql://postgres:chummy@localhost:5432/notification_api' >> .env echo 'DOCUMENT_DOWNLOAD_API_HOST=http://host.docker.internal:7000' >> .env echo 'FF_REDIS_BATCH_SAVING=true' >> .env echo 'FF_BATCH_INSERTION=true' >> .env @@ -115,4 +115,4 @@ jobs: record: false build: npx cypress info working-directory: tests_cypress - spec: cypress/e2e/api/all.cy.js \ No newline at end of file + spec: cypress/e2e/api/email_notifications.cy.js \ No newline at end of file From 512922bf5f53ac119098ba0b966f6cd33a01a2a9 Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Fri, 11 Aug 2023 13:13:03 +0000 Subject: [PATCH 54/59] fix(cypress tests): remove some tests for now --- .../cypress/e2e/api/email_notifications.cy.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests_cypress/cypress/e2e/api/email_notifications.cy.js b/tests_cypress/cypress/e2e/api/email_notifications.cy.js index 5cbaee594a..4f9e5826ce 100644 --- a/tests_cypress/cypress/e2e/api/email_notifications.cy.js +++ b/tests_cypress/cypress/e2e/api/email_notifications.cy.js @@ -43,7 +43,7 @@ describe(`Email notifications test[${config.CONFIG_NAME}]`, () => { }); - it('can send email to smoke test addresses', () => { + it.skip('can send email to smoke test addresses', () => { if (api_key !== 'TEAM') { for (const email of config.Users.Simulated) { Notify.API.SendEmail({ @@ -60,7 +60,7 @@ describe(`Email notifications test[${config.CONFIG_NAME}]`, () => { } }); - it('can use a non-default replyTo', () => { + it.skip('can use a non-default replyTo', () => { Notify.API.SendEmail({ api_key: keys[api_key], to: config.Users.Simulated[0], @@ -74,7 +74,7 @@ describe(`Email notifications test[${config.CONFIG_NAME}]`, () => { }); }); - it('can use a default replyTo', () => { + it.skip('can use a default replyTo', () => { Notify.API.SendEmail({ api_key: keys[api_key], to: config.Users.Simulated[0], @@ -88,7 +88,7 @@ describe(`Email notifications test[${config.CONFIG_NAME}]`, () => { }); }); - it('can use no replyTo', () => { + it.skip('can use no replyTo', () => { Notify.API.SendEmail({ api_key: keys[api_key], to: config.Users.Simulated[0], @@ -101,7 +101,7 @@ describe(`Email notifications test[${config.CONFIG_NAME}]`, () => { }); }); - it('Can scheduled a bulk email send', () => { + it.skip('Can scheduled a bulk email send', () => { // Schedule 20 seconds from now var secheduled_for = new Date(); secheduled_for.setSeconds(secheduled_for.getSeconds()+20); From 15cc0516cd7aa63dc046c7045253d3853d4bee55 Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Fri, 11 Aug 2023 13:13:19 +0000 Subject: [PATCH 55/59] fix(seed_db): update db URI --- tests_cypress/seed_db.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests_cypress/seed_db.py b/tests_cypress/seed_db.py index 2408a5c760..fd0d7330c3 100644 --- a/tests_cypress/seed_db.py +++ b/tests_cypress/seed_db.py @@ -1,6 +1,6 @@ import os -SQLALCHEMY_DATABASE_URI = "postgresql://postgres:postgres@localhost:5432/test_notification_api" #os.getenv("SQLALCHEMY_DATABASE_URI") +SQLALCHEMY_DATABASE_URI = os.getenv("SQLALCHEMY_DATABASE_URI") print(SQLALCHEMY_DATABASE_URI) import sqlalchemy as sa From d79d18e30fb78a690e709b7829c2deb47b9bc37a Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Mon, 14 Aug 2023 12:27:21 +0000 Subject: [PATCH 56/59] fix(seed): add reply to data --- tests_cypress/seed_db.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests_cypress/seed_db.py b/tests_cypress/seed_db.py index fd0d7330c3..0ab5093b56 100644 --- a/tests_cypress/seed_db.py +++ b/tests_cypress/seed_db.py @@ -71,7 +71,12 @@ (E'61a3f8e1-516d-446c-bc3a-c2dac33c9474',E'CYPRESS',E'IjhmYmE3MzUwLTIwN2ItNDRhYi1iNmYwLTVkZjk3ZjAzNjZlMyI.xiQ94d2oAedkohXNhx83B6cWr_0',E'4049c2d0-0cab-455c-8f4c-f356dff51810',NULL,E'2023-05-24 13:48:23.93561',E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',NULL,1,E'normal'), (E'74a06881-7742-4d4a-85ff-b91ae71e1bcd',E'CYPRESS_TEAM_KEY',E'IjYxZjhhYzU3LTNlZGEtNDE3MS1iMDcyLTJjNTY0OWEzODI4ZSI.p6K5JNnYp6Pcn3OEQg1kDM1UHAY',E'4049c2d0-0cab-455c-8f4c-f356dff51810',NULL,E'2023-07-10 16:43:19.425995',E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',NULL,1,E'team'); """ - + insert_reply_tos = """ + INSERT INTO "public"."service_email_reply_to"("id","service_id","email_address","is_default","created_at","updated_at","archived") + VALUES + (E'1bc45a34-f4de-4635-b36f-7da2e2d248ed',E'4049c2d0-0cab-455c-8f4c-f356dff51810',E'andrew.leith+testing@cds-snc.ca',TRUE,E'2023-07-10 16:41:25.562693',NULL,FALSE), + (E'aaa58593-fc0a-46b0-82b8-b303ae662a41',E'4049c2d0-0cab-455c-8f4c-f356dff51810',E'andrew.leith+testing_second_reply@cds-snc.ca',FALSE,E'2023-07-10 16:42:30.376411',NULL,FALSE); + """ conn.execute(sa.text(insert_user)) conn.execute(sa.text(insert_org)) conn.execute(sa.text(insert_service)) @@ -80,3 +85,4 @@ conn.execute(sa.text(insert_user_to_service)) conn.execute(sa.text(insert_templates)) conn.execute(sa.text(insert_api_keys)) + conn.execute(sa.text(insert_reply_tos)) From 02804e22601f553d82f003a9f8b7f5b43fde5986 Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Mon, 14 Aug 2023 12:28:13 +0000 Subject: [PATCH 57/59] fix(api tests): re-enable all tests --- tests_cypress/cypress/e2e/api/all.cy.js | 2 +- .../cypress/e2e/api/email_notifications.cy.js | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests_cypress/cypress/e2e/api/all.cy.js b/tests_cypress/cypress/e2e/api/all.cy.js index 3a52c1c0d7..e23ef40716 100644 --- a/tests_cypress/cypress/e2e/api/all.cy.js +++ b/tests_cypress/cypress/e2e/api/all.cy.js @@ -1,2 +1,2 @@ import './email_notifications.cy'; -import './file_attach.cy'; +// import './file_attach.cy'; diff --git a/tests_cypress/cypress/e2e/api/email_notifications.cy.js b/tests_cypress/cypress/e2e/api/email_notifications.cy.js index 4f9e5826ce..5cbaee594a 100644 --- a/tests_cypress/cypress/e2e/api/email_notifications.cy.js +++ b/tests_cypress/cypress/e2e/api/email_notifications.cy.js @@ -43,7 +43,7 @@ describe(`Email notifications test[${config.CONFIG_NAME}]`, () => { }); - it.skip('can send email to smoke test addresses', () => { + it('can send email to smoke test addresses', () => { if (api_key !== 'TEAM') { for (const email of config.Users.Simulated) { Notify.API.SendEmail({ @@ -60,7 +60,7 @@ describe(`Email notifications test[${config.CONFIG_NAME}]`, () => { } }); - it.skip('can use a non-default replyTo', () => { + it('can use a non-default replyTo', () => { Notify.API.SendEmail({ api_key: keys[api_key], to: config.Users.Simulated[0], @@ -74,7 +74,7 @@ describe(`Email notifications test[${config.CONFIG_NAME}]`, () => { }); }); - it.skip('can use a default replyTo', () => { + it('can use a default replyTo', () => { Notify.API.SendEmail({ api_key: keys[api_key], to: config.Users.Simulated[0], @@ -88,7 +88,7 @@ describe(`Email notifications test[${config.CONFIG_NAME}]`, () => { }); }); - it.skip('can use no replyTo', () => { + it('can use no replyTo', () => { Notify.API.SendEmail({ api_key: keys[api_key], to: config.Users.Simulated[0], @@ -101,7 +101,7 @@ describe(`Email notifications test[${config.CONFIG_NAME}]`, () => { }); }); - it.skip('Can scheduled a bulk email send', () => { + it('Can scheduled a bulk email send', () => { // Schedule 20 seconds from now var secheduled_for = new Date(); secheduled_for.setSeconds(secheduled_for.getSeconds()+20); From 12844c783e0e247065382b5fb77fd523ab27e83b Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Mon, 14 Aug 2023 12:38:25 +0000 Subject: [PATCH 58/59] fix(seed): hardcode URI temporarily --- tests_cypress/seed_db.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests_cypress/seed_db.py b/tests_cypress/seed_db.py index 0ab5093b56..4068e2618e 100644 --- a/tests_cypress/seed_db.py +++ b/tests_cypress/seed_db.py @@ -1,6 +1,6 @@ import os -SQLALCHEMY_DATABASE_URI = os.getenv("SQLALCHEMY_DATABASE_URI") +SQLALCHEMY_DATABASE_URI = 'postgresql://postgres:chummy@localhost:5432/notification_api'#os.getenv("SQLALCHEMY_DATABASE_URI") print(SQLALCHEMY_DATABASE_URI) import sqlalchemy as sa From 9c929057a3a37198a4bbeaf590bdf8ba9e0aa9df Mon Sep 17 00:00:00 2001 From: Andrew Leith Date: Mon, 14 Aug 2023 12:58:57 +0000 Subject: [PATCH 59/59] chore: formatting --- tests_cypress/seed_db.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tests_cypress/seed_db.py b/tests_cypress/seed_db.py index 4068e2618e..04953002b9 100644 --- a/tests_cypress/seed_db.py +++ b/tests_cypress/seed_db.py @@ -1,15 +1,14 @@ -import os +# import os +import sqlalchemy as sa -SQLALCHEMY_DATABASE_URI = 'postgresql://postgres:chummy@localhost:5432/notification_api'#os.getenv("SQLALCHEMY_DATABASE_URI") +SQLALCHEMY_DATABASE_URI = 'postgresql://postgres:chummy@localhost:5432/notification_api' # os.getenv("SQLALCHEMY_DATABASE_URI") print(SQLALCHEMY_DATABASE_URI) -import sqlalchemy as sa - # set connection URI here ↓ engine = sa.create_engine(SQLALCHEMY_DATABASE_URI) with engine.connect() as conn: - with conn.begin(): + with conn.begin(): insert_user = """ INSERT INTO "public"."users"("id","name","email_address","created_at","updated_at","_password","mobile_number","password_changed_at","logged_in_at","failed_login_count","state","platform_admin","current_session_id","auth_type","blocked","additional_information","password_expired") VALUES @@ -27,7 +26,7 @@ VALUES (E'4049c2d0-0cab-455c-8f4c-f356dff51810',E'Cypress2',E'2023-05-16 15:02:43.663183',E'2023-05-24 14:01:51.335072',TRUE,10000,FALSE,E'bouncey',E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',5,FALSE,E'central',TRUE,TRUE,1000,NULL,NULL,NULL,NULL,NULL,FALSE,E'2023-05-16 15:08:46.692247',NULL,E'93413f91-227f-4704-b229-b8210d1ecc0a',NULL,FALSE,1000,NULL); """ - + insert_s_permissions = """ INSERT INTO "public"."service_permissions"("service_id","permission","created_at") VALUES @@ -35,7 +34,7 @@ (E'4049c2d0-0cab-455c-8f4c-f356dff51810',E'international_sms',E'2023-05-16 15:02:43.706543'), (E'4049c2d0-0cab-455c-8f4c-f356dff51810',E'sms',E'2023-05-16 15:02:43.706528'), (E'4049c2d0-0cab-455c-8f4c-f356dff51810',E'upload_document',E'2023-05-24 14:01:51.321006'); - """ + """ insert_permissions = """ INSERT INTO "public"."permissions"("id","service_id","user_id","permission","created_at") VALUES @@ -63,7 +62,7 @@ (E'5945e2f0-3e37-4813-9a60-e0665e02e9c8',E'SMOKE_TEST_SMS',E'sms',E'2023-05-24 13:33:20.936811',NULL,E'SMOKE_TEST_SMS',E'4049c2d0-0cab-455c-8f4c-f356dff51810',NULL,E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',1,FALSE,E'bulk',NULL,FALSE,NULL), (E'b4692883-4182-4a23-b1b9-7b9df66a66e8',E'SIMPLE_EMAIL_TEMPLATE_ID',E'email',E'2023-07-10 16:33:10.288618',NULL,E'TESTING',E'4049c2d0-0cab-455c-8f4c-f356dff51810',E'TESTING',E'3f478896-6d3f-4ef3-aa5a-530fea1206bb',1,FALSE,E'bulk',NULL,FALSE,NULL); """ - + insert_api_keys = """ INSERT INTO "public"."api_keys"("id","name","secret","service_id","expiry_date","created_at","created_by_id","updated_at","version","key_type") VALUES