mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-05 10:53:28 -05:00
Use session.clear() sign-out.
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.
This commit is contained in:
@@ -8,7 +8,6 @@ from app.main import main
|
||||
@main.route('/sign-out', methods=(['GET']))
|
||||
@login_required
|
||||
def sign_out():
|
||||
if session.get('service_name', None):
|
||||
session.pop('service_name')
|
||||
session.clear()
|
||||
logout_user()
|
||||
return redirect(url_for('main.index'))
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
from datetime import datetime
|
||||
from flask import url_for
|
||||
from app.main.dao import users_dao
|
||||
|
||||
|
||||
def test_render_sign_out_redirects_to_sign_in(app_):
|
||||
@@ -24,6 +22,8 @@ def test_sign_out_user(app_,
|
||||
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(
|
||||
@@ -33,3 +33,4 @@ def test_sign_out_user(app_,
|
||||
assert response.status_code == 302
|
||||
assert response.location == url_for(
|
||||
'main.index', _external=True)
|
||||
assert session.get('ItsdangerousSession') is None
|
||||
|
||||
Reference in New Issue
Block a user