Skip to content

Commit

Permalink
Merge PR #823 into 15.0
Browse files Browse the repository at this point in the history
Signed-off-by simahawk
  • Loading branch information
OCA-git-bot committed Oct 2, 2023
2 parents c84078c + 5b14663 commit dd511b6
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions edi_oca/tests/test_security.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ def test_group_create(self):
def test_rule_no_create(self):
self.user.write({"groups_id": [(4, self.group.id)]})
self.consumer_record.name = "no_rule"
with self.assertRaisesRegex(AccessError, "Exchange Record rule demo"):
model = self.consumer_record
msg = rf"not allowed to modify '{model._description}' \({model._name}\)"
with self.assertRaisesRegex(AccessError, msg):
self.create_record(self.user)

@mute_logger("odoo.addons.base.models.ir_model")
Expand All @@ -101,7 +103,9 @@ def test_no_group_no_create(self):
@mute_logger("odoo.addons.base.models.ir_model")
def test_no_group_no_read(self):
exchange_record = self.create_record()
with self.assertRaisesRegex(AccessError, "You are not allowed to access"):
model = self.consumer_record
msg = rf"not allowed to access '{model._description}' \({model._name}\)"
with self.assertRaisesRegex(AccessError, msg):
exchange_record.with_user(self.user).read()

@mute_logger("odoo.addons.base.models.ir_rule")
Expand All @@ -110,7 +114,9 @@ def test_rule_no_read(self):
self.user.write({"groups_id": [(4, self.group.id)]})
self.assertTrue(exchange_record.with_user(self.user).read())
self.consumer_record.name = "no_rule"
with self.assertRaisesRegex(AccessError, "Exchange Record rule demo"):
model = self.consumer_record
msg = rf"not allowed to access '{model._description}' \({model._name}\)"
with self.assertRaisesRegex(AccessError, msg):
exchange_record.with_user(self.user).read()

@mute_logger("odoo.addons.base.models.ir_model")
Expand All @@ -130,7 +136,9 @@ def test_rule_no_unlink(self):
exchange_record = self.create_record()
self.user.write({"groups_id": [(4, self.group.id)]})
self.consumer_record.name = "no_rule"
with self.assertRaisesRegex(AccessError, "Exchange Record rule demo"):
model = self.consumer_record
msg = rf"not allowed to modify '{model._description}' \({model._name}\)"
with self.assertRaisesRegex(AccessError, msg):
exchange_record.with_user(self.user).unlink()

def test_no_group_no_search(self):
Expand Down Expand Up @@ -180,5 +188,7 @@ def test_rule_no_write(self):
exchange_record = self.create_record()
self.user.write({"groups_id": [(4, self.group.id)]})
self.consumer_record.name = "no_rule"
with self.assertRaisesRegex(AccessError, "Exchange Record rule demo"):
model = self.consumer_record
msg = rf"not allowed to modify '{model._description}' \({model._name}\)"
with self.assertRaisesRegex(AccessError, msg):
exchange_record.with_user(self.user).write({"external_identifier": "1234"})

0 comments on commit dd511b6

Please sign in to comment.