Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/scaffold UI test user on demand #2286

Merged
merged 43 commits into from
Nov 8, 2024

Conversation

andrewleith
Copy link
Member

@andrewleith andrewleith commented Sep 13, 2024

Summary | Résumé

API Changes

This PR adds a new API endpoint, secured by the admin_auth mechanism, at /cypress:

  • /cypress/create_user/<email_name>
  • /cypress/cleanup

At the start of each UI test session, both methods will be called:

  • /create_user will be called to generate a unique set of accounts (regular + platform admin) for the test run.
  • /cleanup will be called to remove any test accounts older than 3 hours

Note: these endpoints will be blocked from running in PROD in code, as well as by the WAF.

/create_user

/cleanup

  • Loops through all accounts with the UI testing prefix (notify-ui-tests+ag_) that are older than 3 hours and removes them and their related entities.

Migration

This PR also adds a migration to create the a base UI test service and user that will be used for all tests, and introduces some new config variables to keep track of these:

  • CYPRESS_SERVICE_ID: ID of the cypress service used in UI tests
  • CYPRESS_TEST_USER_ID: ID of the base cypress ui test user (this will not get removed between tests)
  • CYPRESS_TEST_USER_ADMIN_ID: ID of the base cypress ui platform admin test user (this will not get removed between tests)
  • CYPRESS_SMOKE_TEST_EMAIL_TEMPLATE_ID: ID of base email template used in tests
  • CYPRESS_SMOKE_TEST_SMS_TEMPLATE_ID: ID of base SMS template used in tests
  • CYPRESS_USER_PW_SECRET: password of generated UI test users

Related Issues | Cartes liées

Test instructions | Instructions pour tester la modification

TODO: Fill in test instructions for the reviewer.

Release Instructions | Instructions pour le déploiement

None.

Reviewer checklist | Liste de vérification du réviseur

  • This PR does not break existing functionality.
  • This PR does not violate GCNotify's privacy policies.
  • This PR does not raise new security concerns. Refer to our GC Notify Risk Register document on our Google drive.
  • This PR does not significantly alter performance.
  • Additional required documentation resulting of these changes is covered (such as the README, setup instructions, a related ADR or the technical documentation).

⚠ If boxes cannot be checked off before merging the PR, they should be moved to the "Release Instructions" section with appropriate steps required to verify before release. For example, changes to celery code may require tests on staging to verify that performance has not been affected.

@andrewleith andrewleith marked this pull request as draft September 13, 2024 13:47
app/cypress/rest.py Fixed Show fixed Hide fixed
app/cypress/rest.py Fixed Show fixed Hide fixed
- add safeguards to ensure this cant run in prod
- hash the password on the fly instead of storing another secret
- add safeguards to ensure this cant run in prod
- remove/update related tables
app/cypress/rest.py Fixed Show fixed Hide fixed
app/cypress/rest.py Fixed Show fixed Hide fixed
app/cypress/rest.py Fixed Show fixed Hide fixed
app/cypress/rest.py Fixed Show fixed Hide fixed
app/cypress/rest.py Fixed Show fixed Hide fixed
app/cypress/rest.py Fixed Show fixed Hide fixed
tests/app/conftest.py Fixed Show fixed Hide fixed
tests/app/cypress/test_rest.py Fixed Show fixed Hide fixed
tests/app/cypress/test_rest.py Fixed Show fixed Hide fixed
app/__init__.py Show resolved Hide resolved
app/__init__.py Show resolved Hide resolved
app/authentication/auth.py Show resolved Hide resolved
app/authentication/auth.py Outdated Show resolved Hide resolved
app/authentication/auth.py Outdated Show resolved Hide resolved
tests/app/cypress/test_rest.py Outdated Show resolved Hide resolved
tests/app/cypress/test_rest.py Outdated Show resolved Hide resolved
tests/app/cypress/test_rest.py Outdated Show resolved Hide resolved
tests/app/cypress/test_rest.py Outdated Show resolved Hide resolved
tests/app/cypress/test_rest.py Show resolved Hide resolved
@@ -0,0 +1,205 @@
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

Love this addition + the Cypress auth, I'll be sure to move the utility method from that PR in here too!

Copy link
Contributor

@whabanks whabanks left a comment

Choose a reason for hiding this comment

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

LGTM, exciting changes!

@andrewleith andrewleith marked this pull request as ready for review November 8, 2024 15:31
@andrewleith andrewleith merged commit 9f30e3a into main Nov 8, 2024
5 checks passed
@andrewleith andrewleith deleted the feat/scaffold-ui-test-user-on-demand branch November 8, 2024 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants