From b9094f1e17d648feec63c0e54538b9a015553edf Mon Sep 17 00:00:00 2001 From: Tatjana Dehler Date: Thu, 2 Jan 2020 13:22:48 +0100 Subject: [PATCH] mgr/dashboard: fix failing user tests Choose another future_date_1 date (9 days instead of 10) to make sure the expiration date will be between future_date_1 and future_date_2. Otherwise the expiration date might be equal to future_date_1. Also wait for 10 seconds before the password refresh in test_pwd_expiration_date_update to prevent date equality. Fixes: https://tracker.ceph.com/issues/43431 Signed-off-by: Tatjana Dehler --- qa/tasks/mgr/dashboard/test_user.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/qa/tasks/mgr/dashboard/test_user.py b/qa/tasks/mgr/dashboard/test_user.py index 115e554ec11db..de3fcfbe4f6fe 100644 --- a/qa/tasks/mgr/dashboard/test_user.py +++ b/qa/tasks/mgr/dashboard/test_user.py @@ -341,7 +341,7 @@ class UserTest(DashboardTestCase): self.assertError(code='pwd_past_expiration_date', component='user') def test_create_with_default_expiration_date(self): - future_date_1 = datetime.utcnow() + timedelta(days=10) + future_date_1 = datetime.utcnow() + timedelta(days=9) future_date_1 = int(time.mktime(future_date_1.timetuple())) future_date_2 = datetime.utcnow() + timedelta(days=11) future_date_2 = int(time.mktime(future_date_2.timetuple())) @@ -375,6 +375,7 @@ class UserTest(DashboardTestCase): user_1 = self._get('/api/user/user1') self.assertStatus(200) + time.sleep(10) self.login('user1', 'mypassword10#') self._post('/api/user/user1/change_password', { 'old_password': 'mypassword10#', @@ -383,9 +384,9 @@ class UserTest(DashboardTestCase): self.assertStatus(200) self._reset_login_to_admin() - user_2 = self._get('/api/user/user1') + user_1_pwd_changed = self._get('/api/user/user1') self.assertStatus(200) - self.assertLess(user_1['pwdExpirationDate'], user_2['pwdExpirationDate']) + self.assertLess(user_1['pwdExpirationDate'], user_1_pwd_changed['pwdExpirationDate']) self._delete('/api/user/user1') self._ceph_cmd(['dashboard', 'set-user-pwd-expiration-span', '0']) -- 2.39.5