##// 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 283 Session().delete(auth_token)
284 284 Session().commit()
285 285
286 def test_my_account_remove_auth_token(self):
287 # TODO: without this cleanup it fails when run with the whole
288 # test suite, so there must be some interference with other tests.
289 UserApiKeys.query().delete()
286 def test_my_account_remove_auth_token(self, user_util):
287 user = user_util.create_user(password=self.test_user_1_password)
288 user_id = user.user_id
289 self.log_user(user.username, self.test_user_1_password)
290 290
291 usr = self.log_user('test_regular2', 'test12')
292 User.get(usr['user_id'])
291 user = User.get(user_id)
292 keys = user.extra_auth_tokens
293 assert 1 == len(keys)
294
293 295 response = self.app.post(url('my_account_auth_tokens'),
294 296 {'description': 'desc', 'lifetime': -1,
295 297 'csrf_token': self.csrf_token})
296 298 assert_session_flash(response, 'Auth token successfully created')
297 response = response.follow()
299 response.follow()
298 300
299 # now delete our key
300 keys = UserApiKeys.query().all()
301 assert 1 == len(keys)
301 user = User.get(user_id)
302 keys = user.extra_auth_tokens
303 assert 2 == len(keys)
302 304
303 305 response = self.app.post(
304 306 url('my_account_auth_tokens'),
305 307 {'_method': 'delete', 'del_auth_token': keys[0].api_key,
306 308 'csrf_token': self.csrf_token})
307 309 assert_session_flash(response, 'Auth token successfully deleted')
308 keys = UserApiKeys.query().all()
309 assert 0 == len(keys)
310
311 user = User.get(user_id)
312 keys = user.extra_auth_tokens
313 assert 1 == len(keys)
310 314
311 315 def test_my_account_reset_main_auth_token(self):
312 316 usr = self.log_user('test_regular2', 'test12')
General Comments 0
You need to be logged in to leave comments. Login now