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
0b5f2600
Commit
0b5f2600
authored
Oct 09, 2001
by
Andreas Jung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- updated tests
- better debug messages
parent
6c1d1cbb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
10 deletions
+44
-10
lib/python/AccessControl/securitySuite/ResultObject.py
lib/python/AccessControl/securitySuite/ResultObject.py
+5
-4
lib/python/AccessControl/securitySuite/SecurityBase.py
lib/python/AccessControl/securitySuite/SecurityBase.py
+5
-3
lib/python/AccessControl/securitySuite/testSecurity.py
lib/python/AccessControl/securitySuite/testSecurity.py
+34
-3
No files found.
lib/python/AccessControl/securitySuite/ResultObject.py
View file @
0b5f2600
...
...
@@ -88,17 +88,18 @@ class ResultObject:
""" result object used for keeping results from the
ZPublisher.Zope() calls
$Id: ResultObject.py,v 1.
1 2001/10/08 14:49:45
andreasjung Exp $
$Id: ResultObject.py,v 1.
2 2001/10/09 14:40:53
andreasjung Exp $
"""
def
__str__
(
self
,
expected
=-
1
):
def
__str__
(
self
,
expected
=-
1
,
with_output
=
1
):
s
=
'
\
n
'
s
+=
'-'
*
78
s
+=
"
\
n
Request: %s"
%
self
.
request
s
+=
"
\
n
User: %s"
%
self
.
user
s
+=
"
\
n
Expected: %s"
%
expected
+
" got: %s %s"
%
(
self
.
code
,
self
.
return_text
)
s
+=
"
\
n
Output:"
s
+=
self
.
output
if
with_output
:
s
+=
"
\
n
Output:"
s
+=
self
.
output
s
+=
"
\
n
"
return
s
...
...
lib/python/AccessControl/securitySuite/SecurityBase.py
View file @
0b5f2600
...
...
@@ -90,7 +90,7 @@ import ZPublisher, ResultObject
class
SecurityBase
(
unittest
.
TestCase
)
:
""" Base class for all security tests
$Id: SecurityBase.py,v 1.
2 2001/10/09 14:16:34
andreasjung Exp $
$Id: SecurityBase.py,v 1.
3 2001/10/09 14:40:53
andreasjung Exp $
"""
status_regex
=
re
.
compile
(
"Status: ([0-9]{1,4}) (.*)"
,
re
.
I
)
\
...
...
@@ -180,7 +180,7 @@ class SecurityBase(unittest.TestCase) :
if
expected_code
!=
res
.
code
:
raise
AssertionError
,
\
self
.
_request_debug
(
args
,
kw
)
self
.
_request_debug
(
res
,
expected_code
,
args
,
kw
)
################################################################
...
...
@@ -205,9 +205,11 @@ class SecurityBase(unittest.TestCase) :
return
s
def
_request_debug
(
self
,
*
args
,
**
kw
):
def
_request_debug
(
self
,
res
,
expected
,
args
,
kw
):
s
=
'Args: %s'
%
str
(
args
)
s
+=
', KW: %s'
%
str
(
kw
)
s
+=
'
\
n
%s
\
n
'
%
res
.
__str__
(
with_output
=
0
,
expected
=
expected
)
return
s
...
...
lib/python/AccessControl/securitySuite/testSecurity.py
View file @
0b5f2600
...
...
@@ -85,7 +85,7 @@
#
##############################################################################
# $Id: testSecurity.py,v 1.
8 2001/10/08 14:57:4
3 andreasjung Exp $
# $Id: testSecurity.py,v 1.
9 2001/10/09 14:40:5
3 andreasjung Exp $
import
os
,
sys
execfile
(
os
.
path
.
join
(
sys
.
path
[
0
],
'framework.py'
))
...
...
@@ -203,6 +203,14 @@ USERS = (
User
(
'manager'
,
'123'
,(
'Manager'
,))
)
def
getAuth
(
username
):
for
user
in
USERS
:
if
user
.
username
==
username
:
return
"%s:%s"
%
(
user
.
username
,
user
.
password
)
raise
KeyError
,
"no such username: %"
%
username
class
AVeryBasicSecurityTest
(
SecurityBase
.
SecurityBase
):
...
...
@@ -297,8 +305,31 @@ class AVeryBasicSecurityTest(SecurityBase.SecurityBase):
def
testZPublisherAccess
(
self
):
""" test access through ZPublisher """
_r
=
[
(
'/test/f1/'
,
None
,
200
),
(
'/test/f1/anonobj'
,
'manager:123'
,
200
),
_r
=
[
(
'/test/f1/'
,
None
,
200
),
(
'/test/f2'
,
None
,
200
),
(
'/test/f2/f3'
,
None
,
200
),
(
'/test/f2/f3/obj3/public_func'
,
None
,
200
),
(
'/test/f2/f3/obj3/protected_func'
,
None
,
401
),
(
'/test/f2/f3/obj3/manage_func'
,
None
,
401
),
(
'/test/f2/f3/obj3/private_func'
,
None
,
401
),
(
'/test/f1/'
,
getAuth
(
'manager'
),
200
),
(
'/test/f2'
,
getAuth
(
'manager'
),
200
),
(
'/test/f2/f3'
,
getAuth
(
'manager'
),
200
),
(
'/test/f2/f3/obj3/public_func'
,
getAuth
(
'manager'
),
200
),
(
'/test/f2/f3/obj3/protected_func'
,
getAuth
(
'manager'
),
200
),
(
'/test/f2/f3/obj3/manage_func'
,
getAuth
(
'manager'
),
200
),
(
'/test/f2/f3/obj3/private_func'
,
getAuth
(
'manager'
),
401
),
(
'/test/f1/'
,
getAuth
(
'owner'
),
200
),
(
'/test/f2'
,
getAuth
(
'owner'
),
200
),
(
'/test/f2/f3'
,
getAuth
(
'owner'
),
200
),
(
'/test/f2/f3/obj3/public_func'
,
getAuth
(
'owner'
),
200
),
(
'/test/f2/f3/obj3/protected_func'
,
getAuth
(
'owner'
),
200
),
(
'/test/f2/f3/obj3/manage_func'
,
getAuth
(
'owner'
),
401
),
(
'/test/f2/f3/obj3/private_func'
,
getAuth
(
'owner'
),
401
),
]
for
path
,
auth
,
expected
in
_r
:
...
...
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