##// END OF EJS Templates
tests: fixed tests case when we tested token deletion and purged all tokens in the system.
marcink -
r1419:6c1aa54d default
parent child Browse files
Show More
@@ -283,30 +283,34 b' class TestMyAccountController(TestContro'
283 Session().delete(auth_token)
283 Session().delete(auth_token)
284 Session().commit()
284 Session().commit()
285
285
286 def test_my_account_remove_auth_token(self):
286 def test_my_account_remove_auth_token(self, user_util):
287 # TODO: without this cleanup it fails when run with the whole
287 user = user_util.create_user(password=self.test_user_1_password)
288 # test suite, so there must be some interference with other tests.
288 user_id = user.user_id
289 UserApiKeys.query().delete()
289 self.log_user(user.username, self.test_user_1_password)
290
290
291 usr = self.log_user('test_regular2', 'test12')
291 user = User.get(user_id)
292 User.get(usr['user_id'])
292 keys = user.extra_auth_tokens
293 assert 1 == len(keys)
294
293 response = self.app.post(url('my_account_auth_tokens'),
295 response = self.app.post(url('my_account_auth_tokens'),
294 {'description': 'desc', 'lifetime': -1,
296 {'description': 'desc', 'lifetime': -1,
295 'csrf_token': self.csrf_token})
297 'csrf_token': self.csrf_token})
296 assert_session_flash(response, 'Auth token successfully created')
298 assert_session_flash(response, 'Auth token successfully created')
297 response = response.follow()
299 response.follow()
298
300
299 # now delete our key
301 user = User.get(user_id)
300 keys = UserApiKeys.query().all()
302 keys = user.extra_auth_tokens
301 assert 1 == len(keys)
303 assert 2 == len(keys)
302
304
303 response = self.app.post(
305 response = self.app.post(
304 url('my_account_auth_tokens'),
306 url('my_account_auth_tokens'),
305 {'_method': 'delete', 'del_auth_token': keys[0].api_key,
307 {'_method': 'delete', 'del_auth_token': keys[0].api_key,
306 'csrf_token': self.csrf_token})
308 'csrf_token': self.csrf_token})
307 assert_session_flash(response, 'Auth token successfully deleted')
309 assert_session_flash(response, 'Auth token successfully deleted')
308 keys = UserApiKeys.query().all()
310
309 assert 0 == len(keys)
311 user = User.get(user_id)
312 keys = user.extra_auth_tokens
313 assert 1 == len(keys)
310
314
311 def test_my_account_reset_main_auth_token(self):
315 def test_my_account_reset_main_auth_token(self):
312 usr = self.log_user('test_regular2', 'test12')
316 usr = self.log_user('test_regular2', 'test12')
General Comments 0
You need to be logged in to leave comments. Login now