Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.libnetworkcache
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
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
slapos.libnetworkcache
Commits
ec8f2d45
Commit
ec8f2d45
authored
Sep 02, 2011
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cover a case when server replied no json.
parent
755401fd
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
0 deletions
+27
-0
slapos/libnetworkcachetests.py
slapos/libnetworkcachetests.py
+27
-0
No files found.
slapos/libnetworkcachetests.py
View file @
ec8f2d45
...
...
@@ -558,6 +558,33 @@ class OnlineTest(OnlineMixin, unittest.TestCase):
# empty content in shadir so usual exception is raised
self
.
assertEqual
(
str
(
msg
),
'Could not find a trustable entry.'
)
def
test_select_no_json_response
(
self
):
key
=
'somekey'
+
str
(
random
.
random
())
urlmd5
=
str
(
random
.
random
())
file_name
=
'my file'
test_data
=
tempfile
.
TemporaryFile
()
test_string
=
str
(
random
.
random
())
test_data
.
write
(
test_string
)
test_data
.
seek
(
0
)
key_file
=
tempfile
.
NamedTemporaryFile
()
key_file
.
write
(
self
.
key
)
key_file
.
flush
()
key_file
.
seek
(
0
)
nc
=
slapos
.
libnetworkcache
.
NetworkcacheClient
(
self
.
shacache
,
self
.
shadir
)
self
.
assertEqual
(
True
,
nc
.
upload
(
self
.
test_data
,
key
,
urlmd5
=
urlmd5
,
file_name
=
file_name
))
f
=
os
.
path
.
join
(
self
.
tree
,
'shadir'
,
key
)
# now remove the entry from shacache
open
(
f
,
'w'
).
write
(
'This is not a json.'
)
try
:
nc
.
select
(
key
)
except
slapos
.
libnetworkcache
.
DirectoryNotFound
,
msg
:
# empty content in shadir so usual exception is raised
self
.
assertTrue
(
str
(
msg
).
startswith
(
'It was impossible to parse json '
'response'
))
def
test_select_signed_content_server_hacked
(
self
):
key
=
'somekey'
+
str
(
random
.
random
())
urlmd5
=
str
(
random
.
random
())
...
...
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