From 3030f962ced74659c4ed6da7402500ea11dd1cce Mon Sep 17 00:00:00 2001
From: Rafael Monnerat <rafael@nexedi.com>
Date: Thu, 28 Aug 2008 12:10:28 +0000
Subject: [PATCH] Make sure that if the Object Parent does not have one
 permission (View and Access contents information), is not possible use this
 permission as checked_permission.

If some object has no Permission to Access contents information all subobjects cannot be accessed, even if you View permission.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@23224 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Type/tests/testERP5Type.py | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/product/ERP5Type/tests/testERP5Type.py b/product/ERP5Type/tests/testERP5Type.py
index 1452fc0f4fd..e889f79c934 100644
--- a/product/ERP5Type/tests/testERP5Type.py
+++ b/product/ERP5Type/tests/testERP5Type.py
@@ -1193,7 +1193,7 @@ class TestPropertySheet:
                         person.getDefaultOrganisationTitle())
       self.assertEquals(other_pers_title,
                         other_pers.getDefaultOrganisationTitle())
-      
+
     def test_19b_AcquiredContentAccessorWithIdClash(self,quiet=quiet, run=run_all_test):
       """Tests a content setters do not set the property on acquired object
       that may have the same id, using same scenario as test_19
@@ -1261,6 +1261,8 @@ class TestPropertySheet:
       self.assertEquals(email.getDefaultAvailableLanguage(), 'ja')
       self.assertEquals(email.getAvailableLanguageList(), ('ja', 'fr', 'en'))
 
+
+
     def test_20_AsContext(self,quiet=quiet, run=run_all_test):
       """asContext method return a temporary copy of an object.
       Any modification made to the copy does not change the original object.
@@ -1983,6 +1985,28 @@ class TestPropertySheet:
       self.assertEquals(["Gamma System"],
           foo.getWrappedRegionTitleList(checked_permission='View'))
 
+      # Remove permission from parent object, the behaviour of acessor should
+      # be kept. If you have no permission to the parent, this means that the 
+      # sub objects cannot be accessed too.
+      gamma.getParentValue().manage_permission("View", [], acquire=0)
+
+      # getProperty is used by forms
+      self.assertEquals(None,foo.getProperty("wrapped_region_title_list",
+                                                            checked_permission='View'))
+      self.assertEquals(None,
+                foo.getWrappedRegionTitleList(checked_permission='View'))
+
+      self.assertEquals(["Gamma System"],
+                      foo.getWrappedRegionTitleList(checked_permission='Access contents information'))
+
+      gamma.getParentValue().manage_permission("Access contents information", [], acquire=0)
+      self.assertEquals(None,
+                foo.getWrappedRegionTitleList(checked_permission='View'))
+
+      self.assertEquals(None,
+                      foo.getWrappedRegionTitleList(checked_permission='Access contents information'))
+
+
     def test_category_accessor_to_non_existing_documents(self):
       # tests behaviour of category accessors with relations to non existing
       # documents.
-- 
2.30.9