Commit 9a8c10e5 authored by Thomas Gambier's avatar Thomas Gambier 🚴🏼

rename directory_key to key

parent 12b3f447
......@@ -79,18 +79,18 @@ class NetworkCache:
self.shadir_ca_file = get_('shadir-ca-file')
if network_cache_info.has_section('shacache'):
self.directory_key = network_cache_info.get('shacache', 'key')
self.key = network_cache_info.get('shacache', 'key')
else:
self.directory_key = "slapos-upgrade-testing-key"
self.key = "slapos-upgrade-testing-key"
def upload(self, path, metadata_dict, is_sha256file=False):
"""
Upload an existing file, using a file_descriptor.
"""
if is_sha256file:
key = self.directory_key + "-sha256-content"
key = self.key + "-sha256-content"
else:
key = self.directory_key
key = self.key
file_descriptor = open(path, 'rb')
if not (self.dir_url and self.cache_url):
......@@ -119,9 +119,9 @@ class NetworkCache:
required_key_list=[], strategy=None, is_sha256file=False):
if is_sha256file:
key = self.directory_key + "-sha256-content"
key = self.key + "-sha256-content"
else:
key = self.directory_key
key = self.key
result = helper_download_network_cached(
self.download_binary_dir_url,
......@@ -246,13 +246,13 @@ class Signature:
if sha512sum:
self.log(
'Uploaded %s to cache (using %s key) with SHA512 %s.', path,
shacache.directory_key, sha512sum)
shacache.key, sha512sum)
sha512sum_path = shacache.upload(
path=sha256path, metadata_dict=metadata_dict, is_sha256file=True)
if sha512sum_path:
self.log(
'Uploaded %s to cache (using %s key) with SHA512 %s.', sha256path,
shacache.directory_key, sha512sum_path)
shacache.key, sha512sum_path)
else:
self.log('Fail to upload sha256file file to cache.')
else:
......
......@@ -182,7 +182,7 @@ signature-certificate-list = %(certificate)s
self.assertEqual(shacache.download_cache_url, 'https://www.shacache.org/shacache')
self.assertEqual(shacache.download_binary_dir_url, 'http://www.shacache.org/shadir')
self.assertEqual(shacache.signature_certificate_list, SIGNATURE)
self.assertEqual(shacache.directory_key, 'slapos-upgrade-testing-key-with-config-file-invalid')
self.assertEqual(shacache.key, 'slapos-upgrade-testing-key-with-config-file-invalid')
self.assertEqual(shacache.dir_url, None)
self.assertEqual(shacache.cache_url, None)
self.assertEqual(shacache.signature_private_key_file, None)
......@@ -203,7 +203,7 @@ signature-certificate-list = %(certificate)s
self.assertEqual(shacache.download_cache_url, 'https://www.shacache.org/shacache')
self.assertEqual(shacache.download_binary_dir_url, 'http://www.shacache.org/shadir')
self.assertEqual(shacache.signature_certificate_list, SIGNATURE)
self.assertEqual(shacache.directory_key, 'slapos-upgrade-testing-key-with-config-file-invalid')
self.assertEqual(shacache.key, 'slapos-upgrade-testing-key-with-config-file-invalid')
self.assertEqual(shacache.dir_url, 'https://www.shacache.org/shadir')
self.assertEqual(shacache.cache_url, 'https://www.shacache.org/shacache')
self.assertEqual(shacache.shacache_cert_file, '/etc/opt/slapos/shacache.crt')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment