Exemple #1
0
 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'
Exemple #2
0
 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
Exemple #3
0
 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