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 @@
...
@@ -16,27 +16,28 @@
Based on Plone's RestrictedPythonTestCase, with kind permission by the
Based on Plone's RestrictedPythonTestCase, with kind permission by the
Plone developers.
Plone developers.
"""
"""
from
AccessControl
import
Unauthorized
from
AccessControl
import
Unauthorized
from
Products.PythonScripts.PythonScript
import
manage_addPythonScript
def
addPythonScript
(
folder
,
id
,
params
=
''
,
body
=
''
):
def
addPythonScript
(
folder
,
id
,
params
=
''
,
body
=
''
):
"""Add a PythonScript to folder."""
"""Add a PythonScript to folder."""
# clean up any 'ps' that's already here..
# clean up any 'ps' that's already here..
try
:
if
id
in
folder
:
folder
.
_getOb
(
id
)
del
folder
[
id
]
folder
.
manage_delObjects
([
id
])
manage_addPythonScript
(
folder
,
id
)
except
AttributeError
:
pass
# it's okay, no 'ps' exists yet
factory
=
folder
.
manage_addProduct
[
'PythonScripts'
]
factory
.
manage_addPythonScript
(
id
)
folder
[
id
].
ZPythonScript_edit
(
params
,
body
)
folder
[
id
].
ZPythonScript_edit
(
params
,
body
)
def
checkRestricted
(
folder
,
psbody
):
def
checkRestricted
(
folder
,
psbody
):
"""Perform a check by running restricted Python code."""
"""Perform a check by running restricted Python code."""
addPythonScript
(
folder
,
'ps'
,
body
=
psbody
)
addPythonScript
(
folder
,
'ps'
,
body
=
psbody
)
try
:
try
:
folder
.
ps
()
folder
.
ps
()
except
Unauthorized
,
e
:
except
Unauthorized
,
e
:
raise
AssertionError
,
e
raise
AssertionError
(
e
)
def
checkUnauthorized
(
folder
,
psbody
):
def
checkUnauthorized
(
folder
,
psbody
):
"""Perform a check by running restricted Python code. Expect to
"""Perform a check by running restricted Python code. Expect to
...
@@ -47,4 +48,4 @@ def checkUnauthorized(folder, psbody):
...
@@ -47,4 +48,4 @@ def checkUnauthorized(folder, psbody):
except
Unauthorized
:
except
Unauthorized
:
pass
pass
else
:
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