Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
wendelin
Commits
d5973f53
Commit
d5973f53
authored
Jun 14, 2022
by
Levin Zimmermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_wendelin: Add test for unpackLazy in RestrictedPython
parent
e2146551
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
2 deletions
+49
-2
bt5/erp5_wendelin/TestTemplateItem/portal_components/test.erp5.testWendelin.py
...tTemplateItem/portal_components/test.erp5.testWendelin.py
+49
-2
No files found.
bt5/erp5_wendelin/TestTemplateItem/portal_components/test.erp5.testWendelin.py
View file @
d5973f53
...
@@ -25,8 +25,6 @@
...
@@ -25,8 +25,6 @@
#
#
##############################################################################
##############################################################################
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
wendelin.bigarray.array_zodb
import
ZBigArray
from
cStringIO
import
StringIO
from
cStringIO
import
StringIO
import
binascii
import
binascii
import
msgpack
import
msgpack
...
@@ -34,7 +32,14 @@ import numpy as np
...
@@ -34,7 +32,14 @@ import numpy as np
import
string
import
string
import
random
import
random
import
struct
import
struct
import
textwrap
import
urllib
import
urllib
import
uuid
from
zExceptions
import
BadRequest
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Products.ERP5Type.tests.utils
import
createZODBPythonScript
,
removeZODBPythonScript
from
wendelin.bigarray.array_zodb
import
ZBigArray
def
getRandomString
():
def
getRandomString
():
...
@@ -54,6 +59,16 @@ class Test(ERP5TypeTestCase):
...
@@ -54,6 +59,16 @@ class Test(ERP5TypeTestCase):
def
getTitle
(
self
):
def
getTitle
(
self
):
return
"Wendelin Test"
return
"Wendelin Test"
def
createAndRunScript
(
self
,
code
,
expected
):
# we do not care the script name for security test thus use uuid1
name
=
str
(
uuid
.
uuid1
())
script_container
=
self
.
portal
.
portal_skins
.
custom
try
:
createZODBPythonScript
(
script_container
,
name
,
'**kw'
,
textwrap
.
dedent
(
code
))
self
.
assertEqual
(
getattr
(
self
.
portal
,
name
)(),
expected
)
finally
:
removeZODBPythonScript
(
script_container
,
name
)
def
test_01_IngestionFromFluentd
(
self
,
old_fluentd
=
False
):
def
test_01_IngestionFromFluentd
(
self
,
old_fluentd
=
False
):
"""
"""
Test ingestion using a POST Request containing a msgpack encoded message
Test ingestion using a POST Request containing a msgpack encoded message
...
@@ -556,3 +571,35 @@ class Test(ERP5TypeTestCase):
...
@@ -556,3 +571,35 @@ class Test(ERP5TypeTestCase):
np
.
array
([]),
np
.
array
([]),
)
)
)
)
def
test_13_unpackLazy
(
self
):
"""
Ensure unpackLazy is available and functional in restricted python
"""
ingestion_policy_id
=
"test_13_unpackLazy_IngestionPolicy"
try
:
ingestion_policy
=
self
.
getPortal
().
portal_ingestion_policies
.
newContent
(
id
=
ingestion_policy_id
,
title
=
ingestion_policy_id
,
portal_type
=
'Ingestion Policy'
,
reference
=
ingestion_policy_id
,
version
=
'001'
,
)
# ingestion_policy still exists from previous failed test run
except
BadRequest
:
ingestion_policy
=
self
.
portal
.
get
(
ingestion_policy_id
)
self
.
assertNotEqual
(
ingestion_policy
,
None
)
self
.
commit
()
self
.
tic
()
self
.
addCleanup
(
self
.
_removeDocument
,
ingestion_policy
)
code
=
r"""
ingestion_policy = context.portal_ingestion_policies.get("{}")
result = [x for x in ingestion_policy.unpackLazy('b"\x93\x01\x02\x03"')]
return result
"""
.
format
(
ingestion_policy_id
)
self
.
createAndRunScript
(
code
,
[
98
,
34
,
[
1
,
2
,
3
],
34
])
\ No newline at end of file
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