Commit 617fb154 authored by Łukasz Nowak's avatar Łukasz Nowak

updater: Prepare state for more

parent 4ad201cd
......@@ -1386,14 +1386,14 @@ class KedifaUpdaterUpdateCertificateTest(
certificate='', fetch='content', master_content=None)
self.assertEqual('content', certificate)
self.assertTrue(update)
self.assertState({self.certificate_file_name: True})
self.assertState({self.certificate_file_name: {'overridden': True}})
def test_cert_fetch_nomaster_nofallback(self):
certificate, update = self._update(
certificate='old content', fetch='content', master_content=None)
self.assertEqual('content', certificate)
self.assertTrue(update)
self.assertState({self.certificate_file_name: True})
self.assertState({self.certificate_file_name: {'overridden': True}})
def test_nocert_nofetch_master_nofallback(self):
certificate, update = self._update(
......@@ -1414,14 +1414,14 @@ class KedifaUpdaterUpdateCertificateTest(
certificate='', fetch='content', master_content='master')
self.assertEqual('content', certificate)
self.assertTrue(update)
self.assertState({self.certificate_file_name: True})
self.assertState({self.certificate_file_name: {'overridden': True}})
def test_cert_fetch_master_nofallback(self):
certificate, update = self._update(
certificate='old content', fetch='content', master_content='master')
self.assertEqual('content', certificate)
self.assertTrue(update)
self.assertState({self.certificate_file_name: True})
self.assertState({self.certificate_file_name: {'overridden': True}})
def test_nocert_nofetch_nomaster_fallback(self):
certificate, update = self._update(
......@@ -1446,7 +1446,7 @@ class KedifaUpdaterUpdateCertificateTest(
fallback='fallback')
self.assertEqual('old content', certificate)
self.assertFalse(update)
self.assertState({self.certificate_file_name: True})
self.assertState({self.certificate_file_name: {'overridden': True}})
def test_nocert_fetch_nomaster_fallback(self):
certificate, update = self._update(
......@@ -1454,7 +1454,7 @@ class KedifaUpdaterUpdateCertificateTest(
fallback='fallback')
self.assertEqual('content', certificate)
self.assertTrue(update)
self.assertState({self.certificate_file_name: True})
self.assertState({self.certificate_file_name: {'overridden': True}})
def test_cert_fetch_nomaster_fallback(self):
certificate, update = self._update(
......@@ -1462,7 +1462,7 @@ class KedifaUpdaterUpdateCertificateTest(
fallback='fallback')
self.assertEqual('content', certificate)
self.assertTrue(update)
self.assertState({self.certificate_file_name: True})
self.assertState({self.certificate_file_name: {'overridden': True}})
def test_nocert_nofetch_master_fallback(self):
certificate, update = self._update(
......@@ -1488,7 +1488,7 @@ class KedifaUpdaterUpdateCertificateTest(
fallback='fallback')
self.assertEqual('old content', certificate)
self.assertFalse(update)
self.assertState({self.certificate_file_name: True})
self.assertState({self.certificate_file_name: {'overridden': True}})
def test_nocert_fetch_master_fallback(self):
certificate, update = self._update(
......@@ -1496,7 +1496,7 @@ class KedifaUpdaterUpdateCertificateTest(
fallback='fallback')
self.assertEqual('content', certificate)
self.assertTrue(update)
self.assertState({self.certificate_file_name: True})
self.assertState({self.certificate_file_name: {'overridden': True}})
def test_cert_fetch_master_fallback(self):
certificate, update = self._update(
......@@ -1504,7 +1504,7 @@ class KedifaUpdaterUpdateCertificateTest(
fallback='fallback')
self.assertEqual('content', certificate)
self.assertTrue(update)
self.assertState({self.certificate_file_name: True})
self.assertState({self.certificate_file_name: {'overridden': True}})
class KedifaUpdaterUpdateCertificatePrepareTest(
......
......@@ -71,7 +71,14 @@ class Updater(object):
url, fallback_file = self.mapping[certificate_file]
certificate = self.fetchCertificate(url, certificate_file)
fallback_overridden = self.state_dict.get(certificate_file, False)
fallback_overridden = self.state_dict.get(certificate_file, {})
if isinstance(fallback_overridden, dict):
# Support new improved mapping certificate --> information mapping
fallback_overridden = fallback_overridden.get('overridden', False)
elif certificate_file in self.state_dict:
# Migrate to new version ASAP
self.state_dict[certificate_file] = {'overridden': fallback_overridden}
fallback = ''
if fallback_file:
try:
......@@ -95,7 +102,7 @@ class Updater(object):
else:
return False
else:
self.state_dict[certificate_file] = True
self.state_dict[certificate_file] = {'overridden': True}
if current != certificate:
with open(certificate_file, 'w') as fh:
......
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