From 79a99289974912a3dfefcdbf2eb3236bb1b5ac89 Mon Sep 17 00:00:00 2001 From: samoel-silva Date: Mon, 16 Sep 2024 21:35:48 -0300 Subject: [PATCH] =?UTF-8?q?Exercicio=2025:=20Teste=20para=20proibi=C3=A7?= =?UTF-8?q?=C3=A3o=20de=20secretaria=20dentro=20de=20secretaria?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/tests/content/test_ct_secretaria.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/backend/tests/content/test_ct_secretaria.py b/backend/tests/content/test_ct_secretaria.py index 387315a..74fa5c9 100644 --- a/backend/tests/content/test_ct_secretaria.py +++ b/backend/tests/content/test_ct_secretaria.py @@ -80,3 +80,24 @@ def test_create(self, secretaria_payload, role, allowed): content = api.content.create( container=self.portal, **secretaria_payload ) + + @pytest.mark.parametrize( + "role", + [ + ["Manager"], + ["Site Administrator"], + ["Member"], + ["Editor"], + ], + ) + def test_cant_create(self, secretaria_payload, role): + usr = api.user.get_current() + with api.env.adopt_roles("Manager"): + content = api.content.create(container=self.portal, **secretaria_payload) + with api.env.adopt_roles(role): + assert ( + api.user.has_permission( + "portal.governo: Add Secretaria", user=usr, obj=content + ) + is False + )