Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.package
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
14
Merge Requests
14
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
slapos.package
Commits
0e4dc50e
Commit
0e4dc50e
authored
Jul 15, 2014
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos.package: Fixes for Tests
parent
045cbe91
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
131 additions
and
11 deletions
+131
-11
slapos/package/distribution.py
slapos/package/distribution.py
+1
-1
slapos/package/promise/core.py
slapos/package/promise/core.py
+1
-1
slapos/package/test/base.py
slapos/package/test/base.py
+46
-0
slapos/package/test/test_promise_core.py
slapos/package/test/test_promise_core.py
+70
-5
slapos/package/test/test_signature.py
slapos/package/test/test_signature.py
+13
-4
No files found.
slapos/package/distribution.py
View file @
0e4dc50e
...
...
@@ -165,7 +165,7 @@ class AptGet:
def
addKey
(
self
,
caller
,
url
,
alias
):
""" Download and add a gpg key """
gpg_path
=
open
(
"%s/%s.gpg"
%
self
.
trusted_gpg_d_path
,
alias
)
gpg_path
=
open
(
"%s/%s.gpg"
%
(
self
.
trusted_gpg_d_path
,
alias
)
)
if
os
.
path
.
exists
(
gpg_path
):
# File already exists, skip
return
...
...
slapos/package/promise/core.py
View file @
0e4dc50e
...
...
@@ -51,7 +51,7 @@ class Promise(BasePromise):
repository_tuple_list
.
append
((
alias
.
strip
(),
url
.
strip
()))
key_tuple_list
=
[]
for
key
in
upgrade_goal
[
'key-list'
]
:
for
key
in
upgrade_goal
.
get
(
'key-list'
,
[])
:
alias
,
url
=
key
.
split
(
"="
)
key_tuple_list
.
append
((
alias
.
strip
(),
url
.
strip
()))
...
...
slapos/package/test/base.py
View file @
0e4dc50e
...
...
@@ -104,3 +104,49 @@ reboot = 2011-10-10
upgrade = 2014-06-04
"""
UPGRADE_KEY_WITHOUT_KEY_LIST
=
"""[debian-default]
repository-list =
main = http://ftp.fr.debian.org/debian/ wheezy main
main-src = http://ftp.fr.debian.org/debian/ wheezy main
update = http://ftp.fr.debian.org/debian/ wheezy-updates main
update-src = http://ftp.fr.debian.org/debian/ wheezy-updates main
slapos = http://download.opensuse.org/repositories/home:/VIFIBnexedi:/branches:/home:/VIFIBnexedi/Debian_7.0/ ./
re6stnet = http://git.erp5.org/dist/deb ./
filter-package-list =
ntp
openvpn
slapos.node
re6stnet
filter-promise-list =
core
signature-list =
debian+++jessie/sid+++
debian+++7.4+++
debian+++7.5+++
debian+++7.3+++
debian+++7+++
[opensuse-legacy]
repository-list =
suse = http://download.opensuse.org/distribution/12.1/repo/oss/
slapos = http://download.opensuse.org/repositories/home:/VIFIBnexedi:/branches:/home:/VIFIBnexedi/openSUSE_12.1/
re6st = http://git.erp5.org/dist/rpm
filter-promise-list =
core
filter-package-list =
ntp
openvpn
slapos.node
re6stnet
signature-list =
opensuse+++12.1+++x86_64
[system]
reboot = 2011-10-10
upgrade = 2014-06-04
"""
slapos/package/test/test_promise_core.py
View file @
0e4dc50e
...
...
@@ -27,8 +27,10 @@
#
##############################################################################
import
datetime
from
slapos.package.promise
import
core
from
slapos.package.test.base
import
CONFIGURATION_FILE
,
UPGRADE_KEY
,
_fake_call
from
slapos.package.test.base
import
CONFIGURATION_FILE
,
UPGRADE_KEY
,
\
_fake_call
,
UPGRADE_KEY_WITHOUT_KEY_LIST
from
slapos.package.signature
import
NetworkCache
from
optparse
import
Values
...
...
@@ -51,8 +53,11 @@ class TestCoreCase(unittest.TestCase):
def
setUp
(
self
):
core
.
Promise
.
_call
=
_fake_call
core
.
Promise
.
log
=
_log_message_list
core
.
Promise
.
log
=
_log_message_list
self
.
original_promise_update
=
core
.
Promise
.
update
core
.
Promise
.
update
=
_fake_update
self
.
original_network_cache_download
=
NetworkCache
.
download
# Patch Download
...
...
@@ -71,6 +76,9 @@ class TestCoreCase(unittest.TestCase):
"verbose"
:
False
}
def
tearDown
(
self
):
NetworkCache
.
download
=
self
.
original_network_cache_download
core
.
Promise
.
update
=
self
.
original_promise_update
def
_createConfigurationFile
(
self
):
with
open
(
"/tmp/test_base_promise_configuration.cfg"
,
"w"
)
as
configuration_file
:
...
...
@@ -144,9 +152,11 @@ reboot = 2100-11-11
# Patch Download
def
_fake_signature_download
(
self
,
path
,
*
args
,
**
kwargs
):
copy_of_upgrade_key
=
UPGRADE_KEY
with
open
(
path
,
'w'
)
as
upgrade_signature
:
modified_upgrade_key
=
UPGRADE_KEY
.
replace
(
"upgrade = 2014-06-04"
,
"upgrade = 2100-01-01"
)
modified_upgrade_key
=
copy_of_upgrade_key
.
replace
(
"upgrade = 2014-06-04"
,
"upgrade = 2100-01-01"
)
upgrade_signature
.
write
(
modified_upgrade_key
)
return
True
...
...
@@ -187,7 +197,7 @@ reboot = 2100-11-11
'Expected Reboot early them 2011-10-10'
,
'Expected Upgrade early them 2014-06-04'
,
'Last reboot : 2100-11-11'
,
'Last upgrade :
2014-06-14'
,
'Last upgrade :
%s'
%
datetime
.
datetime
.
today
().
strftime
(
"%Y-%m-%d"
),
'Your system is up to date'
,
'No need to reboot.'
,
'No need to reboot.'
]
...
...
@@ -212,3 +222,58 @@ reboot = 2100-11-11
self
.
assertEquals
(
promise
.
_fake_update_call
[
2
],
key_list
)
def
testFixConsistency_without_key_list
(
self
):
modified_config_dict
=
self
.
config_dict
.
copy
()
# Patch Download
def
_fake_signature_download
(
self
,
path
,
*
args
,
**
kwargs
):
with
open
(
path
,
'w'
)
as
upgrade_signature
:
modified_upgrade_key
=
UPGRADE_KEY_WITHOUT_KEY_LIST
.
replace
(
"upgrade = 2014-06-04"
,
"upgrade = 2100-01-01"
)
upgrade_signature
.
write
(
modified_upgrade_key
)
return
True
NetworkCache
.
download
=
_fake_signature_download
def
_fake_update
(
self
,
repository_list
=
[],
package_list
=
[],
key_list
=
[]):
self
.
_fake_update_call
=
(
repository_list
,
package_list
,
key_list
)
slapupdate_path
=
"/tmp/testFixConsistencyUpgrade"
with
open
(
slapupdate_path
,
'w'
)
as
slapupdate
:
slapupdate
.
write
(
"""[system]
upgrade = 2000-11-11
reboot = 2100-11-11
"""
)
modified_config_dict
[
"srv_file"
]
=
slapupdate_path
promise
=
core
.
Promise
(
Values
(
modified_config_dict
))
self
.
assertEquals
(
promise
.
checkConsistency
(
fixit
=
1
),
True
)
self
.
maxDiff
=
None
expected_message_list
=
[
'Expected Reboot early them 2011-10-10'
,
'Expected Upgrade early them 2100-01-01'
,
'Last reboot : 2100-11-11'
,
'Last upgrade : 2000-11-11'
,
'Upgrade will happens on 2100-01-01'
]
self
.
assertEquals
(
promise
.
_message_list
,
expected_message_list
)
repository_list
=
[
(
'main'
,
'http://ftp.fr.debian.org/debian/ wheezy main'
),
(
'main-src'
,
'http://ftp.fr.debian.org/debian/ wheezy main'
),
(
'update'
,
'http://ftp.fr.debian.org/debian/ wheezy-updates main'
),
(
'update-src'
,
'http://ftp.fr.debian.org/debian/ wheezy-updates main'
),
(
'slapos'
,
'http://download.opensuse.org/repositories/home:/VIFIBnexedi:/branches:/home:/VIFIBnexedi/Debian_7.0/ ./'
),
(
're6stnet'
,
'http://git.erp5.org/dist/deb ./'
)]
filter_package_list
=
[
'ntp'
,
'openvpn'
,
'slapos.node'
,
're6stnet'
]
key_list
=
[]
self
.
assertEquals
(
promise
.
_fake_update_call
[
0
],
repository_list
)
self
.
assertEquals
(
promise
.
_fake_update_call
[
1
],
filter_package_list
)
self
.
assertEquals
(
promise
.
_fake_update_call
[
2
],
key_list
)
slapos/package/test/test_signature.py
View file @
0e4dc50e
...
...
@@ -62,9 +62,14 @@ signature-certificate-list =
-----END CERTIFICATE-----
"""
UPDATE_CFG_DATA
=
"""
[slapupdate]
upgrade_key = slapos-upgrade-testing-key-with-config-file-invalid
"""
+
BASE_UPDATE_CFG_DATA
UPDATE_UPLOAD_CFG_DATA
=
"""
[slapupdate]
upgrade_key = slapos-upgrade-testing-key-with-config-file
"""
+
BASE_UPDATE_CFG_DATA
...
...
@@ -142,6 +147,7 @@ def _fake_upload(self, *args, **kwargs):
class
NetworkCacheTestCase
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
original_networkcache_upload
=
NetworkcacheClient
.
upload
NetworkcacheClient
.
upload
=
_fake_upload
...
...
@@ -152,6 +158,8 @@ class NetworkCacheTestCase(unittest.TestCase):
"verbose"
:
False
}
def
tearDown
(
self
):
NetworkcacheClient
.
upload
=
self
.
original_networkcache_upload
def
_createConfigurationFile
(
self
):
with
open
(
"/tmp/test_signature_000000_configuration.cfg"
,
"w"
)
as
configuration_file
:
...
...
@@ -173,7 +181,7 @@ class NetworkCacheTestCase(unittest.TestCase):
SIGNATURE
)
self
.
assertEqual
(
shacache
.
directory_key
,
'slapos-upgrade-testing-key-with-config-file'
)
'slapos-upgrade-testing-key-with-config-file
-invalid
'
)
# Check keys that don't exist
# Not mandatory
self
.
assertEqual
(
shacache
.
dir_url
,
None
)
...
...
@@ -200,7 +208,7 @@ class NetworkCacheTestCase(unittest.TestCase):
SIGNATURE
)
self
.
assertEqual
(
shacache
.
directory_key
,
'slapos-upgrade-testing-key-with-config-file'
)
'slapos-upgrade-testing-key-with-config-file
-invalid
'
)
# Check keys that don't exist
# Not mandatory
self
.
assertEqual
(
shacache
.
dir_url
,
'https://www.shacache.org/shadir'
)
...
...
@@ -239,6 +247,7 @@ class NetworkCacheTestCase(unittest.TestCase):
strategy
=
signature
.
strategy
)
self
.
maxDiff
=
None
self
.
assertEquals
(
UPGRADE_KEY
.
splitlines
(),
open
(
path
,
'r'
).
read
().
splitlines
())
...
...
@@ -260,7 +269,7 @@ class NetworkCacheTestCase(unittest.TestCase):
signature_private_key_file
,
"COMP-123A"
)
configuration_content
=
UPDATE_CFG_DATA
+
"""
configuration_content
=
UPDATE_
UPLOAD_
CFG_DATA
+
"""
signature_private_key_file = %(signature_private_key_file)s
signature_certificate_file = %(signature_certificate_file)s
upload-cache-url = https://www.shacache.org/shacache
...
...
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