From: Tatjana Dehler Date: Tue, 8 Oct 2019 13:07:18 +0000 (+0200) Subject: mgr/dashboard: check for correct DashboardException error codes X-Git-Tag: v15.1.0~1275^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4dd83fd6aabbec51f430790d546b444767b27c47;p=ceph.git mgr/dashboard: check for correct DashboardException error codes We need to check for the correct error codes. Otherwise the integration tests are going to fail. Fixes: https://tracker.ceph.com/issues/42222 Signed-off-by: Tatjana Dehler --- diff --git a/qa/tasks/mgr/dashboard/test_user.py b/qa/tasks/mgr/dashboard/test_user.py index 3a8e7ee7ce52..a8f04bae35d2 100644 --- a/qa/tasks/mgr/dashboard/test_user.py +++ b/qa/tasks/mgr/dashboard/test_user.py @@ -177,7 +177,7 @@ class UserTest(DashboardTestCase): 'new_password': 'mypassword10#' }) self.assertStatus(400) - self.assertError(code='the_same_as_old_password', component='user') + self.assertError(code='pwd-must-not-be-last-one', component='user') self.delete_user('test1') def test_change_password_contains_username(self): @@ -188,7 +188,7 @@ class UserTest(DashboardTestCase): 'new_password': 'mypasstest1@#' }) self.assertStatus(400) - self.assertError(code='contains_username', component='user') + self.assertError(code='pwd-must-not-contain-username', component='user') self.delete_user('test1') def test_change_password_contains_forbidden_words(self): @@ -199,7 +199,7 @@ class UserTest(DashboardTestCase): 'new_password': 'mypassOSD01' }) self.assertStatus(400) - self.assertError(code='contains_forbidden_words', component='user') + self.assertError(code='pwd-must-not-contain-forbidden-keywords', component='user') self.delete_user('test1') def test_change_password_contains_sequential_characters(self): @@ -210,7 +210,7 @@ class UserTest(DashboardTestCase): 'new_password': 'mypass123456!@$' }) self.assertStatus(400) - self.assertError(code='contains_sequential_characters', component='user') + self.assertError(code='pwd-must-not-contain-sequential-chars', component='user') self.delete_user('test1') def test_change_password_contains_repetetive_characters(self): @@ -221,7 +221,7 @@ class UserTest(DashboardTestCase): 'new_password': 'aaaaA1@!#' }) self.assertStatus(400) - self.assertError(code='contains_repetetive_characters', component='user') + self.assertError(code='pwd-must-not-contain-repetitive-chars', component='user') self.delete_user('test1') def test_change_password(self): diff --git a/src/pybind/mgr/dashboard/controllers/user.py b/src/pybind/mgr/dashboard/controllers/user.py index a8d63a21adca..a75c99e033f8 100644 --- a/src/pybind/mgr/dashboard/controllers/user.py +++ b/src/pybind/mgr/dashboard/controllers/user.py @@ -17,29 +17,29 @@ def check_password_complexity(password, username, old_password=None): if password_complexity.check_if_as_the_old_password(): raise DashboardException(msg='Password cannot be the\ same as the previous one.', - code='not-strong-enough-password', + code='pwd-must-not-be-last-one', component='user') if password_complexity.check_if_contains_username(): raise DashboardException(msg='Password cannot contain username.', - code='not-strong-enough-password', + code='pwd-must-not-contain-username', component='user') if password_complexity.check_if_contains_forbidden_words(): raise DashboardException(msg='Password cannot contain keywords.', - code='not-strong-enough-password', + code='pwd-must-not-contain-forbidden-keywords', component='user') if password_complexity.check_if_repetetive_characters(): - raise DashboardException(msg='Password cannot contain repetitive\ + raise DashboardException(msg='Password cannot contain repetitive \ characters.', - code='not-strong-enough-password', + code='pwd-must-not-contain-repetitive-chars', component='user') if password_complexity.check_if_sequential_characters(): - raise DashboardException(msg='Password cannot contain sequential\ + raise DashboardException(msg='Password cannot contain sequential \ characters.', - code='not-strong-enough-password', + code='pwd-must-not-contain-sequential-chars', component='user') if password_complexity.check_password_characters() < 10: raise DashboardException(msg='Password is too weak.', - code='not-strong-enough-password', + code='pwd-too-weak', component='user')