Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
2a2f650d
Commit
2a2f650d
authored
Jan 27, 2004
by
Brian Lloyd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
unify policy tests
parent
455c21c7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
67 additions
and
5 deletions
+67
-5
lib/python/AccessControl/tests/testZopeSecurityPolicy.py
lib/python/AccessControl/tests/testZopeSecurityPolicy.py
+67
-5
No files found.
lib/python/AccessControl/tests/testZopeSecurityPolicy.py
View file @
2a2f650d
...
...
@@ -13,8 +13,8 @@
"""Tests of ZopeSecurityPolicy
"""
__rcs_id__
=
'$Id: testZopeSecurityPolicy.py,v 1.
9 2004/01/27 16:59:23 tseaver
Exp $'
__version__
=
'$Revision: 1.
9
$'
[
11
:
-
2
]
__rcs_id__
=
'$Id: testZopeSecurityPolicy.py,v 1.
10 2004/01/27 19:22:51 Brian
Exp $'
__version__
=
'$Revision: 1.
10
$'
[
11
:
-
2
]
import
os
,
sys
,
unittest
...
...
@@ -37,8 +37,11 @@ sysadmin_roles = ('RoleOfSysAdmin',)
class
App
(
Explicit
):
pass
def
unrestrictedTraverse
(
self
,
path
):
ob
=
self
for
el
in
path
:
ob
=
getattr
(
ob
,
el
)
return
ob
class
PublicMethod
(
Method
):
def
getOwner
(
self
):
...
...
@@ -73,11 +76,26 @@ class setuidMethod (PublicMethod):
_proxy_roles
=
sysadmin_roles
class
OwnedSetuidMethod
(
Implicit
):
__roles__
=
eo_roles
_proxy_roles
=
sysadmin_roles
def
getOwner
(
self
,
info
=
0
):
if
info
:
return
((
'subobject'
,
'acl_users'
),
'theowner'
)
else
:
return
self
.
aq_parent
.
aq_parent
.
acl_users
.
getUserById
(
'theowner'
)
def
getWrappedOwner
(
self
):
acl_users
=
self
.
aq_parent
.
aq_parent
.
acl_users
user
=
acl_users
.
getUserById
(
'theowner'
)
return
user
.
__of__
(
acl_users
)
class
DangerousMethod
(
PublicMethod
):
# Only accessible to sysadmin or people who use proxy roles
__roles__
=
sysadmin_roles
class
SimpleItemish
(
Implicit
):
public_m
=
PublicMethod
()
protected_m
=
ProtectedMethod
()
...
...
@@ -87,12 +105,23 @@ class SimpleItemish (Implicit):
public_prop
=
'Public Value'
private_prop
=
'Private Value'
class
ImplictAcqObject
(
Implicit
):
pass
class
UnprotectedSimpleItem
(
SimpleItemish
):
__allow_access_to_unprotected_subobjects__
=
1
class
OwnedSimpleItem
(
UnprotectedSimpleItem
):
def
getOwner
(
self
,
info
=
0
):
if
info
:
return
((
'subobject'
,
'acl_users'
),
'theowner'
)
else
:
return
self
.
aq_parent
.
acl_users
.
getuserById
(
'theowner'
)
class
RestrictedSimpleItem
(
SimpleItemish
):
__allow_access_to_unprotected_subobjects__
=
0
...
...
@@ -258,6 +287,39 @@ class ZopeSecurityPolicyTests (unittest.TestCase):
else
:
policy
.
validate
(
''
,
''
,
name
,
''
,
None
)
def
testProxyRoleScope
(
self
):
self
.
a
.
subobject
=
ImplictAcqObject
()
subobject
=
self
.
a
.
subobject
subobject
.
acl_users
=
UserFolder
()
subobject
.
acl_users
.
_addUser
(
'theowner'
,
'password'
,
'password'
,
eo_roles
+
sysadmin_roles
,
())
subobject
.
item
=
UnprotectedSimpleItem
()
subitem
=
subobject
.
item
subitem
.
owned_setuid_m
=
OwnedSetuidMethod
()
subitem
.
getPhysicalRoot
=
lambda
root
=
self
.
a
:
root
item
=
self
.
a
.
item
item
.
getPhysicalRoot
=
lambda
root
=
self
.
a
:
root
self
.
context
.
stack
.
append
(
subitem
.
owned_setuid_m
.
__of__
(
subitem
))
# Out of owner context
self
.
assertPolicyAllows
(
item
,
'public_m'
)
self
.
assertPolicyDenies
(
item
,
'protected_m'
)
self
.
assertPolicyDenies
(
item
,
'owned_m'
)
self
.
assertPolicyAllows
(
item
,
'setuid_m'
)
self
.
assertPolicyDenies
(
item
,
'dangerous_m'
)
# Inside owner context
self
.
assertPolicyAllows
(
subitem
,
'public_m'
)
self
.
assertPolicyDenies
(
subitem
,
'protected_m'
)
self
.
assertPolicyDenies
(
subitem
,
'owned_m'
)
self
.
assertPolicyAllows
(
subitem
,
'setuid_m'
)
self
.
assertPolicyAllows
(
subitem
,
'dangerous_m'
)
def
testUnicodeName
(
self
):
policy
=
self
.
policy
assert
policy
.
validate
(
''
,
''
,
u'foo'
,
''
,
None
)
if
0
:
# This test purposely generates a log entry.
# Enable it if you don't mind it adding to the log.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment