From a14163a589b7fdd6db377b4f58f2ec75d1130639 Mon Sep 17 00:00:00 2001 From: Tatjana Dehler Date: Wed, 9 Oct 2019 15:39:31 +0200 Subject: [PATCH] mgr/dashboard: reset login to admin user After logging in with a separate testuser, especially a read-only user, we need to reset the login to the admin user. This is important in order to be able to continue with further tests. If not doing so further tests might fail with the following error response: {"status": "401 Unauthorized", "detail": "You are not authorized to access that resource", ...} Fixes: https://tracker.ceph.com/issues/42226, https://tracker.ceph.com/issues/42227 Signed-off-by: Tatjana Dehler --- qa/tasks/mgr/dashboard/test_user.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/qa/tasks/mgr/dashboard/test_user.py b/qa/tasks/mgr/dashboard/test_user.py index a8f04bae35d23..860bc8bf45b48 100644 --- a/qa/tasks/mgr/dashboard/test_user.py +++ b/qa/tasks/mgr/dashboard/test_user.py @@ -23,6 +23,12 @@ class UserTest(DashboardTestCase): data['enabled'] = enabled cls._post("/api/user", data) + @classmethod + def _reset_login_to_admin(cls, username): + cls.logout() + cls.delete_user(username) + cls.login('admin', 'admin') + def test_crud_user(self): self._create_user(username='user1', password='mypassword10#', @@ -64,7 +70,7 @@ class UserTest(DashboardTestCase): def test_crd_disabled_user(self): self._create_user(username='klara', - password='123456789', + password='mypassword10#', name='Klara Musterfrau', email='klara@musterfrau.com', roles=['administrator'], @@ -178,7 +184,7 @@ class UserTest(DashboardTestCase): }) self.assertStatus(400) self.assertError(code='pwd-must-not-be-last-one', component='user') - self.delete_user('test1') + self._reset_login_to_admin('test1') def test_change_password_contains_username(self): self.create_user('test1', 'mypassword10#', ['read-only']) @@ -189,7 +195,7 @@ class UserTest(DashboardTestCase): }) self.assertStatus(400) self.assertError(code='pwd-must-not-contain-username', component='user') - self.delete_user('test1') + self._reset_login_to_admin('test1') def test_change_password_contains_forbidden_words(self): self.create_user('test1', 'mypassword10#', ['read-only']) @@ -200,7 +206,7 @@ class UserTest(DashboardTestCase): }) self.assertStatus(400) self.assertError(code='pwd-must-not-contain-forbidden-keywords', component='user') - self.delete_user('test1') + self._reset_login_to_admin('test1') def test_change_password_contains_sequential_characters(self): self.create_user('test1', 'mypassword10#', ['read-only']) @@ -211,7 +217,7 @@ class UserTest(DashboardTestCase): }) self.assertStatus(400) self.assertError(code='pwd-must-not-contain-sequential-chars', component='user') - self.delete_user('test1') + self._reset_login_to_admin('test1') def test_change_password_contains_repetetive_characters(self): self.create_user('test1', 'mypassword10#', ['read-only']) @@ -222,7 +228,7 @@ class UserTest(DashboardTestCase): }) self.assertStatus(400) self.assertError(code='pwd-must-not-contain-repetitive-chars', component='user') - self.delete_user('test1') + self._reset_login_to_admin('test1') def test_change_password(self): self.create_user('test1', 'mypassword10#', ['read-only']) -- 2.39.5