mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-13 22:42:29 +03:00
Merge branch 'invalid-apk-fix' into 'master'
Fix bug when scanning invalid APKs and add a test for it See merge request !246
This commit is contained in:
commit
d6310ed52c
2 changed files with 20 additions and 1 deletions
|
@ -793,7 +793,7 @@ def scan_apk(apkcache, apkfilename, repodir, knownapks, use_date_from_apk):
|
||||||
logging.error("Could not find {0} to remove it".format(apkfile))
|
logging.error("Could not find {0} to remove it".format(apkfile))
|
||||||
else:
|
else:
|
||||||
logging.error("Failed to get apk information, skipping " + apkfile)
|
logging.error("Failed to get apk information, skipping " + apkfile)
|
||||||
return True
|
return True, None, False
|
||||||
for line in p.output.splitlines():
|
for line in p.output.splitlines():
|
||||||
if line.startswith("package:"):
|
if line.startswith("package:"):
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -130,6 +130,25 @@ class UpdateTest(unittest.TestCase):
|
||||||
self.assertIsNone(apk.get('obbMainFile'))
|
self.assertIsNone(apk.get('obbMainFile'))
|
||||||
self.assertIsNone(apk.get('obbPatchFile'))
|
self.assertIsNone(apk.get('obbPatchFile'))
|
||||||
|
|
||||||
|
def test_scan_invalid_apk(self):
|
||||||
|
os.chdir(os.path.dirname(__file__))
|
||||||
|
if os.path.basename(os.getcwd()) != 'tests':
|
||||||
|
raise Exception('This test must be run in the "tests/" subdir')
|
||||||
|
|
||||||
|
config = dict()
|
||||||
|
fdroidserver.common.fill_config_defaults(config)
|
||||||
|
fdroidserver.common.config = config
|
||||||
|
fdroidserver.update.config = config
|
||||||
|
fdroidserver.update.options.delete_unknown = False
|
||||||
|
|
||||||
|
knownapks = fdroidserver.common.KnownApks()
|
||||||
|
apk = 'fake.ota.update_1234.zip' # this is not an APK, scanning should fail
|
||||||
|
(skip, apk, cachechanged) = fdroidserver.update.scan_apk({}, apk, 'repo', knownapks, False)
|
||||||
|
|
||||||
|
self.assertTrue(skip)
|
||||||
|
self.assertIsNone(apk)
|
||||||
|
self.assertFalse(cachechanged)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
parser = optparse.OptionParser()
|
parser = optparse.OptionParser()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue