Tests the search with suspend security.

This commit is contained in:
Monica Diaz Pena
2019-12-26 14:30:16 -05:00
parent c6a9bd39f7
commit fd3c2624a1

View File

@@ -30,3 +30,18 @@ class TestBaseSuspendSecurity(TransactionCase):
# this tests if _normalize_args conversion works # this tests if _normalize_args conversion works
self.env['res.users'].browse( self.env['res.users'].browse(
self.env['res.users'].suspend_security().env.uid) self.env['res.users'].suspend_security().env.uid)
def test_suspend_security_on_search(self):
user_without_access = self.env["res.users"].create(
dict(
name="Testing Suspend Security",
login="nogroups",
email="nogroups@suspendsecurity.com",
groups_id=[(5,)],
)
)
# the search is forbidden
with self.assertRaises(exceptions.AccessError):
self.env["ir.config_parameter"].sudo(user_without_access).search([])
# this tests the search
self.env["ir.config_parameter"].sudo(user_without_access).suspend_security().search([])