mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-05-05 16:38:59 -04:00
NOTE: you can not test that the session is cleared out by checking the session cookie does not exist on the index page, because ItsDangerousSession will create a new session when it hits the index page. The unit test confirms that the session has been cleared.
37 lines
1.4 KiB
Python
37 lines
1.4 KiB
Python
from flask import url_for
|
|
|
|
|
|
def test_render_sign_out_redirects_to_sign_in(app_):
|
|
with app_.test_request_context():
|
|
response = app_.test_client().get(
|
|
url_for('main.sign_out'))
|
|
assert response.status_code == 302
|
|
assert response.location == url_for(
|
|
'main.sign_in', _external=True, next=url_for('main.sign_out'))
|
|
|
|
|
|
def test_sign_out_user(app_,
|
|
mock_get_service,
|
|
api_user_active,
|
|
mock_get_user,
|
|
mock_get_user_by_email,
|
|
mock_get_service_templates,
|
|
mock_login,
|
|
mock_get_jobs):
|
|
with app_.test_request_context():
|
|
email = 'valid@example.gov.uk'
|
|
password = 'val1dPassw0rd!'
|
|
with app_.test_client() as client:
|
|
with client.session_transaction() as session:
|
|
print('session: {}'.format(session))
|
|
client.login(api_user_active)
|
|
# Check we are logged in
|
|
response = client.get(
|
|
url_for('main.service_dashboard', service_id="123"))
|
|
assert response.status_code == 200
|
|
response = client.get(url_for('main.sign_out'))
|
|
assert response.status_code == 302
|
|
assert response.location == url_for(
|
|
'main.index', _external=True)
|
|
assert session.get('ItsdangerousSession') is None
|