From 282cffe2ae4338c82af9b0d0ddd1fa44166bb64b Mon Sep 17 00:00:00 2001 From: Peter Mathis Date: Fri, 4 Jul 2025 11:11:22 +0200 Subject: [PATCH 1/2] Fix tests for updated rolemap --- news/+rolemap_testfix.tests.md | 1 + src/plone/restapi/tests/test_search.py | 31 +++++++++----------------- 2 files changed, 11 insertions(+), 21 deletions(-) create mode 100644 news/+rolemap_testfix.tests.md diff --git a/news/+rolemap_testfix.tests.md b/news/+rolemap_testfix.tests.md new file mode 100644 index 000000000..9a5d549ef --- /dev/null +++ b/news/+rolemap_testfix.tests.md @@ -0,0 +1 @@ +Testfix for https://github.com/plone/Products.CMFPlone/pull/4042. @petschki diff --git a/src/plone/restapi/tests/test_search.py b/src/plone/restapi/tests/test_search.py index 321755ef1..013c2e50e 100644 --- a/src/plone/restapi/tests/test_search.py +++ b/src/plone/restapi/tests/test_search.py @@ -660,27 +660,6 @@ def test_respect_access_inactive_permission(self): ).json() self.assertEqual(response["items_total"], 1) - # not admin users can't see expired items - self.api_session.auth = ("editoruser", TEST_USER_PASSWORD) - - response = self.api_session.get("/@search", params={}).json() - if HAS_PLONE_6: - # Since Plone 6 the Plone site is indexed ... - self.assertEqual(response["items_total"], 4) - else: - # ... before it was not - self.assertEqual(response["items_total"], 3) - response = self.api_session.get( - "/@search", params={"Title": "Lorem Ipsum"} - ).json() - self.assertEqual(response["items_total"], 0) - - # now grant permission to Editor to access inactive content - self.portal.manage_permission( - "Access inactive portal content", roles=["Manager", "Editor"] - ) - transaction.commit() - #  portal-enabled Editor can see expired contents response = self.api_session.get("/@search", params={}).json() if HAS_PLONE_6: @@ -718,6 +697,16 @@ def test_respect_access_inactive_permission(self): ).json() self.assertEqual(response["items_total"], 1) + # unauthorized users can not access expired content + self.api_session.auth = None + response = self.api_session.get("/@search", params={}).json() + if HAS_PLONE_6: + # Since Plone 6 the Plone site is indexed ... + self.assertEqual(response["items_total"], 1) + else: + # ... before it was not + self.assertEqual(response["items_total"], 0) + def test_search_use_site_search_settings_for_types(self): response = self.api_session.get( "/@search", params={"use_site_search_settings": 1} From 9bc99995e763d238c24133bdd8a3711d92511d7d Mon Sep 17 00:00:00 2001 From: Peter Mathis Date: Sun, 6 Jul 2025 12:00:47 +0200 Subject: [PATCH 2/2] Update news/+rolemap_testfix.tests.md Co-authored-by: Steve Piercy --- news/+rolemap_testfix.tests.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/news/+rolemap_testfix.tests.md b/news/+rolemap_testfix.tests.md index 9a5d549ef..98cf44ad5 100644 --- a/news/+rolemap_testfix.tests.md +++ b/news/+rolemap_testfix.tests.md @@ -1 +1 @@ -Testfix for https://github.com/plone/Products.CMFPlone/pull/4042. @petschki +Fixed test to allow Contributor and Editor to access inactive portal content. See https://github.com/plone/Products.CMFPlone/pull/4042. @petschki