Skip to content

Commit

Permalink
fixup! [IMP] Allow the administator to forbid passwords that contain …
Browse files Browse the repository at this point in the history
…the login.
  • Loading branch information
George Daramouskas committed Mar 22, 2019
1 parent bb3f697 commit 41bac8c
Showing 1 changed file with 19 additions and 23 deletions.
42 changes: 19 additions & 23 deletions password_security/tests/test_res_users.py
Expand Up @@ -13,36 +13,35 @@
@post_install(True)
class TestResUsers(SavepointCase):

def setUp(cls):
super(TestResUsers, cls).setUp()
cls.main_comp = cls.env.ref('base.main_company')
cls.main_comp.password_no_login = True
def setUp(self):
super(TestResUsers, self).setUp()
self.main_comp = self.env.ref('base.main_company')
# Modify users as privileged, but non-root user
cls.privileged_user = cls.env['res.users'].create({
self.privileged_user = self.env['res.users'].create({
'name': 'Privileged User',
'login': 'privileged_user@example.com',
'company_id': cls.main_comp.id,
'company_id': self.main_comp.id,
'groups_id': [
(4, cls.env.ref('base.group_erp_manager').id),
(4, cls.env.ref('base.group_partner_manager').id),
(4, cls.env.ref('base.group_user').id),
(4, self.env.ref('base.group_erp_manager').id),
(4, self.env.ref('base.group_partner_manager').id),
(4, self.env.ref('base.group_user').id),
],
})
cls.privileged_user.email = cls.privileged_user.login
cls.login = 'foslabs@example.com'
cls.partner_vals = {
self.privileged_user.email = self.privileged_user.login
self.login = 'foslabs@example.com'
self.partner_vals = {
'name': 'Partner',
'is_company': False,
'email': cls.login,
'email': self.login,
}
cls.password = 'asdQWE123$%^'
cls.vals = {
self.password = 'asdQWE123$%^'
self.vals = {
'name': 'User',
'login': cls.login,
'password': cls.password,
'company_id': cls.main_comp.id
'login': self.login,
'password': self.password,
'company_id': self.main_comp.id
}
cls.model_obj = cls.env['res.users']
self.model_obj = self.env['res.users']

def _new_record(self):
partner_id = self.env['res.partner'].create(self.partner_vals)
Expand Down Expand Up @@ -168,12 +167,9 @@ def test_underscore_is_special_character(self):
rec_id._check_password('asdQWE12345_3')

def test_password_contains_login(self):
self.main_comp.password_no_login = True
self.assertTrue(self.main_comp.password_no_login)
rec_id = self._new_record()
rec_id.login = 'suzanne'
with self.assertRaises(PassError):
rec_id._check_password('Suzanne1966!')

def tearDown(cls):
cls.main_comp.password_no_login = False
super(TestResUsers, cls).tearDown()

0 comments on commit 41bac8c

Please sign in to comment.