You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

167 lines
5.7 KiB

[FIX] password_security: Create user as admin in tests If you test this addon after installing `partner_event`, you get this error in all tests: ERROR: test_validate_pass_reset_error (odoo.addons.password_security.tests.test_res_users.TestResUsers) ` It should throw PassError on reset inside min threshold Traceback (most recent call last): ` File "/opt/odoo/auto/addons/password_security/tests/test_res_users.py", line 143, in test_validate_pass_reset_error ` rec_id = self._new_record() ` File "/opt/odoo/auto/addons/password_security/tests/test_res_users.py", line 46, in _new_record ` partner_id = self.env['res.partner'].create(self.partner_vals) ` File "/opt/odoo/auto/addons/mail_tracking_mailgun/models/res_partner.py", line 154, in create ` return super(ResPartner, self).create(vals) ` File "/opt/odoo/auto/addons/partner_firstname/models/res_partner.py", line 54, in create ` return super(ResPartner, self.with_context(context)).create(vals) ` File "/opt/odoo/custom/src/odoo/odoo/addons/base/res/res_partner.py", line 532, in create ` partner = super(Partner, self).create(vals) ` File "/opt/odoo/auto/addons/mail/models/mail_thread.py", line 228, in create ` thread = super(MailThread, self).create(values) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 3847, in create ` record = self.browse(self._create(old_vals)) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 4006, in _create ` self.recompute() ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5336, in recompute ` vals = rec._convert_to_write({n: rec[n] for n in ns}) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5336, in <dictcomp> ` vals = rec._convert_to_write({n: rec[n] for n in ns}) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5232, in __getitem__ ` return self._fields[key].__get__(self, type(self)) ` File "/opt/odoo/custom/src/odoo/odoo/fields.py", line 918, in __get__ ` value = record._cache[self] ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5584, in __getitem__ ` return value.get() if isinstance(value, SpecialValue) else value ` File "/opt/odoo/custom/src/odoo/odoo/fields.py", line 48, in get ` raise self.exception ` AccessError: (u'Sorry, you are not allowed to access this document. Only users with the following access level are currently allowed to do that:\n- Events/User\n\n(Document model: event.registration)', None) Since creating users or partners in tests has a very high probability to collide with other addons, this test is being moved to post mode. Also, to avoid the above permissions issue, the partner is actually created through the admin user, which actually has permissions to read everything. Then, it is `.sudo()`ed later, to perform the module tests correctly. The tests do not get affected because what is being tested was not [intended to be] the partner creation itself, but the password policy enforcement.
7 years ago
[FIX] password_security: Create user as admin in tests If you test this addon after installing `partner_event`, you get this error in all tests: ERROR: test_validate_pass_reset_error (odoo.addons.password_security.tests.test_res_users.TestResUsers) ` It should throw PassError on reset inside min threshold Traceback (most recent call last): ` File "/opt/odoo/auto/addons/password_security/tests/test_res_users.py", line 143, in test_validate_pass_reset_error ` rec_id = self._new_record() ` File "/opt/odoo/auto/addons/password_security/tests/test_res_users.py", line 46, in _new_record ` partner_id = self.env['res.partner'].create(self.partner_vals) ` File "/opt/odoo/auto/addons/mail_tracking_mailgun/models/res_partner.py", line 154, in create ` return super(ResPartner, self).create(vals) ` File "/opt/odoo/auto/addons/partner_firstname/models/res_partner.py", line 54, in create ` return super(ResPartner, self.with_context(context)).create(vals) ` File "/opt/odoo/custom/src/odoo/odoo/addons/base/res/res_partner.py", line 532, in create ` partner = super(Partner, self).create(vals) ` File "/opt/odoo/auto/addons/mail/models/mail_thread.py", line 228, in create ` thread = super(MailThread, self).create(values) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 3847, in create ` record = self.browse(self._create(old_vals)) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 4006, in _create ` self.recompute() ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5336, in recompute ` vals = rec._convert_to_write({n: rec[n] for n in ns}) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5336, in <dictcomp> ` vals = rec._convert_to_write({n: rec[n] for n in ns}) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5232, in __getitem__ ` return self._fields[key].__get__(self, type(self)) ` File "/opt/odoo/custom/src/odoo/odoo/fields.py", line 918, in __get__ ` value = record._cache[self] ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5584, in __getitem__ ` return value.get() if isinstance(value, SpecialValue) else value ` File "/opt/odoo/custom/src/odoo/odoo/fields.py", line 48, in get ` raise self.exception ` AccessError: (u'Sorry, you are not allowed to access this document. Only users with the following access level are currently allowed to do that:\n- Events/User\n\n(Document model: event.registration)', None) Since creating users or partners in tests has a very high probability to collide with other addons, this test is being moved to post mode. Also, to avoid the above permissions issue, the partner is actually created through the admin user, which actually has permissions to read everything. Then, it is `.sudo()`ed later, to perform the module tests correctly. The tests do not get affected because what is being tested was not [intended to be] the partner creation itself, but the password policy enforcement.
7 years ago
[FIX] password_security: Create user as admin in tests If you test this addon after installing `partner_event`, you get this error in all tests: ERROR: test_validate_pass_reset_error (odoo.addons.password_security.tests.test_res_users.TestResUsers) ` It should throw PassError on reset inside min threshold Traceback (most recent call last): ` File "/opt/odoo/auto/addons/password_security/tests/test_res_users.py", line 143, in test_validate_pass_reset_error ` rec_id = self._new_record() ` File "/opt/odoo/auto/addons/password_security/tests/test_res_users.py", line 46, in _new_record ` partner_id = self.env['res.partner'].create(self.partner_vals) ` File "/opt/odoo/auto/addons/mail_tracking_mailgun/models/res_partner.py", line 154, in create ` return super(ResPartner, self).create(vals) ` File "/opt/odoo/auto/addons/partner_firstname/models/res_partner.py", line 54, in create ` return super(ResPartner, self.with_context(context)).create(vals) ` File "/opt/odoo/custom/src/odoo/odoo/addons/base/res/res_partner.py", line 532, in create ` partner = super(Partner, self).create(vals) ` File "/opt/odoo/auto/addons/mail/models/mail_thread.py", line 228, in create ` thread = super(MailThread, self).create(values) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 3847, in create ` record = self.browse(self._create(old_vals)) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 4006, in _create ` self.recompute() ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5336, in recompute ` vals = rec._convert_to_write({n: rec[n] for n in ns}) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5336, in <dictcomp> ` vals = rec._convert_to_write({n: rec[n] for n in ns}) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5232, in __getitem__ ` return self._fields[key].__get__(self, type(self)) ` File "/opt/odoo/custom/src/odoo/odoo/fields.py", line 918, in __get__ ` value = record._cache[self] ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5584, in __getitem__ ` return value.get() if isinstance(value, SpecialValue) else value ` File "/opt/odoo/custom/src/odoo/odoo/fields.py", line 48, in get ` raise self.exception ` AccessError: (u'Sorry, you are not allowed to access this document. Only users with the following access level are currently allowed to do that:\n- Events/User\n\n(Document model: event.registration)', None) Since creating users or partners in tests has a very high probability to collide with other addons, this test is being moved to post mode. Also, to avoid the above permissions issue, the partner is actually created through the admin user, which actually has permissions to read everything. Then, it is `.sudo()`ed later, to perform the module tests correctly. The tests do not get affected because what is being tested was not [intended to be] the partner creation itself, but the password policy enforcement.
7 years ago
[FIX] password_security: Create user as admin in tests If you test this addon after installing `partner_event`, you get this error in all tests: ERROR: test_validate_pass_reset_error (odoo.addons.password_security.tests.test_res_users.TestResUsers) ` It should throw PassError on reset inside min threshold Traceback (most recent call last): ` File "/opt/odoo/auto/addons/password_security/tests/test_res_users.py", line 143, in test_validate_pass_reset_error ` rec_id = self._new_record() ` File "/opt/odoo/auto/addons/password_security/tests/test_res_users.py", line 46, in _new_record ` partner_id = self.env['res.partner'].create(self.partner_vals) ` File "/opt/odoo/auto/addons/mail_tracking_mailgun/models/res_partner.py", line 154, in create ` return super(ResPartner, self).create(vals) ` File "/opt/odoo/auto/addons/partner_firstname/models/res_partner.py", line 54, in create ` return super(ResPartner, self.with_context(context)).create(vals) ` File "/opt/odoo/custom/src/odoo/odoo/addons/base/res/res_partner.py", line 532, in create ` partner = super(Partner, self).create(vals) ` File "/opt/odoo/auto/addons/mail/models/mail_thread.py", line 228, in create ` thread = super(MailThread, self).create(values) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 3847, in create ` record = self.browse(self._create(old_vals)) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 4006, in _create ` self.recompute() ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5336, in recompute ` vals = rec._convert_to_write({n: rec[n] for n in ns}) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5336, in <dictcomp> ` vals = rec._convert_to_write({n: rec[n] for n in ns}) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5232, in __getitem__ ` return self._fields[key].__get__(self, type(self)) ` File "/opt/odoo/custom/src/odoo/odoo/fields.py", line 918, in __get__ ` value = record._cache[self] ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5584, in __getitem__ ` return value.get() if isinstance(value, SpecialValue) else value ` File "/opt/odoo/custom/src/odoo/odoo/fields.py", line 48, in get ` raise self.exception ` AccessError: (u'Sorry, you are not allowed to access this document. Only users with the following access level are currently allowed to do that:\n- Events/User\n\n(Document model: event.registration)', None) Since creating users or partners in tests has a very high probability to collide with other addons, this test is being moved to post mode. Also, to avoid the above permissions issue, the partner is actually created through the admin user, which actually has permissions to read everything. Then, it is `.sudo()`ed later, to perform the module tests correctly. The tests do not get affected because what is being tested was not [intended to be] the partner creation itself, but the password policy enforcement.
7 years ago
[FIX] password_security: Create user as admin in tests If you test this addon after installing `partner_event`, you get this error in all tests: ERROR: test_validate_pass_reset_error (odoo.addons.password_security.tests.test_res_users.TestResUsers) ` It should throw PassError on reset inside min threshold Traceback (most recent call last): ` File "/opt/odoo/auto/addons/password_security/tests/test_res_users.py", line 143, in test_validate_pass_reset_error ` rec_id = self._new_record() ` File "/opt/odoo/auto/addons/password_security/tests/test_res_users.py", line 46, in _new_record ` partner_id = self.env['res.partner'].create(self.partner_vals) ` File "/opt/odoo/auto/addons/mail_tracking_mailgun/models/res_partner.py", line 154, in create ` return super(ResPartner, self).create(vals) ` File "/opt/odoo/auto/addons/partner_firstname/models/res_partner.py", line 54, in create ` return super(ResPartner, self.with_context(context)).create(vals) ` File "/opt/odoo/custom/src/odoo/odoo/addons/base/res/res_partner.py", line 532, in create ` partner = super(Partner, self).create(vals) ` File "/opt/odoo/auto/addons/mail/models/mail_thread.py", line 228, in create ` thread = super(MailThread, self).create(values) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 3847, in create ` record = self.browse(self._create(old_vals)) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 4006, in _create ` self.recompute() ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5336, in recompute ` vals = rec._convert_to_write({n: rec[n] for n in ns}) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5336, in <dictcomp> ` vals = rec._convert_to_write({n: rec[n] for n in ns}) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5232, in __getitem__ ` return self._fields[key].__get__(self, type(self)) ` File "/opt/odoo/custom/src/odoo/odoo/fields.py", line 918, in __get__ ` value = record._cache[self] ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5584, in __getitem__ ` return value.get() if isinstance(value, SpecialValue) else value ` File "/opt/odoo/custom/src/odoo/odoo/fields.py", line 48, in get ` raise self.exception ` AccessError: (u'Sorry, you are not allowed to access this document. Only users with the following access level are currently allowed to do that:\n- Events/User\n\n(Document model: event.registration)', None) Since creating users or partners in tests has a very high probability to collide with other addons, this test is being moved to post mode. Also, to avoid the above permissions issue, the partner is actually created through the admin user, which actually has permissions to read everything. Then, it is `.sudo()`ed later, to perform the module tests correctly. The tests do not get affected because what is being tested was not [intended to be] the partner creation itself, but the password policy enforcement.
7 years ago
[FIX] password_security: Create user as admin in tests If you test this addon after installing `partner_event`, you get this error in all tests: ERROR: test_validate_pass_reset_error (odoo.addons.password_security.tests.test_res_users.TestResUsers) ` It should throw PassError on reset inside min threshold Traceback (most recent call last): ` File "/opt/odoo/auto/addons/password_security/tests/test_res_users.py", line 143, in test_validate_pass_reset_error ` rec_id = self._new_record() ` File "/opt/odoo/auto/addons/password_security/tests/test_res_users.py", line 46, in _new_record ` partner_id = self.env['res.partner'].create(self.partner_vals) ` File "/opt/odoo/auto/addons/mail_tracking_mailgun/models/res_partner.py", line 154, in create ` return super(ResPartner, self).create(vals) ` File "/opt/odoo/auto/addons/partner_firstname/models/res_partner.py", line 54, in create ` return super(ResPartner, self.with_context(context)).create(vals) ` File "/opt/odoo/custom/src/odoo/odoo/addons/base/res/res_partner.py", line 532, in create ` partner = super(Partner, self).create(vals) ` File "/opt/odoo/auto/addons/mail/models/mail_thread.py", line 228, in create ` thread = super(MailThread, self).create(values) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 3847, in create ` record = self.browse(self._create(old_vals)) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 4006, in _create ` self.recompute() ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5336, in recompute ` vals = rec._convert_to_write({n: rec[n] for n in ns}) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5336, in <dictcomp> ` vals = rec._convert_to_write({n: rec[n] for n in ns}) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5232, in __getitem__ ` return self._fields[key].__get__(self, type(self)) ` File "/opt/odoo/custom/src/odoo/odoo/fields.py", line 918, in __get__ ` value = record._cache[self] ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5584, in __getitem__ ` return value.get() if isinstance(value, SpecialValue) else value ` File "/opt/odoo/custom/src/odoo/odoo/fields.py", line 48, in get ` raise self.exception ` AccessError: (u'Sorry, you are not allowed to access this document. Only users with the following access level are currently allowed to do that:\n- Events/User\n\n(Document model: event.registration)', None) Since creating users or partners in tests has a very high probability to collide with other addons, this test is being moved to post mode. Also, to avoid the above permissions issue, the partner is actually created through the admin user, which actually has permissions to read everything. Then, it is `.sudo()`ed later, to perform the module tests correctly. The tests do not get affected because what is being tested was not [intended to be] the partner creation itself, but the password policy enforcement.
7 years ago
[FIX] password_security: Create user as admin in tests If you test this addon after installing `partner_event`, you get this error in all tests: ERROR: test_validate_pass_reset_error (odoo.addons.password_security.tests.test_res_users.TestResUsers) ` It should throw PassError on reset inside min threshold Traceback (most recent call last): ` File "/opt/odoo/auto/addons/password_security/tests/test_res_users.py", line 143, in test_validate_pass_reset_error ` rec_id = self._new_record() ` File "/opt/odoo/auto/addons/password_security/tests/test_res_users.py", line 46, in _new_record ` partner_id = self.env['res.partner'].create(self.partner_vals) ` File "/opt/odoo/auto/addons/mail_tracking_mailgun/models/res_partner.py", line 154, in create ` return super(ResPartner, self).create(vals) ` File "/opt/odoo/auto/addons/partner_firstname/models/res_partner.py", line 54, in create ` return super(ResPartner, self.with_context(context)).create(vals) ` File "/opt/odoo/custom/src/odoo/odoo/addons/base/res/res_partner.py", line 532, in create ` partner = super(Partner, self).create(vals) ` File "/opt/odoo/auto/addons/mail/models/mail_thread.py", line 228, in create ` thread = super(MailThread, self).create(values) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 3847, in create ` record = self.browse(self._create(old_vals)) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 4006, in _create ` self.recompute() ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5336, in recompute ` vals = rec._convert_to_write({n: rec[n] for n in ns}) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5336, in <dictcomp> ` vals = rec._convert_to_write({n: rec[n] for n in ns}) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5232, in __getitem__ ` return self._fields[key].__get__(self, type(self)) ` File "/opt/odoo/custom/src/odoo/odoo/fields.py", line 918, in __get__ ` value = record._cache[self] ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5584, in __getitem__ ` return value.get() if isinstance(value, SpecialValue) else value ` File "/opt/odoo/custom/src/odoo/odoo/fields.py", line 48, in get ` raise self.exception ` AccessError: (u'Sorry, you are not allowed to access this document. Only users with the following access level are currently allowed to do that:\n- Events/User\n\n(Document model: event.registration)', None) Since creating users or partners in tests has a very high probability to collide with other addons, this test is being moved to post mode. Also, to avoid the above permissions issue, the partner is actually created through the admin user, which actually has permissions to read everything. Then, it is `.sudo()`ed later, to perform the module tests correctly. The tests do not get affected because what is being tested was not [intended to be] the partner creation itself, but the password policy enforcement.
7 years ago
[FIX] password_security: Create user as admin in tests If you test this addon after installing `partner_event`, you get this error in all tests: ERROR: test_validate_pass_reset_error (odoo.addons.password_security.tests.test_res_users.TestResUsers) ` It should throw PassError on reset inside min threshold Traceback (most recent call last): ` File "/opt/odoo/auto/addons/password_security/tests/test_res_users.py", line 143, in test_validate_pass_reset_error ` rec_id = self._new_record() ` File "/opt/odoo/auto/addons/password_security/tests/test_res_users.py", line 46, in _new_record ` partner_id = self.env['res.partner'].create(self.partner_vals) ` File "/opt/odoo/auto/addons/mail_tracking_mailgun/models/res_partner.py", line 154, in create ` return super(ResPartner, self).create(vals) ` File "/opt/odoo/auto/addons/partner_firstname/models/res_partner.py", line 54, in create ` return super(ResPartner, self.with_context(context)).create(vals) ` File "/opt/odoo/custom/src/odoo/odoo/addons/base/res/res_partner.py", line 532, in create ` partner = super(Partner, self).create(vals) ` File "/opt/odoo/auto/addons/mail/models/mail_thread.py", line 228, in create ` thread = super(MailThread, self).create(values) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 3847, in create ` record = self.browse(self._create(old_vals)) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 4006, in _create ` self.recompute() ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5336, in recompute ` vals = rec._convert_to_write({n: rec[n] for n in ns}) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5336, in <dictcomp> ` vals = rec._convert_to_write({n: rec[n] for n in ns}) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5232, in __getitem__ ` return self._fields[key].__get__(self, type(self)) ` File "/opt/odoo/custom/src/odoo/odoo/fields.py", line 918, in __get__ ` value = record._cache[self] ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5584, in __getitem__ ` return value.get() if isinstance(value, SpecialValue) else value ` File "/opt/odoo/custom/src/odoo/odoo/fields.py", line 48, in get ` raise self.exception ` AccessError: (u'Sorry, you are not allowed to access this document. Only users with the following access level are currently allowed to do that:\n- Events/User\n\n(Document model: event.registration)', None) Since creating users or partners in tests has a very high probability to collide with other addons, this test is being moved to post mode. Also, to avoid the above permissions issue, the partner is actually created through the admin user, which actually has permissions to read everything. Then, it is `.sudo()`ed later, to perform the module tests correctly. The tests do not get affected because what is being tested was not [intended to be] the partner creation itself, but the password policy enforcement.
7 years ago
[FIX] password_security: Create user as admin in tests If you test this addon after installing `partner_event`, you get this error in all tests: ERROR: test_validate_pass_reset_error (odoo.addons.password_security.tests.test_res_users.TestResUsers) ` It should throw PassError on reset inside min threshold Traceback (most recent call last): ` File "/opt/odoo/auto/addons/password_security/tests/test_res_users.py", line 143, in test_validate_pass_reset_error ` rec_id = self._new_record() ` File "/opt/odoo/auto/addons/password_security/tests/test_res_users.py", line 46, in _new_record ` partner_id = self.env['res.partner'].create(self.partner_vals) ` File "/opt/odoo/auto/addons/mail_tracking_mailgun/models/res_partner.py", line 154, in create ` return super(ResPartner, self).create(vals) ` File "/opt/odoo/auto/addons/partner_firstname/models/res_partner.py", line 54, in create ` return super(ResPartner, self.with_context(context)).create(vals) ` File "/opt/odoo/custom/src/odoo/odoo/addons/base/res/res_partner.py", line 532, in create ` partner = super(Partner, self).create(vals) ` File "/opt/odoo/auto/addons/mail/models/mail_thread.py", line 228, in create ` thread = super(MailThread, self).create(values) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 3847, in create ` record = self.browse(self._create(old_vals)) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 4006, in _create ` self.recompute() ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5336, in recompute ` vals = rec._convert_to_write({n: rec[n] for n in ns}) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5336, in <dictcomp> ` vals = rec._convert_to_write({n: rec[n] for n in ns}) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5232, in __getitem__ ` return self._fields[key].__get__(self, type(self)) ` File "/opt/odoo/custom/src/odoo/odoo/fields.py", line 918, in __get__ ` value = record._cache[self] ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5584, in __getitem__ ` return value.get() if isinstance(value, SpecialValue) else value ` File "/opt/odoo/custom/src/odoo/odoo/fields.py", line 48, in get ` raise self.exception ` AccessError: (u'Sorry, you are not allowed to access this document. Only users with the following access level are currently allowed to do that:\n- Events/User\n\n(Document model: event.registration)', None) Since creating users or partners in tests has a very high probability to collide with other addons, this test is being moved to post mode. Also, to avoid the above permissions issue, the partner is actually created through the admin user, which actually has permissions to read everything. Then, it is `.sudo()`ed later, to perform the module tests correctly. The tests do not get affected because what is being tested was not [intended to be] the partner creation itself, but the password policy enforcement.
7 years ago
[FIX] password_security: Create user as admin in tests If you test this addon after installing `partner_event`, you get this error in all tests: ERROR: test_validate_pass_reset_error (odoo.addons.password_security.tests.test_res_users.TestResUsers) ` It should throw PassError on reset inside min threshold Traceback (most recent call last): ` File "/opt/odoo/auto/addons/password_security/tests/test_res_users.py", line 143, in test_validate_pass_reset_error ` rec_id = self._new_record() ` File "/opt/odoo/auto/addons/password_security/tests/test_res_users.py", line 46, in _new_record ` partner_id = self.env['res.partner'].create(self.partner_vals) ` File "/opt/odoo/auto/addons/mail_tracking_mailgun/models/res_partner.py", line 154, in create ` return super(ResPartner, self).create(vals) ` File "/opt/odoo/auto/addons/partner_firstname/models/res_partner.py", line 54, in create ` return super(ResPartner, self.with_context(context)).create(vals) ` File "/opt/odoo/custom/src/odoo/odoo/addons/base/res/res_partner.py", line 532, in create ` partner = super(Partner, self).create(vals) ` File "/opt/odoo/auto/addons/mail/models/mail_thread.py", line 228, in create ` thread = super(MailThread, self).create(values) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 3847, in create ` record = self.browse(self._create(old_vals)) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 4006, in _create ` self.recompute() ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5336, in recompute ` vals = rec._convert_to_write({n: rec[n] for n in ns}) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5336, in <dictcomp> ` vals = rec._convert_to_write({n: rec[n] for n in ns}) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5232, in __getitem__ ` return self._fields[key].__get__(self, type(self)) ` File "/opt/odoo/custom/src/odoo/odoo/fields.py", line 918, in __get__ ` value = record._cache[self] ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5584, in __getitem__ ` return value.get() if isinstance(value, SpecialValue) else value ` File "/opt/odoo/custom/src/odoo/odoo/fields.py", line 48, in get ` raise self.exception ` AccessError: (u'Sorry, you are not allowed to access this document. Only users with the following access level are currently allowed to do that:\n- Events/User\n\n(Document model: event.registration)', None) Since creating users or partners in tests has a very high probability to collide with other addons, this test is being moved to post mode. Also, to avoid the above permissions issue, the partner is actually created through the admin user, which actually has permissions to read everything. Then, it is `.sudo()`ed later, to perform the module tests correctly. The tests do not get affected because what is being tested was not [intended to be] the partner creation itself, but the password policy enforcement.
7 years ago
[FIX] password_security: Create user as admin in tests If you test this addon after installing `partner_event`, you get this error in all tests: ERROR: test_validate_pass_reset_error (odoo.addons.password_security.tests.test_res_users.TestResUsers) ` It should throw PassError on reset inside min threshold Traceback (most recent call last): ` File "/opt/odoo/auto/addons/password_security/tests/test_res_users.py", line 143, in test_validate_pass_reset_error ` rec_id = self._new_record() ` File "/opt/odoo/auto/addons/password_security/tests/test_res_users.py", line 46, in _new_record ` partner_id = self.env['res.partner'].create(self.partner_vals) ` File "/opt/odoo/auto/addons/mail_tracking_mailgun/models/res_partner.py", line 154, in create ` return super(ResPartner, self).create(vals) ` File "/opt/odoo/auto/addons/partner_firstname/models/res_partner.py", line 54, in create ` return super(ResPartner, self.with_context(context)).create(vals) ` File "/opt/odoo/custom/src/odoo/odoo/addons/base/res/res_partner.py", line 532, in create ` partner = super(Partner, self).create(vals) ` File "/opt/odoo/auto/addons/mail/models/mail_thread.py", line 228, in create ` thread = super(MailThread, self).create(values) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 3847, in create ` record = self.browse(self._create(old_vals)) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 4006, in _create ` self.recompute() ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5336, in recompute ` vals = rec._convert_to_write({n: rec[n] for n in ns}) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5336, in <dictcomp> ` vals = rec._convert_to_write({n: rec[n] for n in ns}) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5232, in __getitem__ ` return self._fields[key].__get__(self, type(self)) ` File "/opt/odoo/custom/src/odoo/odoo/fields.py", line 918, in __get__ ` value = record._cache[self] ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5584, in __getitem__ ` return value.get() if isinstance(value, SpecialValue) else value ` File "/opt/odoo/custom/src/odoo/odoo/fields.py", line 48, in get ` raise self.exception ` AccessError: (u'Sorry, you are not allowed to access this document. Only users with the following access level are currently allowed to do that:\n- Events/User\n\n(Document model: event.registration)', None) Since creating users or partners in tests has a very high probability to collide with other addons, this test is being moved to post mode. Also, to avoid the above permissions issue, the partner is actually created through the admin user, which actually has permissions to read everything. Then, it is `.sudo()`ed later, to perform the module tests correctly. The tests do not get affected because what is being tested was not [intended to be] the partner creation itself, but the password policy enforcement.
7 years ago
[FIX] password_security: Create user as admin in tests If you test this addon after installing `partner_event`, you get this error in all tests: ERROR: test_validate_pass_reset_error (odoo.addons.password_security.tests.test_res_users.TestResUsers) ` It should throw PassError on reset inside min threshold Traceback (most recent call last): ` File "/opt/odoo/auto/addons/password_security/tests/test_res_users.py", line 143, in test_validate_pass_reset_error ` rec_id = self._new_record() ` File "/opt/odoo/auto/addons/password_security/tests/test_res_users.py", line 46, in _new_record ` partner_id = self.env['res.partner'].create(self.partner_vals) ` File "/opt/odoo/auto/addons/mail_tracking_mailgun/models/res_partner.py", line 154, in create ` return super(ResPartner, self).create(vals) ` File "/opt/odoo/auto/addons/partner_firstname/models/res_partner.py", line 54, in create ` return super(ResPartner, self.with_context(context)).create(vals) ` File "/opt/odoo/custom/src/odoo/odoo/addons/base/res/res_partner.py", line 532, in create ` partner = super(Partner, self).create(vals) ` File "/opt/odoo/auto/addons/mail/models/mail_thread.py", line 228, in create ` thread = super(MailThread, self).create(values) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 3847, in create ` record = self.browse(self._create(old_vals)) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 4006, in _create ` self.recompute() ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5336, in recompute ` vals = rec._convert_to_write({n: rec[n] for n in ns}) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5336, in <dictcomp> ` vals = rec._convert_to_write({n: rec[n] for n in ns}) ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5232, in __getitem__ ` return self._fields[key].__get__(self, type(self)) ` File "/opt/odoo/custom/src/odoo/odoo/fields.py", line 918, in __get__ ` value = record._cache[self] ` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5584, in __getitem__ ` return value.get() if isinstance(value, SpecialValue) else value ` File "/opt/odoo/custom/src/odoo/odoo/fields.py", line 48, in get ` raise self.exception ` AccessError: (u'Sorry, you are not allowed to access this document. Only users with the following access level are currently allowed to do that:\n- Events/User\n\n(Document model: event.registration)', None) Since creating users or partners in tests has a very high probability to collide with other addons, this test is being moved to post mode. Also, to avoid the above permissions issue, the partner is actually created through the admin user, which actually has permissions to read everything. Then, it is `.sudo()`ed later, to perform the module tests correctly. The tests do not get affected because what is being tested was not [intended to be] the partner creation itself, but the password policy enforcement.
7 years ago
  1. # -*- coding: utf-8 -*-
  2. # Copyright 2015 LasLabs Inc.
  3. # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
  4. import time
  5. from odoo.tests.common import at_install, post_install, SavepointCase
  6. from ..exceptions import PassError
  7. @at_install(False)
  8. @post_install(True)
  9. class TestResUsers(SavepointCase):
  10. def setUp(cls):
  11. super(TestResUsers, cls).setUp()
  12. cls.main_comp = cls.env.ref('base.main_company')
  13. # Modify users as privileged, but non-root user
  14. cls.privileged_user = cls.env['res.users'].create({
  15. 'name': 'Privileged User',
  16. 'login': 'privileged_user@example.com',
  17. 'company_id': cls.main_comp.id,
  18. 'groups_id': [
  19. (4, cls.env.ref('base.group_erp_manager').id),
  20. (4, cls.env.ref('base.group_partner_manager').id),
  21. (4, cls.env.ref('base.group_user').id),
  22. ],
  23. })
  24. cls.privileged_user.email = cls.privileged_user.login
  25. cls.login = 'foslabs@example.com'
  26. cls.partner_vals = {
  27. 'name': 'Partner',
  28. 'is_company': False,
  29. 'email': cls.login,
  30. }
  31. cls.password = 'asdQWE123$%^'
  32. cls.vals = {
  33. 'name': 'User',
  34. 'login': cls.login,
  35. 'password': cls.password,
  36. 'company_id': cls.main_comp.id
  37. }
  38. cls.model_obj = cls.env['res.users']
  39. def _new_record(self):
  40. partner_id = self.env['res.partner'].create(self.partner_vals)
  41. self.vals['partner_id'] = partner_id.id
  42. return self.model_obj.create(self.vals).sudo(self.privileged_user)
  43. def test_password_write_date_is_saved_on_create(self):
  44. rec_id = self._new_record()
  45. self.assertTrue(
  46. rec_id.password_write_date,
  47. 'Password write date was not saved to db.',
  48. )
  49. def test_password_write_date_is_updated_on_write(self):
  50. rec_id = self._new_record()
  51. old_write_date = rec_id.password_write_date
  52. time.sleep(2)
  53. rec_id.write({'password': 'asdQWE123$%^2'})
  54. rec_id.refresh()
  55. new_write_date = rec_id.password_write_date
  56. self.assertNotEqual(
  57. old_write_date, new_write_date,
  58. 'Password write date was not updated on write.',
  59. )
  60. def test_does_not_update_write_date_if_password_unchanged(self):
  61. rec_id = self._new_record()
  62. old_write_date = rec_id.password_write_date
  63. time.sleep(2)
  64. rec_id.write({'name': 'Luser'})
  65. rec_id.refresh()
  66. new_write_date = rec_id.password_write_date
  67. self.assertEqual(
  68. old_write_date, new_write_date,
  69. 'Password not changed but write date updated anyway.',
  70. )
  71. def test_check_password_returns_true_for_valid_password(self):
  72. rec_id = self._new_record()
  73. self.assertTrue(
  74. rec_id._check_password('asdQWE123$%^3'),
  75. 'Password is valid but check failed.',
  76. )
  77. def test_check_password_raises_error_for_invalid_password(self):
  78. rec_id = self._new_record()
  79. with self.assertRaises(PassError):
  80. rec_id._check_password('password')
  81. def test_save_password_crypt(self):
  82. rec_id = self._new_record()
  83. self.assertEqual(
  84. 1, len(rec_id.password_history_ids),
  85. )
  86. def test_check_password_crypt(self):
  87. """ It should raise PassError if previously used """
  88. rec_id = self._new_record()
  89. with self.assertRaises(PassError):
  90. rec_id.write({'password': self.password})
  91. def test_password_is_expired_if_record_has_no_write_date(self):
  92. rec_id = self._new_record()
  93. rec_id.write({'password_write_date': None})
  94. rec_id.refresh()
  95. self.assertTrue(
  96. rec_id._password_has_expired(),
  97. 'Record has no password write date but check failed.',
  98. )
  99. def test_an_old_password_is_expired(self):
  100. rec_id = self._new_record()
  101. old_write_date = '1970-01-01 00:00:00'
  102. rec_id.write({'password_write_date': old_write_date})
  103. rec_id.refresh()
  104. self.assertTrue(
  105. rec_id._password_has_expired(),
  106. 'Password is out of date but check failed.',
  107. )
  108. def test_a_new_password_is_not_expired(self):
  109. rec_id = self._new_record()
  110. self.assertFalse(
  111. rec_id._password_has_expired(),
  112. 'Password was just created but has already expired.',
  113. )
  114. def test_expire_password_generates_token(self):
  115. rec_id = self._new_record()
  116. rec_id.sudo().action_expire_password()
  117. rec_id.refresh()
  118. token = rec_id.partner_id.signup_token
  119. self.assertTrue(
  120. token,
  121. 'A token was not generated.',
  122. )
  123. def test_validate_pass_reset_error(self):
  124. """ It should throw PassError on reset inside min threshold """
  125. rec_id = self._new_record()
  126. with self.assertRaises(PassError):
  127. rec_id._validate_pass_reset()
  128. def test_validate_pass_reset_allow(self):
  129. """ It should allow reset pass when outside threshold """
  130. rec_id = self._new_record()
  131. rec_id.password_write_date = '2016-01-01'
  132. self.assertEqual(
  133. True, rec_id._validate_pass_reset(),
  134. )
  135. def test_validate_pass_reset_zero(self):
  136. """ It should allow reset pass when <= 0 """
  137. rec_id = self._new_record()
  138. rec_id.company_id.password_minimum = 0
  139. self.assertEqual(
  140. True, rec_id._validate_pass_reset(),
  141. )
  142. def test_underscore_is_special_character(self):
  143. self.assertTrue(self.main_comp.password_special)
  144. rec_id = self._new_record()
  145. rec_id._check_password('asdQWE12345_3')