Ensure users are authenticated for most pages (#586)

* Ensure users are authenticated for most pages

This changeset makes sure that users must be authenticated and logged in to view most pages of the Notify service.  We are moving to a model where only the home page and a select few others will be publicly accessible for the time being.

Signed-off-by: Carlo Costino <carlo.costino@gsa.gov>
This commit is contained in:
Carlo Costino
2023-07-03 15:03:33 -04:00
committed by GitHub
parent 1d8059da94
commit da84a18970
3 changed files with 34 additions and 7 deletions

View File

@@ -71,7 +71,6 @@ def test_robots(client_request):
('bat_phone', {}),
('thanks', {}),
('register', {}),
('features_email', {}),
pytest.param('index', {}, marks=pytest.mark.xfail(raises=AssertionError)),
))
@freeze_time('2012-12-12 12:12') # So we dont go out of business hours
@@ -116,12 +115,17 @@ def test_static_pages(
session['service_id'] = None
request()
# Check it still works when they sign out
# Check it redirects to the login screen when they sign out
client_request.logout()
with client_request.session_transaction() as session:
session['service_id'] = None
session['user_id'] = None
request()
request(
_expected_status=302,
_expected_redirect='/sign-in?next={}'.format(
url_for('main.{}'.format(view))
)
)
def test_guidance_pages_link_to_service_pages_when_signed_in(
@@ -143,12 +147,12 @@ def test_guidance_pages_link_to_service_pages_when_signed_in(
page = request()
assert not page.select_one(selector)
# Check it still works when they sign out
# Check it redirects to the login screen when they sign out
client_request.logout()
with client_request.session_transaction() as session:
session['service_id'] = None
session['user_id'] = None
page = request()
page = request(_expected_status=302)
assert not page.select_one(selector)