Don't copy per version anti features to all versions

make_v0() modified the apps data structure to copy an anti feature for a
specific version to all versions resulting in index-v1 and -v2 to
contain wrong anti feature annotations. This patch fixes this and adds a
test that the data structure is no longer modified.

The bug shadowed bugs in the AF implementation of -v1 and -v2 resulting
in not coping the version specific data. This is corrected as well.
This is also tested now.

For -v2 the AF dict is now sorted to make the result reproducible.

Finally The NoSourceSince AF was added as a per version and overall AF
in -v1 and is now only applied as an overall AF and the test is updated
accordingly.
This commit is contained in:
Jochen Sprickerhof 2023-03-31 13:18:37 +02:00 committed by Hans-Christoph Steiner
parent 484f289919
commit 889b8cb372
10 changed files with 63 additions and 67 deletions

View file

@ -1,5 +1,6 @@
#!/usr/bin/env python3
import copy
import datetime
import inspect
import logging
@ -425,6 +426,7 @@ class IndexTest(unittest.TestCase):
app['icon'] = 'info.zwanenburg.caffeinetile.4.xml'
app['CurrentVersionCode'] = 4
apps = {app.id: app}
orig_apps = copy.deepcopy(apps)
apk = {
'hash': 'dbbdd7deadb038862f426b71efe4a64df8c3edf25d669e935f349510e16f65db',
'hashType': 'sha256',
@ -436,7 +438,7 @@ class IndexTest(unittest.TestCase):
'-1': 'res/drawable/ic_coffee_on.xml',
},
'icons': {'160': 'info.zwanenburg.caffeinetile.4.xml'},
'antiFeatures': [],
'antiFeatures': ['KnownVuln'],
'packageName': 'info.zwanenburg.caffeinetile',
'versionCode': 4,
'name': 'Caffeine Tile',
@ -463,6 +465,7 @@ class IndexTest(unittest.TestCase):
)
)
self.assertTrue(os.path.exists(os.path.join('repo', 'index.xml')))
self.assertEqual(orig_apps, apps, "apps was modified when building the index")
def test_v0_invalid_config_exception(self):
"""Index v0 needs additional config values when using --nosign