From 4f635087c3bfafdaf358ddcd4951e97a552ffc69 Mon Sep 17 00:00:00 2001 From: Ronald Portier Date: Mon, 4 Feb 2019 12:40:56 +0100 Subject: [PATCH] [FIX] Correct test for password not in login. --- password_security/models/res_users.py | 5 +++-- password_security/tests/test_res_users.py | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/password_security/models/res_users.py b/password_security/models/res_users.py index e030e883f25..344a89e7922 100644 --- a/password_security/models/res_users.py +++ b/password_security/models/res_users.py @@ -91,8 +91,9 @@ def _check_password_rules(self, password): password_regex.append('.{%d,}$' % company_id.password_length) if not re.search(''.join(password_regex), password): raise PassError(self.password_match_message()) - if company_id.password_no_login and self.login in password: - raise PassError(self.password_match_message()) + if company_id.password_no_login: + if self.login.lower() in password.lower(): + raise PassError(self.password_match_message()) return True @api.multi diff --git a/password_security/tests/test_res_users.py b/password_security/tests/test_res_users.py index 64152f8576d..ae4c02e82c7 100644 --- a/password_security/tests/test_res_users.py +++ b/password_security/tests/test_res_users.py @@ -168,6 +168,6 @@ def test_underscore_is_special_character(self): def test_password_contains_login(self): self.assertTrue(self.main_comp.password_no_login) rec_id = self._new_record() - rec_id._check_password('asdQWE123$%^12') + rec_id.login = 'suzanne' with self.assertRaises(PassError): - rec_id._check_password(rec_id.login + 'invalid') + rec_id._check_password('Suzanne1966!')