mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-10 10:03:21 -04:00
Made a few adjustments to test the beta redirect:
- Explicitly return the redirect - Change the redirect to be a 302 instead of 301 - Adjusted the test client to allow sub domains - Added the remaining tests A big thank you to @A-Shumway42 for getting this work underway! Signed-off-by: Carlo Costino <carlo.costino@gsa.gov>
This commit is contained in:
@@ -344,7 +344,7 @@ def redirect_notify_to_beta():
|
|||||||
and "beta.notify.gov" not in request.url
|
and "beta.notify.gov" not in request.url
|
||||||
):
|
):
|
||||||
url_to_beta = create_beta_url(request.url)
|
url_to_beta = create_beta_url(request.url)
|
||||||
redirect(url_to_beta, 301)
|
return redirect(url_to_beta, 302)
|
||||||
|
|
||||||
|
|
||||||
def load_service_before_request():
|
def load_service_before_request():
|
||||||
|
|||||||
@@ -8,10 +8,31 @@ def test_create_beta_url():
|
|||||||
assert url_for_redirect == "https://beta.notify.gov/using-notify/get-started"
|
assert url_for_redirect == "https://beta.notify.gov/using-notify/get-started"
|
||||||
|
|
||||||
|
|
||||||
|
def test_no_redirect_notify_to_beta_non_production(monkeypatch, client_request):
|
||||||
|
monkeypatch.setitem(current_app.config, "NOTIFY_ENVIRONMENT", "development")
|
||||||
|
assert current_app.config["NOTIFY_ENVIRONMENT"] == "development"
|
||||||
|
|
||||||
|
|
||||||
|
client_request.get_response_from_url(
|
||||||
|
"https://notify.gov/using-notify/get-started",
|
||||||
|
_expected_status=200
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_redirect_notify_to_beta(monkeypatch, client_request):
|
def test_redirect_notify_to_beta(monkeypatch, client_request):
|
||||||
monkeypatch.setitem(current_app.config, "NOTIFY_ENVIRONMENT", "production")
|
monkeypatch.setitem(current_app.config, "NOTIFY_ENVIRONMENT", "production")
|
||||||
# import pdb
|
|
||||||
# pdb.set_trace()
|
|
||||||
# resp = client_request.get_response_from_url("https://notify.gov/using-notify/get-started")
|
|
||||||
# assert resp.status_code == 301
|
|
||||||
assert current_app.config["NOTIFY_ENVIRONMENT"] == "production"
|
assert current_app.config["NOTIFY_ENVIRONMENT"] == "production"
|
||||||
|
|
||||||
|
client_request.get_response_from_url(
|
||||||
|
"https://notify.gov/using-notify/get-started",
|
||||||
|
_expected_status=302
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_no_redirect_beta_notify_to_beta(monkeypatch, client_request):
|
||||||
|
monkeypatch.setitem(current_app.config, "NOTIFY_ENVIRONMENT", "production")
|
||||||
|
assert current_app.config["NOTIFY_ENVIRONMENT"] == "production"
|
||||||
|
|
||||||
|
client_request.get_response_from_url(
|
||||||
|
"https://beta.notify.gov/using-notify/get-started",
|
||||||
|
_expected_status=200
|
||||||
|
)
|
||||||
|
|||||||
@@ -2392,6 +2392,7 @@ def _client(notify_admin):
|
|||||||
Do not use this fixture directly – use `client_request` instead
|
Do not use this fixture directly – use `client_request` instead
|
||||||
"""
|
"""
|
||||||
with notify_admin.test_request_context(), notify_admin.test_client() as client:
|
with notify_admin.test_request_context(), notify_admin.test_client() as client:
|
||||||
|
client.allow_subdomain_redirects = True
|
||||||
yield client
|
yield client
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user