def test_sudo_logout(self): r = RequestFactory() fake_request = r.post('/anyurl', data={'submit_desudo': True}) session = FakeSession(**{ACCOUNT_ID_VAR: PLAIN_ACCOUNT.id}) fake_request.session = session fake_request.account = PLAIN_ACCOUNT with patch('nav.web.auth.desudo'): with patch('nav.web.auth.reverse', return_value='parrot'): result = logout(fake_request) assert result == 'parrot'
def test_non_sudo_logout(self): r = RequestFactory() fake_request = r.get('/anyurl') session = FakeSession(**{ACCOUNT_ID_VAR: PLAIN_ACCOUNT.id}) fake_request.session = session fake_request.account = PLAIN_ACCOUNT with patch('nav.web.auth.LogEntry.add_log_entry'): result = logout(fake_request) assert result == '/' assert not hasattr(fake_request, 'account') assert ACCOUNT_ID_VAR not in fake_request.session
def test_logout_before_login(self): r = RequestFactory() fake_request = r.get('/anyurl') with patch('nav.web.auth.LogEntry.add_log_entry'): result = logout(fake_request) assert result == None