Complete pinned Play bundle inputs and guest prerequisite delivery

This commit is contained in:
maxjivi05 committed 2026-11-03 00:04:07 -05:00
1 parent 2f6e43e3d1
commit 567ca34a48
16 files changed
+10608 -22

No files matched your search

@@ -46,6 +46,14 @@ class PlayArchivePreparationTest(unittest.TestCase):
prepare(self.source, output, self.definition)
self.assertFalse(output.exists())
def test_zstd_recompression_preserves_the_exact_original_tar_bytes(self):
original = self.root / 'original.tar.zst'
original.write_bytes(subprocess.check_output(['zstd', '-1', '-c'], input=self.content))
definition = dict(self.definition, method='zstd-to-zstd-19')
output = self.root / 'recompressed.tar.zst'
prepare(original, output, definition)
self.assertEqual(self.content, subprocess.check_output(['zstd', '-dc', str(output)]))
if __name__ == '__main__':
unittest.main()
+54
View File
@@ -0,0 +1,54 @@
from pathlib import Path
import unittest
from tools.playstore.payloads import load_manifest, validate_play_engines
ROOT = Path(__file__).resolve().parents[2]
class PlayManifestTest(unittest.TestCase):
def setUp(self):
self.manifest = load_manifest(ROOT / 'tools/playstore/components.lock.json')
self.entries = {url: entry for entry in self.manifest['entries'] for url in entry['urls']}
def test_release_inventory_satisfies_engine_and_delivery_restrictions(self):
validate_play_engines(self.manifest)
self.assertTrue(any(entry.get('delivery') == 'windows-guest' for entry in self.manifest['entries']))
for entry in self.manifest['entries']:
if entry.get('delivery') == 'windows-guest':
self.assertTrue(entry['id'].startswith('windows-'))
self.assertTrue(all(feature.startswith('windows:') for feature in entry['provides']))
def test_every_advertised_native_release_asset_is_available_with_the_same_identity(self):
def visit(value):
if isinstance(value, dict):
if 'browser_download_url' in value:
entry = self.entries[value['browser_download_url']]
self.assertEqual(value['size'], entry['size'])
if value.get('digest'):
self.assertEqual(value['digest'], 'sha256:' + entry['sha256'])
for item in value.values():
visit(item)
elif isinstance(value, list):
for item in value:
visit(item)
for entry in self.manifest['entries']:
if 'content' in entry:
visit(entry['content'])
def test_catalog_endpoints_used_by_android_and_the_guest_are_present(self):
repositories = ['The412Banner/Banners-Turnip', 'WinNative-Emu/Drivers', 'Droid-Deck/Drivers-CI']
urls = ['https://api.github.com/repos/' + repo + '/releases?per_page=15' for repo in repositories]
urls += ['https://api.github.com/repos/Droid-Deck/DroidDeck-Proton/releases?per_page=15',
'https://api.github.com/repos/Droid-Deck/DroidDeck-Proton/releases',
'https://api.github.com/repos/SteamDeckHomebrew/decky-loader/releases?per_page=30']
for url in urls:
self.assertIsInstance(self.entries[url]['content'], list)
proton = self.entries[urls[-3]]['content']
self.assertTrue(any(asset['browser_download_url'].startswith('droiddeck-bundle://')
for release in proton for asset in release['assets']))
if __name__ == '__main__':
unittest.main()
+38
View File
@@ -93,6 +93,44 @@ class PlaystorePayloadsTest(unittest.TestCase):
with self.assertRaisesRegex(ValueError, 'Missing component coverage: proton'):
self.validate()
def test_external_windows_prerequisite_requires_explicit_scope_and_pinned_source(self):
entry = dict(self.manifest['entries'][0], id='windows-vcredist', delivery='windows-guest',
provides=['windows:vcredist'], download_url='https://example.test/vcredist.exe')
self.manifest['entries'].append(entry)
entry['urls'] = ['https://example.test/vcredist.exe']
with self.assertRaisesRegex(ValueError, 'restricted to approved Windows'):
self.validate()
self.manifest['windows_guest_downloads'] = True
self.validate()
entry['provides'] = ['runtime:linux']
with self.assertRaisesRegex(ValueError, 'restricted to approved Windows'):
self.validate()
def test_external_windows_bytes_are_not_fetched_or_counted_as_bundled_payload(self):
entry = dict(self.manifest['entries'][0], id='windows-vcredist', delivery='windows-guest',
provides=['windows:vcredist'], download_url='https://example.test/vcredist.exe',
urls=['https://example.test/vcredist.exe'], sha256='b' * 64, size=5_000_000_000)
self.manifest['entries'].append(entry)
self.manifest['windows_guest_downloads'] = True
with patch.object(payloads.urllib.request, 'build_opener', side_effect=AssertionError('Unexpected network')):
index = payloads.stage(self.validate(), self.cache, self.root / 'staged')
metadata = index['entries'][entry['urls'][0]]
self.assertEqual('windows-guest', metadata['delivery'])
self.assertEqual(entry['download_url'], metadata['download_url'])
self.assertNotIn('recipe', metadata)
def test_shared_storage_chunks_preserve_distinct_component_identities(self):
first = self.manifest['entries'][0]
second = dict(first, id='second', urls=['https://example.test/second'], size=first['size'] + 7)
data = self.content + b'changed'
second['sha256'] = hashlib.sha256(data).hexdigest()
(self.cache / second['sha256']).write_bytes(data)
self.manifest['entries'].append(second)
index = payloads.stage(self.validate(), self.cache, self.root / 'staged', chunk_bytes=7, module_bytes=14)
one, two = [index['entries'][entry['urls'][0]] for entry in [first, second]]
self.assertEqual(self.chunks(one)[0], self.chunks(two)[0])
self.assertNotEqual(one['sha256'], two['sha256'])
def test_unknown_schema_and_empty_manifest_are_rejected(self):
self.manifest['schema'] = 2
with self.assertRaisesRegex(ValueError, 'schema'):
+8
View File
@@ -77,6 +77,14 @@ class PlaystoreSigningTest(unittest.TestCase):
signing.sign(self.source, self.destination, self.keystore, 'private-alias-value', self.signer)
self.assertFalse(self.destination.exists())
def test_unsigned_bundle_is_signed_without_a_second_full_bundle_copy(self):
with zipfile.ZipFile(self.source, 'w') as package:
package.writestr('base/assets/runtime', b'component payload')
with patch.object(signing, 'sanitize', side_effect=AssertionError('Unexpected full bundle copy')):
self.sign()
with zipfile.ZipFile(self.destination) as package:
self.assertEqual(b'component payload', package.read('base/assets/runtime'))
if __name__ == '__main__':
unittest.main()