Commit c1374587 authored by Andreas Jung's avatar Andreas Jung

-fixed some tests

-removed redundant test for attributes
-minor tweakings
parent 33af8d7b
...@@ -90,7 +90,7 @@ import ZPublisher, ResultObject ...@@ -90,7 +90,7 @@ import ZPublisher, ResultObject
class SecurityBase(unittest.TestCase) : class SecurityBase(unittest.TestCase) :
""" Base class for all security tests """ Base class for all security tests
$Id: SecurityBase.py,v 1.3 2001/10/09 14:40:53 andreasjung Exp $ $Id: SecurityBase.py,v 1.4 2001/10/18 14:30:51 andreasjung Exp $
""" """
status_regex = re.compile("Status: ([0-9]{1,4}) (.*)",re.I)\ status_regex = re.compile("Status: ([0-9]{1,4}) (.*)",re.I)\
...@@ -164,10 +164,15 @@ class SecurityBase(unittest.TestCase) : ...@@ -164,10 +164,15 @@ class SecurityBase(unittest.TestCase) :
roles = eval(s) roles = eval(s)
if roles==None or len(roles)==0: if roles==None or len(roles)==0:
roles=(None,) roles=()
for r in roles: roles = list(roles)
if not r in expected_roles: roles.sort()
expected_roles = list(expected_roles)
expected_roles.sort()
if roles != expected_roles:
raise AssertionError, self._roles_debug(hier,roles,expected_roles) raise AssertionError, self._roles_debug(hier,roles,expected_roles)
def _checkRequest(self,*args,**kw): def _checkRequest(self,*args,**kw):
......
...@@ -85,10 +85,9 @@ ...@@ -85,10 +85,9 @@
# #
############################################################################## ##############################################################################
# $Id: regressionSecurity.py,v 1.1 2001/10/11 13:33:48 andreasjung Exp $ # $Id: regressionSecurity.py,v 1.2 2001/10/18 14:30:51 andreasjung Exp $
import os, sys import os, sys, unittest
execfile(os.path.join(sys.path[0],'framework.py'))
import Zope import Zope
from OFS.Folder import Folder from OFS.Folder import Folder
...@@ -259,29 +258,6 @@ class AVeryBasicSecurityTest(SecurityBase.SecurityBase): ...@@ -259,29 +258,6 @@ class AVeryBasicSecurityTest(SecurityBase.SecurityBase):
get_transaction().commit() get_transaction().commit()
def testAttributeAccess(self):
""" check access to attributes """
obj = self.root.test.f2.f3.obj3
try:
x = obj.public_attr
obj.public_attr = 'blabla'
except: raise AssertionError,'this should work !'
try:
x = obj._protected_attr
raise AssertionError,'this should not work !'
except AssertionError:
raise
try:
obj._protected_attr = "blalbla"
raise AssertionError,'this should not work !'
except AssertionError:
raise
def testNobody(self): def testNobody(self):
""" check permissions for nobody user """ """ check permissions for nobody user """
...@@ -296,10 +272,10 @@ class AVeryBasicSecurityTest(SecurityBase.SecurityBase): ...@@ -296,10 +272,10 @@ class AVeryBasicSecurityTest(SecurityBase.SecurityBase):
def testPermissionAccess(self): def testPermissionAccess(self):
""" check permission based access """ """ check permission based access """
self._checkRoles('test.f2.f3.obj3.public_func', (None,)) self._checkRoles('test.f2.f3.obj3.public_func', ())
self._checkRoles('test.f2.f3.obj3.protected_func', ('Manager','Owner')) self._checkRoles('test.f2.f3.obj3.protected_func', ('Manager','Owner'))
self._checkRoles('test.f2.f3.obj3.manage_func', ('Manager',)) self._checkRoles('test.f2.f3.obj3.manage_func', ('Manager',))
self._checkRoles('test.f2.f3.obj3.private_func', ('Manager',)) self._checkRoles('test.f2.f3.obj3.private_func', ())
def testZPublisherAccess(self): def testZPublisherAccess(self):
...@@ -339,4 +315,12 @@ class AVeryBasicSecurityTest(SecurityBase.SecurityBase): ...@@ -339,4 +315,12 @@ class AVeryBasicSecurityTest(SecurityBase.SecurityBase):
res = self._checkRequest(path,expected=expected) res = self._checkRequest(path,expected=expected)
framework() def test_suite():
return unittest.makeSuite(AVeryBasicSecurityTest)
def main():
unittest.TextTestRunner().run(test_suite())
if __name__ == '__main__':
main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment