]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: reset login to admin user
authorTatjana Dehler <tdehler@suse.com>
Wed, 9 Oct 2019 13:39:31 +0000 (15:39 +0200)
committerTatjana Dehler <tdehler@suse.com>
Fri, 11 Oct 2019 08:46:26 +0000 (10:46 +0200)
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 <tdehler@suse.com>
qa/tasks/mgr/dashboard/test_user.py

index a8f04bae35d2344bce643a201cc2173005befa04..860bc8bf45b48a8c96de18bba485ac68b6ab1605 100644 (file)
@@ -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'])