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

updater: Prepare state for more

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