Merge pull request #202 from dod-ccpo/redirect-non-ccpo-to-requests
Redirect non-ccpo users to requests page after CAC or dev login
This commit is contained in:
commit
70cc82a1e7
@ -46,7 +46,10 @@ def login_redirect():
|
||||
user = auth_context.get_user()
|
||||
session["user_id"] = user.id
|
||||
|
||||
return redirect(url_for("atst.home"))
|
||||
if user.atat_role.name == "ccpo":
|
||||
return redirect(url_for("atst.home"))
|
||||
else:
|
||||
return redirect(url_for("requests.requests_index"))
|
||||
|
||||
|
||||
def _is_valid_certificate(request):
|
||||
|
@ -61,4 +61,8 @@ def login_dev():
|
||||
email=user_data["email"]
|
||||
)
|
||||
session["user_id"] = user.id
|
||||
return redirect(url_for("atst.home"))
|
||||
|
||||
if user.atat_role.name == "ccpo":
|
||||
return redirect(url_for("atst.home"))
|
||||
else:
|
||||
return redirect(url_for("requests.requests_index"))
|
||||
|
@ -2,6 +2,7 @@ import pytest
|
||||
from flask import session, url_for
|
||||
from .mocks import DOD_SDN_INFO, DOD_SDN, FIXTURE_EMAIL_ADDRESS
|
||||
from atst.domain.users import Users
|
||||
from atst.domain.roles import Roles
|
||||
from atst.domain.exceptions import NotFoundError
|
||||
from .factories import UserFactory
|
||||
|
||||
@ -13,7 +14,7 @@ def _fetch_user_info(c, t):
|
||||
return MOCK_USER
|
||||
|
||||
|
||||
def test_successful_login_redirect(client, monkeypatch):
|
||||
def test_successful_login_redirect_non_ccpo(client, monkeypatch):
|
||||
monkeypatch.setattr("atst.domain.authnid.AuthenticationContext.authenticate", lambda *args: True)
|
||||
monkeypatch.setattr("atst.domain.authnid.AuthenticationContext.get_user", lambda *args: UserFactory.create())
|
||||
|
||||
@ -26,6 +27,24 @@ def test_successful_login_redirect(client, monkeypatch):
|
||||
},
|
||||
)
|
||||
|
||||
assert resp.status_code == 302
|
||||
assert "requests" in resp.headers["Location"]
|
||||
assert session["user_id"]
|
||||
|
||||
def test_successful_login_redirect_ccpo(client, monkeypatch):
|
||||
monkeypatch.setattr("atst.domain.authnid.AuthenticationContext.authenticate", lambda *args: True)
|
||||
role = Roles.get("ccpo")
|
||||
monkeypatch.setattr("atst.domain.authnid.AuthenticationContext.get_user", lambda *args: UserFactory.create(atat_role=role))
|
||||
|
||||
resp = client.get(
|
||||
"/login-redirect",
|
||||
environ_base={
|
||||
"HTTP_X_SSL_CLIENT_VERIFY": "SUCCESS",
|
||||
"HTTP_X_SSL_CLIENT_S_DN": "",
|
||||
"HTTP_X_SSL_CLIENT_CERT": "",
|
||||
},
|
||||
)
|
||||
|
||||
assert resp.status_code == 302
|
||||
assert "home" in resp.headers["Location"]
|
||||
assert session["user_id"]
|
||||
@ -90,7 +109,7 @@ def test_crl_validation_on_login(client):
|
||||
},
|
||||
)
|
||||
assert resp.status_code == 302
|
||||
assert "home" in resp.headers["Location"]
|
||||
assert "requests" in resp.headers["Location"]
|
||||
assert session["user_id"]
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user