From fa105a95e3e339d0bd968957b98ee5e3b105bb61 Mon Sep 17 00:00:00 2001 From: richard-dds Date: Wed, 5 Sep 2018 10:39:05 -0400 Subject: [PATCH] Redirect to home after login, which redirects elsewhere --- atst/routes/__init__.py | 4 ++-- atst/routes/dev.py | 2 +- tests/routes/test_home.py | 4 ++-- tests/test_auth.py | 6 ++---- tests/test_routes.py | 1 - 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/atst/routes/__init__.py b/atst/routes/__init__.py index da65796b..fb53802a 100644 --- a/atst/routes/__init__.py +++ b/atst/routes/__init__.py @@ -17,7 +17,7 @@ def root(): @bp.route("/home") def home(): - return render_template("home.html") + return redirect(url_for("requests.requests_index")) @bp.route("/styleguide") @@ -46,7 +46,7 @@ def login_redirect(): user = auth_context.get_user() session["user_id"] = user.id - return redirect(url_for("requests.requests_index")) + return redirect(url_for(".home")) def _is_valid_certificate(request): diff --git a/atst/routes/dev.py b/atst/routes/dev.py index 00e8c48e..0b53daf0 100644 --- a/atst/routes/dev.py +++ b/atst/routes/dev.py @@ -63,4 +63,4 @@ def login_dev(): ) session["user_id"] = user.id - return redirect(url_for("requests.requests_index")) + return redirect(url_for("atst.home")) diff --git a/tests/routes/test_home.py b/tests/routes/test_home.py index 1e0c1712..daa1c7ce 100644 --- a/tests/routes/test_home.py +++ b/tests/routes/test_home.py @@ -8,12 +8,12 @@ def test_user_with_workspaces_has_workspaces_nav(client, user_session): Workspaces._create_workspace_role(user, workspace, "default") user_session(user) - response = client.get("/home") + response = client.get("/home", follow_redirects=True) assert b'href="/workspaces"' in response.data def test_user_without_workspaces_has_no_workspaces_nav(client, user_session): user = UserFactory.create() user_session(user) - response = client.get("/home") + response = client.get("/home", follow_redirects=True) assert b'href="/workspaces"' not in response.data diff --git a/tests/test_auth.py b/tests/test_auth.py index cf9cc107..2bf24b69 100644 --- a/tests/test_auth.py +++ b/tests/test_auth.py @@ -33,7 +33,7 @@ def test_successful_login_redirect_non_ccpo(client, monkeypatch): ) assert resp.status_code == 302 - assert "requests" in resp.headers["Location"] + assert "home" in resp.headers["Location"] assert session["user_id"] @@ -57,7 +57,7 @@ def test_successful_login_redirect_ccpo(client, monkeypatch): ) assert resp.status_code == 302 - assert "requests" in resp.headers["Location"] + assert "home" in resp.headers["Location"] assert session["user_id"] @@ -119,8 +119,6 @@ def test_crl_validation_on_login(client): "HTTP_X_SSL_CLIENT_CERT": good_cert, }, ) - assert resp.status_code == 302 - assert "requests" in resp.headers["Location"] assert session["user_id"] diff --git a/tests/test_routes.py b/tests/test_routes.py index 4b079645..c2d77150 100644 --- a/tests/test_routes.py +++ b/tests/test_routes.py @@ -5,7 +5,6 @@ import pytest "path", ( "/", - "/home", "/workspaces", "/requests", "/requests/new/1",