From 4dd83fd6aabbec51f430790d546b444767b27c47 Mon Sep 17 00:00:00 2001 From: Tatjana Dehler Date: Tue, 8 Oct 2019 15:07:18 +0200 Subject: [PATCH] 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 --- qa/tasks/mgr/dashboard/test_user.py | 10 +++++----- src/pybind/mgr/dashboard/controllers/user.py | 16 ++++++++-------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/qa/tasks/mgr/dashboard/test_user.py b/qa/tasks/mgr/dashboard/test_user.py index 3a8e7ee7ce5..a8f04bae35d 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 a8d63a21adc..a75c99e033f 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') -- 2.39.5