Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapcache
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
slapcache
Commits
12b3f447
Commit
12b3f447
authored
Mar 31, 2022
by
Thomas Gambier
🚴🏼
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support tests in python2
textwrap.indent doesn't exist in python2.
parent
4b8e5c41
Pipeline
#21471
passed with stage
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
7 deletions
+6
-7
slapcache/test/test_signature.py
slapcache/test/test_signature.py
+6
-7
No files found.
slapcache/test/test_signature.py
View file @
12b3f447
...
...
@@ -7,7 +7,6 @@
from
slapcache
import
signature
from
slapos.libnetworkcache
import
NetworkcacheClient
from
optparse
import
Values
from
textwrap
import
indent
import
slapos.signature
,
time
,
difflib
,
tempfile
,
unittest
,
os
def
_fake_call
(
self
,
*
args
,
**
kw
):
self
.
last_call
=
(
args
,
kw
)
...
...
@@ -104,8 +103,7 @@ upgrade = 2014-06-04
"""
SIGNATURE
=
"""
-----BEGIN CERTIFICATE-----
SIGNATURE
=
"""-----BEGIN CERTIFICATE-----
MIIB8DCCAVmgAwIBAgIJAPFf61p8y809MA0GCSqGSIb3DQEBBQUAMBAxDjAMBgNV
BAMMBUNPTVAtMCAXDTE0MDIxNzE2NDgxN1oYDzIxMTQwMTI0MTY0ODE3WjAQMQ4w
DAYDVQQDDAVDT01QLTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAsiqCyuv1
...
...
@@ -176,7 +174,8 @@ class NetworkCacheTestCase(unittest.TestCase):
info
,
self
.
configuration_file_path
=
tempfile
.
mkstemp
()
configuration_content
=
UPDATE_CFG_DATA
+
"""
signature-certificate-list = %(certificate)s
"""
%
{
'certificate'
:
indent
(
SIGNATURE
,
' '
)}
"""
%
{
'certificate'
:
'
\
n
'
.
join
(
' '
+
l
if
l
.
strip
()
else
'
\
n
'
for
l
in
SIGNATURE
.
splitlines
())}
print
(
configuration_content
)
open
(
self
.
configuration_file_path
,
'w'
).
write
(
configuration_content
)
shacache
=
signature
.
NetworkCache
(
self
.
configuration_file_path
)
self
.
assertEqual
(
shacache
.
download_binary_cache_url
,
'http://www.shacache.org/shacache'
)
...
...
@@ -197,7 +196,7 @@ signature-certificate-list = %(certificate)s
info
,
self
.
configuration_file_path
=
tempfile
.
mkstemp
()
configuration_content
=
UPDATE_CFG_WITH_UPLOAD_DATA
+
"""
signature-certificate-list = %(certificate)s
"""
%
{
'certificate'
:
indent
(
SIGNATURE
,
' '
)}
"""
%
{
'certificate'
:
'
\
n
'
.
join
(
' '
+
l
if
l
.
strip
()
else
'
\
n
'
for
l
in
SIGNATURE
.
splitlines
()
)}
open
(
self
.
configuration_file_path
,
'w'
).
write
(
configuration_content
)
shacache
=
signature
.
NetworkCache
(
self
.
configuration_file_path
)
self
.
assertEqual
(
shacache
.
download_binary_cache_url
,
'http://www.shacache.org/shacache'
)
...
...
@@ -255,11 +254,11 @@ upload-dir-url = https://www.shacache.org/shadir
shadir-cert-file = %(tempfile)s
shadir-key-file = %(tempfile)s
signature-certificate-list =
%(certificate)s
%(certificate)s
"""
%
{
'tempfile'
:
_fake_signature_path
,
'signature_private_key_file'
:
signature_private_key_file
,
'certificate'
:
indent
(
open
(
signature_certificate_file
,
'r'
).
read
(),
' '
)
'certificate'
:
''
.
join
(
' '
+
l
if
l
.
strip
()
else
'
\
n
'
for
l
in
open
(
signature_certificate_file
,
'r'
).
readlines
()
)
}
open
(
self
.
configuration_file_path
,
'w'
).
write
(
configuration_content
)
open
(
_fake_signature_path
,
'w'
).
write
(
'# XXX ...'
)
...
...
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