def test_signal_when_user_logout_manual(monkeypatch, django_user_model): session = SessionStore() session['fake_session_key'] = 'fake-session_value' session.save() assert SessionStore(session_key=session.session_key) is not None factory = RequestFactory() request = factory.get('/logout') request.session = session # Create a fake session ticket and make sure it exists in the db session_ticket = SessionTicket.objects.create( session_key=session.session_key, ticket='fake-ticket' ) user = django_user_model.objects.create_user('*****@*****.**', '') assert user is not None request.user = user callback_values = {} @receiver(cas_user_logout) def callback(sender, session, **kwargs): callback_values.update(kwargs) callback_values['session'] = dict(session) response = logout(request) assert request.user.is_anonymous() is True assert 'user' in callback_values assert callback_values['user'] == user assert 'session' in callback_values assert callback_values['session'].get('fake_session_key') == 'fake-session_value' assert 'ticket' in callback_values assert callback_values['ticket'] == 'fake-ticket'
def test_signal_when_user_logout_manual(monkeypatch, django_user_model): session = SessionStore() session['fake_session_key'] = 'fake-session_value' session.save() assert SessionStore(session_key=session.session_key) is not None factory = RequestFactory() request = factory.get('/logout') request.session = session # Create a fake session ticket and make sure it exists in the db session_ticket = SessionTicket.objects.create( session_key=session.session_key, ticket='fake-ticket') user = django_user_model.objects.create_user('*****@*****.**', '') assert user is not None request.user = user callback_values = {} @receiver(cas_user_logout) def callback(sender, session, **kwargs): callback_values.update(kwargs) callback_values['session'] = dict(session) response = logout(request) assert request.user.is_anonymous() is True assert 'user' in callback_values assert callback_values['user'] == user assert 'session' in callback_values assert callback_values['session'].get( 'fake_session_key') == 'fake-session_value' assert 'ticket' in callback_values assert callback_values['ticket'] == 'fake-ticket'
def test_logout_completely(django_user_model, settings): """ Test the case where the user logs out. """ settings.CAS_LOGOUT_COMPLETELY = True factory = RequestFactory() request = factory.get('/logout/') # Create a session object from the middleware process_request_for_middleware(request, SessionMiddleware) user = django_user_model.objects.create_user('*****@*****.**', '') assert user is not None request.user = user response = logout(request) assert response.status_code == 302 assert request.user.is_anonymous() is True
def logout(request, **kwargs): return casviews.logout(request, **kwargs)
def test_logout_delete_not_allowed(): factory = RequestFactory() request = factory.delete('/logout/') response = logout(request) assert response.status_code == 405
def page_logout(request): if settings.CAS_AUTH: return cas_views.logout(request) else: logout(request) return page_login(request)
def cas_logout(request): return cas_views.logout(request)
def page_logout(request): return cas_views.logout(request)