Browse Source

Merge pull request #1254 from Tecnativa/10.0-password_security-fix_integration_tests

[FIX] password_security: Create user as admin in tests
pull/1265/head
Pedro M. Baeza 7 years ago
committed by GitHub
parent
commit
76e08369ef
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      password_security/__manifest__.py
  2. 45
      password_security/tests/test_res_users.py

2
password_security/__manifest__.py

@ -5,7 +5,7 @@
'name': 'Password Security',
"summary": "Allow admin to set password security requirements.",
'version': '10.0.1.1.3',
'version': '10.0.1.1.4',
'author': "LasLabs, Odoo Community Association (OCA)",
'category': 'Base',
'depends': [

45
password_security/tests/test_res_users.py

@ -4,48 +4,49 @@
import time
from odoo.tests.common import TransactionCase
from odoo.tests.common import at_install, post_install, SavepointCase
from ..exceptions import PassError
class TestResUsers(TransactionCase):
@at_install(False)
@post_install(True)
class TestResUsers(SavepointCase):
def setUp(self):
super(TestResUsers, self).setUp()
self.main_comp = self.env.ref('base.main_company')
def setUp(cls):
super(TestResUsers, cls).setUp()
cls.main_comp = cls.env.ref('base.main_company')
# Modify users as privileged, but non-root user
privileged_user = self.env['res.users'].create({
cls.privileged_user = cls.env['res.users'].create({
'name': 'Privileged User',
'login': 'privileged_user@example.com',
'company_id': self.main_comp.id,
'company_id': cls.main_comp.id,
'groups_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),
(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),
],
})
privileged_user.email = privileged_user.login
self.env = self.env(user=privileged_user)
self.login = 'foslabs@example.com'
self.partner_vals = {
cls.privileged_user.email = cls.privileged_user.login
cls.login = 'foslabs@example.com'
cls.partner_vals = {
'name': 'Partner',
'is_company': False,
'email': self.login,
'email': cls.login,
}
self.password = 'asdQWE123$%^'
self.vals = {
cls.password = 'asdQWE123$%^'
cls.vals = {
'name': 'User',
'login': self.login,
'password': self.password,
'company_id': self.main_comp.id
'login': cls.login,
'password': cls.password,
'company_id': cls.main_comp.id
}
self.model_obj = self.env['res.users']
cls.model_obj = cls.env['res.users']
def _new_record(self):
partner_id = self.env['res.partner'].create(self.partner_vals)
self.vals['partner_id'] = partner_id.id
return self.model_obj.create(self.vals)
return self.model_obj.create(self.vals).sudo(self.privileged_user)
def test_password_write_date_is_saved_on_create(self):
rec_id = self._new_record()

Loading…
Cancel
Save