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
f12f5b49
Commit
f12f5b49
authored
Jul 10, 2010
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Small cleanup
parent
79e9fa21
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
9 deletions
+10
-9
src/Products/Five/tests/testing/restricted.py
src/Products/Five/tests/testing/restricted.py
+10
-9
No files found.
src/Products/Five/tests/testing/restricted.py
View file @
f12f5b49
...
...
@@ -16,27 +16,28 @@
Based on Plone's RestrictedPythonTestCase, with kind permission by the
Plone developers.
"""
from
AccessControl
import
Unauthorized
from
Products.PythonScripts.PythonScript
import
manage_addPythonScript
def
addPythonScript
(
folder
,
id
,
params
=
''
,
body
=
''
):
"""Add a PythonScript to folder."""
# clean up any 'ps' that's already here..
try
:
folder
.
_getOb
(
id
)
folder
.
manage_delObjects
([
id
])
except
AttributeError
:
pass
# it's okay, no 'ps' exists yet
factory
=
folder
.
manage_addProduct
[
'PythonScripts'
]
factory
.
manage_addPythonScript
(
id
)
if
id
in
folder
:
del
folder
[
id
]
manage_addPythonScript
(
folder
,
id
)
folder
[
id
].
ZPythonScript_edit
(
params
,
body
)
def
checkRestricted
(
folder
,
psbody
):
"""Perform a check by running restricted Python code."""
addPythonScript
(
folder
,
'ps'
,
body
=
psbody
)
try
:
folder
.
ps
()
except
Unauthorized
,
e
:
raise
AssertionError
,
e
raise
AssertionError
(
e
)
def
checkUnauthorized
(
folder
,
psbody
):
"""Perform a check by running restricted Python code. Expect to
...
...
@@ -47,4 +48,4 @@ def checkUnauthorized(folder, psbody):
except
Unauthorized
:
pass
else
:
raise
AssertionError
,
"Authorized but shouldn't be"
raise
AssertionError
(
"Authorized but shouldn't be"
)
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