Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
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
Boxiang Sun
slapos.core
Commits
02c94a10
Commit
02c94a10
authored
Oct 11, 2012
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prove that blacklist upload works
parent
36fdf199
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
73 additions
and
0 deletions
+73
-0
slapos/tests/slapobject.py
slapos/tests/slapobject.py
+73
-0
No files found.
slapos/tests/slapobject.py
View file @
02c94a10
...
...
@@ -27,6 +27,7 @@
from
slapos.grid
import
SlapObject
from
slapos.grid
import
utils
from
slapos.grid
import
networkcache
from
slapos.tests.slapgrid
import
BasicMixin
import
os
import
unittest
...
...
@@ -42,8 +43,13 @@ class FakeCallAndRead:
self
.
external_command_list
.
extend
(
additional_buildout_parametr_list
)
FakeCallAndRead
=
FakeCallAndRead
()
# Backup modules
original_install_from_buildout
=
SlapObject
.
Software
.
_install_from_buildout
original_upload_network_cached
=
networkcache
.
upload_network_cached
originalBootstrapBuildout
=
utils
.
bootstrapBuildout
originalLaunchBuildout
=
utils
.
launchBuildout
originalUploadSoftwareRelease
=
SlapObject
.
Software
.
uploadSoftwareRelease
class
TestSoftwareSlapObject
(
BasicMixin
,
unittest
.
TestCase
):
"""
...
...
@@ -74,6 +80,9 @@ class TestSoftwareSlapObject(BasicMixin, unittest.TestCase):
# Un-monkey patch utils module
utils
.
bootstrapBuildout
=
originalBootstrapBuildout
utils
.
launchBuildout
=
originalLaunchBuildout
SlapObject
.
Software
.
_install_from_buildout
=
original_install_from_buildout
networkcache
.
upload_network_cached
=
original_upload_network_cached
SlapObject
.
Software
.
uploadSoftwareRelease
=
originalUploadSoftwareRelease
# Test methods
def
test_software_install_with_networkcache
(
self
):
...
...
@@ -133,3 +142,67 @@ class TestSoftwareSlapObject(BasicMixin, unittest.TestCase):
in
command_list
)
self
.
assertFalse
(
'networkcache:upload-dir-url=%s'
%
self
.
upload_dir_url
in
command_list
)
# XXX-Cedric: do the same with upload
def
test_software_install_networkcache_upload_blacklist
(
self
):
"""
Check if the networkcache upload blacklist parameters are propagated.
"""
def
fakeBuildout
(
*
args
,
**
kw
):
pass
SlapObject
.
Software
.
_install_from_buildout
=
fakeBuildout
def
fake_upload_network_cached
(
*
args
,
**
kw
):
self
.
assertFalse
(
True
)
networkcache
.
upload_network_cached
=
fake_upload_network_cached
upload_to_binary_cache_url_blacklist
=
[
"http://example.com"
]
software
=
SlapObject
.
Software
(
url
=
'http://example.com/software.cfg'
,
software_root
=
self
.
software_root
,
buildout
=
self
.
buildout
,
signature_private_key_file
=
'/signature/private/key_file'
,
upload_cache_url
=
'http://example.com/uploadcache'
,
upload_dir_url
=
'http://example.com/uploaddir'
,
shacache_cert_file
=
self
.
shacache_cert_file
,
shacache_key_file
=
self
.
shacache_key_file
,
shadir_cert_file
=
self
.
shadir_cert_file
,
shadir_key_file
=
self
.
shadir_key_file
,
upload_to_binary_cache_url_blacklist
=
\
upload_to_binary_cache_url_blacklist
,
)
software
.
install
()
def
test_software_install_networkcache_upload_blacklist
(
self
):
"""
Check if the networkcache upload blacklist parameters only prevent
blacklisted Software Release to be uploaded.
"""
def
fakeBuildout
(
*
args
,
**
kw
):
pass
SlapObject
.
Software
.
_install_from_buildout
=
fakeBuildout
def
fakeUploadSoftwareRelease
(
*
args
,
**
kw
):
self
.
uploaded
=
True
SlapObject
.
Software
.
uploadSoftwareRelease
=
fakeUploadSoftwareRelease
upload_to_binary_cache_url_blacklist
=
[
"http://anotherexample.com"
]
software
=
SlapObject
.
Software
(
url
=
'http://example.com/software.cfg'
,
software_root
=
self
.
software_root
,
buildout
=
self
.
buildout
,
signature_private_key_file
=
'/signature/private/key_file'
,
upload_cache_url
=
'http://example.com/uploadcache'
,
upload_dir_url
=
'http://example.com/uploaddir'
,
upload_binary_cache_url
=
'http://example.com/uploadcache'
,
upload_binary_dir_url
=
'http://example.com/uploaddir'
,
shacache_cert_file
=
self
.
shacache_cert_file
,
shacache_key_file
=
self
.
shacache_key_file
,
shadir_cert_file
=
self
.
shadir_cert_file
,
shadir_key_file
=
self
.
shadir_key_file
,
upload_to_binary_cache_url_blacklist
=
\
upload_to_binary_cache_url_blacklist
,
)
software
.
install
()
self
.
assertTrue
(
getattr
(
self
,
'uploaded'
,
False
))
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