Skip to content

Commit adbb5fe

Browse files
committed
Simplify test_updater_root_rotation_integration
Implement a simpler check that the file we expected to fail wasa the cause of the NoWorkingMirror exceptions. Signed-off-by: Joshua Lock <[email protected]>
1 parent 7f9ded5 commit adbb5fe

File tree

1 file changed

+9
-24
lines changed

1 file changed

+9
-24
lines changed

tests/test_updater_root_rotation_integration.py

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -266,13 +266,10 @@ def test_verify_root_with_current_keyids_and_threshold(self):
266266
self.repository_updater.refresh()
267267

268268
for mirror_url, mirror_error in six.iteritems(cm.exception.mirror_errors):
269-
url_prefix = self.repository_mirrors['mirror1']['url_prefix']
270-
url_file = os.path.join(url_prefix, 'metadata', '2.root.json')
271-
272269
# Verify that '2.root.json' is the culprit.
273-
self.assertEqual(url_file.replace('\\', '/'), mirror_url)
270+
self.assertTrue(mirror_url.endswith('/2.root.json'))
274271
self.assertTrue(isinstance(mirror_error,
275-
securesystemslib.exceptions.BadSignatureError))
272+
securesystemslib.exceptions.BadSignatureError))
276273

277274
# Assert that the current 'root.json' on the client side is the verified one
278275
self.assertTrue(filecmp.cmp(
@@ -412,11 +409,8 @@ def test_root_rotation_missing_keys(self):
412409
self.repository_updater.refresh()
413410

414411
for mirror_url, mirror_error in six.iteritems(cm.exception.mirror_errors):
415-
url_prefix = self.repository_mirrors['mirror1']['url_prefix']
416-
url_file = os.path.join(url_prefix, 'metadata', '2.root.json')
417-
418412
# Verify that '2.root.json' is the culprit.
419-
self.assertEqual(url_file.replace('\\', '/'), mirror_url)
413+
self.assertTrue(mirror_url.endswith('/2.root.json'))
420414
self.assertTrue(isinstance(mirror_error,
421415
securesystemslib.exceptions.BadSignatureError))
422416

@@ -491,13 +485,10 @@ def test_root_rotation_unmet_last_version_threshold(self):
491485
self.repository_updater.refresh()
492486

493487
for mirror_url, mirror_error in six.iteritems(cm.exception.mirror_errors):
494-
url_prefix = self.repository_mirrors['mirror1']['url_prefix']
495-
url_file = os.path.join(url_prefix, 'metadata', '3.root.json')
496-
497488
# Verify that '2.root.json' is the culprit.
498-
self.assertEqual(url_file.replace('\\', '/'), mirror_url)
489+
self.assertTrue(mirror_url.endswith('/3.root.json'))
499490
self.assertTrue(isinstance(mirror_error,
500-
securesystemslib.exceptions.BadSignatureError))
491+
securesystemslib.exceptions.BadSignatureError))
501492

502493
# Assert that the current 'root.json' on the client side is the verified one
503494
self.assertTrue(filecmp.cmp(
@@ -541,13 +532,10 @@ def test_root_rotation_unmet_new_threshold(self):
541532
self.repository_updater.refresh()
542533

543534
for mirror_url, mirror_error in six.iteritems(cm.exception.mirror_errors):
544-
url_prefix = self.repository_mirrors['mirror1']['url_prefix']
545-
url_file = os.path.join(url_prefix, 'metadata', '3.root.json')
546-
547535
# Verify that '2.root.json' is the culprit.
548-
self.assertEqual(url_file.replace('\\', '/'), mirror_url)
536+
self.assertTrue(mirror_url.endswith('/3.root.json'))
549537
self.assertTrue(isinstance(mirror_error,
550-
securesystemslib.exceptions.BadSignatureError))
538+
securesystemslib.exceptions.BadSignatureError))
551539

552540
# Assert that the current 'root.json' on the client side is the verified one
553541
self.assertTrue(filecmp.cmp(
@@ -580,13 +568,10 @@ def test_root_rotation_discard_untrusted_version(self):
580568
self.repository_updater.refresh()
581569

582570
for mirror_url, mirror_error in six.iteritems(cm.exception.mirror_errors):
583-
url_prefix = self.repository_mirrors['mirror1']['url_prefix']
584-
url_file = os.path.join(url_prefix, 'metadata', '2.root.json')
585-
586571
# Verify that '2.root.json' is the culprit.
587-
self.assertEqual(url_file.replace('\\', '/'), mirror_url)
572+
self.assertTrue(mirror_url.endswith('/2.root.json'))
588573
self.assertTrue(isinstance(mirror_error,
589-
securesystemslib.exceptions.BadSignatureError))
574+
securesystemslib.exceptions.BadSignatureError))
590575

591576
# Assert that the current 'root.json' on the client side is the trusted one
592577
# and 2.root.json is discarded

0 commit comments

Comments
 (0)