From e50b4bb5f71d80d65be9211ce6b9f2b9afdc4c59 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Mon, 29 Apr 2024 10:42:31 -0700 Subject: [PATCH] try overriding pytest.ini variables --- app/main/views/sign_in.py | 20 +++++++++++--------- tests/end_to_end/conftest.py | 3 +++ tests/end_to_end/test_create_new_template.py | 12 +++++++++--- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/app/main/views/sign_in.py b/app/main/views/sign_in.py index 4863392da..927bd4652 100644 --- a/app/main/views/sign_in.py +++ b/app/main/views/sign_in.py @@ -132,10 +132,20 @@ def verify_email(user, redirect_url): @main.route("/sign-in", methods=(["GET", "POST"])) @hide_from_search_engines def sign_in(): + + if os.getenv("NOTIFY_E2E_TEST_EMAIL"): + current_app.logger.warning("E2E TESTS ARE ENABLED.") + current_app.logger.warning( + "If you are getting a 404 on signin, comment out E2E vars in .env file!" + ) + user = user_api_client.get_user_by_email(os.getenv("NOTIFY_E2E_TEST_EMAIL")) + activate_user(user["id"]) + return redirect(url_for("main.show_accounts_or_dashboard")) + # If we have to revalidated the email, send the message # via email and redirect to the "verify your email page" # and don't proceed further with login - current_app.logger.warning("HIT SIGNIN!") + email_verify_template = _do_login_dot_gov() if ( email_verify_template @@ -146,14 +156,6 @@ def sign_in(): redirect_url = request.args.get("next") - if os.getenv("NOTIFY_E2E_TEST_EMAIL"): - current_app.logger.warning("E2E TESTS ARE ENABLED.") - current_app.logger.warning( - "If you are getting a 404 on signin, comment out E2E vars in .env file!" - ) - user = user_api_client.get_user_by_email(os.getenv("NOTIFY_E2E_TEST_EMAIL")) - activate_user(user["id"]) - return redirect(url_for("main.show_accounts_or_dashboard", next=redirect_url)) current_app.logger.warning("FAILED TO BOUNCE OUT OF SIGN IN") current_app.logger.info(f"current user is {current_user}") if current_user and current_user.is_authenticated: diff --git a/tests/end_to_end/conftest.py b/tests/end_to_end/conftest.py index 19c708aee..e0d182f09 100644 --- a/tests/end_to_end/conftest.py +++ b/tests/end_to_end/conftest.py @@ -88,6 +88,9 @@ def end_to_end_context(browser): context = browser.new_context() return context +def pytest_generate_tests(metafunc): + os.environ['DANGEROUS_SALT'] = 'blahblahdiddiblah' + @pytest.fixture() def authenticated_page(end_to_end_context): diff --git a/tests/end_to_end/test_create_new_template.py b/tests/end_to_end/test_create_new_template.py index bc254d072..4aa25019b 100644 --- a/tests/end_to_end/test_create_new_template.py +++ b/tests/end_to_end/test_create_new_template.py @@ -12,9 +12,15 @@ E2E_TEST_URI = os.getenv("NOTIFY_E2E_TEST_URI") def _setup(page): # Prepare for adding a new service later in the test. - current_app.logger.warning(f"ESE_TEST_URI={E2E_TEST_URI}") - current_app.logger.warning(f"NOTIFY_ENVIRONMENT={os.getenv('NOTIFY_ENVIRONMENT')}") - current_app.logger.warning(f"E2E EMAIL {os.getenv('NOTIFY_E2E_TEST_EMAIL')}") + print(f"ESE_TEST_URI={E2E_TEST_URI}") + print(f"NOTIFY_ENVIRONMENT={os.getenv('NOTIFY_ENVIRONMENT')}") + print(f"E2E EMAIL {os.getenv('NOTIFY_E2E_TEST_EMAIL')}") + print(f"E2E DANGEROUS SALT {os.getenv('DANGEROUS_SALT')}") + print(f"E2E SECRET_KEY {os.getenv('SECRET_KEY')}") + print(f"E2E ADMIN_CLIENT_SECRET {os.getenv('ADMIN_CLIENT_SECRET')}") + print(f"E2E ADMIN_CLIENT_USERNAME {os.getenv('ADMIN_CLIENT_USERNAME')}") + + current_date_time = datetime.datetime.now() new_service_name = "E2E Federal Test Service {now} - {browser_type}".format( now=current_date_time.strftime("%m/%d/%Y %H:%M:%S"),