Skip to content

Commit

Permalink
Fix issue where catalog search with path failed when path had inacces…
Browse files Browse the repository at this point in the history
…sible (private) levels
  • Loading branch information
datakurre committed Apr 10, 2017
1 parent ac77383 commit 73d9f7c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Products/CMFPlone/CatalogTool.py
Expand Up @@ -409,7 +409,9 @@ def allow_inactive(self, query_kw):
for path in list(paths):
path = path.encode('utf-8') # paths must not be unicode
try:
objs.append(site.restrictedTraverse(path))
parts = path.split('/')
parent = site.unrestrictedTraverse('/'.join(parts[:-1]))
objs.append(parent.restrictedTraverse(parts[-1]))
except (KeyError, AttributeError):
# When no object is found don't raise an error
pass
Expand Down
28 changes: 28 additions & 0 deletions Products/CMFPlone/tests/testCatalogTool.py
Expand Up @@ -1026,6 +1026,34 @@ def testCallExpiredWithPermission(self):
res = self.catalog()
self.assertResults(res, base_content)

def testPathWithPrivateMidLevel(self):
# This test was added to test issue where allow_inactive-check raised
# Unauthorized-exception with the search conditions of this test.

# Be anonymous to enable allow_inactive -check
self.logout()

# Check that search shows both self.folder and self.folder.doc
path = '/'.join(self.folder.aq_parent.getPhysicalPath())
results = [b.getPath() for b in self.catalog(path=path)]
self.assertIn('/'.join(self.folder.getPhysicalPath()), results)
self.assertIn('/'.join(self.folder.doc.getPhysicalPath()), results)

# Hide self.folder from anonymous, but leave self.folder.doc visible
self.login(TEST_USER_NAME)
self.portal.portal_workflow.doActionFor(self.folder, 'hide')
self.logout()

# Check that self.folder.doc is still visible while self.folder is not
results = [b.getPath() for b in self.catalog(path=path)]
self.assertNotIn('/'.join(self.folder.getPhysicalPath()), results)
self.assertIn('/'.join(self.folder.doc.getPhysicalPath()), results)

# Check that direct search for self.folder.doc can be made
path = '/'.join(self.folder.doc.getPhysicalPath())
results = [b.getPath() for b in self.catalog(path=path)]
self.assertIn('/'.join(self.folder.doc.getPhysicalPath()), results)

def testExpiredWithPermissionOnSubpath(self):
self.folder.doc.setExpirationDate(DateTime(2000, 12, 31))
self.folder.doc.reindexObject()
Expand Down

0 comments on commit 73d9f7c

Please sign in to comment.