Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/+rolemap_testfix.tests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Testfix for https://github.com/plone/Products.CMFPlone/pull/4042. @petschki
31 changes: 10 additions & 21 deletions src/plone/restapi/tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The expired items need to be published to make sure they are filtered out here because of their expiration date and not because of allowedRolesAndUsers


def test_search_use_site_search_settings_for_types(self):
response = self.api_session.get(
"/@search", params={"use_site_search_settings": 1}
Expand Down
Loading