mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-20 13:26:02 +00:00
fix(components): an origin APK without a newer preload output still proves the rest
This commit is contained in:
1 parent
ddf3985cb5
commit
9003ed14c0
2 files changed
+26
-1
No files matched your search
@@ -150,6 +150,30 @@ class PreloadSnapshotTest(unittest.TestCase):
|
||||
with self.assertRaisesRegex(ValueError, 'successful main'):
|
||||
snapshots.artifact_bytes(self.data['origin'], self.root / 'cache')
|
||||
|
||||
def test_origin_apk_without_a_newer_output_reads_the_rest(self):
|
||||
from zipfile import ZipFile
|
||||
newest = 'libddnatv-hook.so'
|
||||
apk = io.BytesIO()
|
||||
with ZipFile(apk, 'w') as z:
|
||||
for name, value in self.binaries.items():
|
||||
if name != newest:
|
||||
z.writestr('assets/linuxfs/' + name, value)
|
||||
outer = io.BytesIO()
|
||||
with ZipFile(outer, 'w') as z:
|
||||
z.writestr('app-release.apk', apk.getvalue())
|
||||
digest = snapshots.sha(outer.getvalue())
|
||||
origin = dict(self.data['origin'], artifact_sha256=digest)
|
||||
build = dict(event='push', head_branch='main', conclusion='success', head_sha=origin['commit'],
|
||||
path='.github/workflows/build.yml', repository=dict(full_name=snapshots.REPO))
|
||||
artifact = dict(name='droiddeck-apk', workflow_run=dict(id=origin['run']), digest='sha256:' + digest)
|
||||
cache = self.root / 'cache'
|
||||
cache.mkdir()
|
||||
(cache / (digest + '.zip')).write_bytes(outer.getvalue())
|
||||
with patch.object(snapshots, 'api', side_effect=[build, artifact]):
|
||||
content = snapshots.artifact_bytes(origin, cache)
|
||||
self.assertNotIn(newest, content)
|
||||
self.assertEqual(set(content), snapshots.FILES - {newest})
|
||||
|
||||
def test_corrupt_archive_is_rejected(self):
|
||||
with self.assertRaisesRegex(ValueError, 'checksum'):
|
||||
snapshots.unpack(self.content + b'tampered', self.data)
|
||||
|
||||
Reference in new issue
Block a user