This commit is contained in:
@@ -20,7 +20,7 @@ class ProductionCD(unittest.TestCase):
|
||||
self.addCleanup(temp.cleanup)
|
||||
self.root = Path(temp.name)
|
||||
self.request = dict(sha=SHA, task=TASK, bundle='b' * 64, confirm='deploy-production',
|
||||
action='deploy', approval='signed', run_id='42')
|
||||
action='deploy', run_id='42')
|
||||
self.manifest = dict(schema=1, target=cd.TARGET, sha=SHA, task=TASK, migrations=[1, 2], images={})
|
||||
for role, image in IMAGES.items():
|
||||
archive = self.root / (role + '.tar')
|
||||
@@ -94,14 +94,14 @@ class ProductionCD(unittest.TestCase):
|
||||
with self.assertRaisesRegex(cd.CDError, 'DEPLOYED_HIFOX_PENDING'):
|
||||
self.execute()
|
||||
self.assertEqual(cd.read_json(self.host.receipt_path)['state'], 'deployed_hifox_pending')
|
||||
self.request.update(action='writeback', confirm='retry-writeback', approval='')
|
||||
self.request.update(action='writeback', confirm='retry-writeback')
|
||||
self.assertEqual(self.execute()['state'], 'published')
|
||||
self.host.switch.assert_called_once()
|
||||
self.host.load.assert_called_once()
|
||||
self.assertEqual(self.host.verify.call_count, 2)
|
||||
|
||||
def test_writeback_without_receipt_refuses(self):
|
||||
self.request.update(action='writeback', confirm='retry-writeback', approval='')
|
||||
self.request.update(action='writeback', confirm='retry-writeback')
|
||||
with self.assertRaisesRegex(cd.CDError, 'receipt'):
|
||||
self.execute()
|
||||
self.assert_no_deploy()
|
||||
@@ -122,6 +122,18 @@ class ProductionCD(unittest.TestCase):
|
||||
self.execute()
|
||||
self.host.switch.assert_called_once()
|
||||
|
||||
def test_gitea_guard_log_binds_the_exact_dispatch(self):
|
||||
trusted = 'f' * 40
|
||||
proof = cd.guard_proof(self.request, trusted)
|
||||
log = f'2026-11-22T17:31:54.013Z {proof}\n'.encode()
|
||||
cd.verify_guard_log(log, self.request, trusted)
|
||||
for name, altered in (('sha', 'b' * 40), ('bundle', 'c' * 64), ('run_id', '43'),
|
||||
('task', 'd5abdf29-d0b5-4992-8073-0cb8fffd84ee2'), ('confirm', 'retry-writeback')):
|
||||
with self.subTest(name=name), self.assertRaisesRegex(cd.CDError, 'dispatch proof'):
|
||||
cd.verify_guard_log(log, {**self.request, name: altered}, trusted)
|
||||
with self.assertRaisesRegex(cd.CDError, 'dispatch proof'):
|
||||
cd.verify_guard_log(log + log, self.request, trusted)
|
||||
|
||||
def test_target_lock_is_exclusive(self):
|
||||
path = self.root / 'lock'
|
||||
with cd.deploy_lock(path):
|
||||
|
||||
Reference in New Issue
Block a user