Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
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
Roque
erp5
Commits
70d11122
Commit
70d11122
authored
Feb 07, 2023
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_web_shadir: update tests
See commit
c45c2295
("erp5_web_shadir: more useful checks").
parent
de87a9b0
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
20 deletions
+11
-20
bt5/erp5_web_shadir/TestTemplateItem/portal_components/test.erp5.ShaDirMixin.py
...stTemplateItem/portal_components/test.erp5.ShaDirMixin.py
+4
-7
bt5/erp5_web_shadir/TestTemplateItem/portal_components/test.erp5.testShaDir.py
...estTemplateItem/portal_components/test.erp5.testShaDir.py
+5
-6
bt5/networkcache_erp5/TestTemplateItem/portal_components/test.erp5.testShaDirExternal.py
...ateItem/portal_components/test.erp5.testShaDirExternal.py
+2
-7
No files found.
bt5/erp5_web_shadir/TestTemplateItem/portal_components/test.erp5.ShaDirMixin.py
View file @
70d11122
...
...
@@ -27,11 +27,11 @@
#
##############################################################################
import
base64
import
hashlib
import
json
import
platform
import
random
from
base64
import
b64encode
from
DateTime
import
DateTime
...
...
@@ -47,8 +47,6 @@ class ShaDirMixin(object):
self
.
portal
=
self
.
getPortal
()
self
.
key
=
'mykey'
+
str
(
random
.
random
())
self
.
file_name
=
'file.txt'
self
.
urlmd5
=
hashlib
.
md5
(
self
.
key
).
hexdigest
()
self
.
file_content
=
'This is the content.'
self
.
file_sha512sum
=
hashlib
.
sha512
(
self
.
file_content
).
hexdigest
()
self
.
distribution
=
'pypi'
...
...
@@ -58,21 +56,20 @@ class ShaDirMixin(object):
libc_version
=
'%s %s'
%
(
platform
.
libc_ver
()[
0
],
platform
.
libc_ver
()[
1
])
self
.
architecture
=
'%s %s'
%
(
platform
.
machine
(),
libc_version
)
self
.
data_list
=
[
json
.
dumps
({
'file'
:
self
.
file_name
,
'urlmd5'
:
self
.
urlmd5
,
self
.
data_list
=
[
json
.
dumps
({
'sha512'
:
self
.
file_sha512sum
,
'creation_date'
:
str
(
self
.
creation_date
),
'expiration_date'
:
str
(
self
.
expiration_date
),
'distribution'
:
self
.
distribution
,
'architecture'
:
self
.
architecture
}),
"User SIGNATURE goes here."
]
b64encode
(
"User SIGNATURE goes here."
)
]
self
.
data
=
json
.
dumps
(
self
.
data_list
)
self
.
sha512sum
=
hashlib
.
sha512
(
self
.
data
).
hexdigest
()
self
.
header_dict
=
{
'Content-Type'
:
'application/json'
,
'Authorization'
:
'Basic
%s'
%
(
base64
.
encodestring
(
'ERP5TypeTestCase:'
).
strip
())
'Authorization'
:
'Basic
'
+
b64encode
(
'ERP5TypeTestCase:'
),
}
module
=
self
.
portal
.
web_site_module
...
...
bt5/erp5_web_shadir/TestTemplateItem/portal_components/test.erp5.testShaDir.py
View file @
70d11122
...
...
@@ -27,11 +27,12 @@
#
##############################################################################
import
hashlib
import
httplib
import
urlparse
import
json
import
random
from
base64
import
b64encode
from
unittest
import
expectedFailure
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
erp5.component.test.ShaDirMixin
import
ShaDirMixin
...
...
@@ -214,17 +215,15 @@ class TestShaDir(ShaDirMixin, ERP5TypeTestCase):
self
.
postInformation
()
self
.
tic
()
urlmd5_2
=
'anotherurlmd5'
+
str
(
random
.
random
())
sha512_2
=
'anothersha512_2'
+
str
(
random
.
random
())
sha512_2
=
hashlib
.
sha512
(
str
(
random
.
random
())).
hexdigest
()
key_2
=
'another_key'
+
str
(
random
.
random
())
data_list_2
=
[
json
.
dumps
({
'file'
:
self
.
file_name
,
'urlmd5'
:
urlmd5_2
,
data_list_2
=
[
json
.
dumps
({
'sha512'
:
sha512_2
,
'creation_date'
:
str
(
self
.
creation_date
),
'expiration_date'
:
str
(
self
.
expiration_date
),
'distribution'
:
self
.
distribution
,
'architecture'
:
self
.
architecture
}),
"User SIGNATURE goes here."
]
b64encode
(
"User SIGNATURE goes here."
)
]
data_2
=
json
.
dumps
(
data_list_2
)
self
.
postInformation
(
key_2
,
data_2
)
self
.
tic
()
...
...
bt5/networkcache_erp5/TestTemplateItem/portal_components/test.erp5.testShaDirExternal.py
View file @
70d11122
...
...
@@ -146,14 +146,10 @@ class TestShaDirExternal(ShaDirMixin, ShaSecurityMixin, ERP5TypeTestCase):
self
.
assertEqual
(
302
,
result
.
status
)
def
test_external_post_with_wrong_data
(
self
):
"""
The data which is sent to the server must follow a JSON schema.
If the data does not follow the schema it must return the error.
"""
# Removing a required property
data
=
json
.
loads
(
self
.
data
)
data
[
0
]
=
json
.
loads
(
data
[
0
])
d
ata
[
0
].
pop
(
'file'
)
d
el
data
[
0
][
'sha512'
]
data
[
0
]
=
json
.
dumps
(
data
[
0
])
data
=
json
.
dumps
(
data
)
...
...
@@ -165,7 +161,6 @@ class TestShaDirExternal(ShaDirMixin, ShaSecurityMixin, ERP5TypeTestCase):
data
=
result
.
read
()
finally
:
connection
.
close
()
self
.
assertTrue
(
"Required field 'file' is missing"
in
data
,
data
)
self
.
assertEqual
(
500
,
result
.
status
)
self
.
assertEqual
(
400
,
result
.
status
)
self
.
assertEqual
(
'text/html; charset=utf-8'
,
result
.
getheader
(
"content-type"
))
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