mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-04 14:30:30 +03:00
test_sdk_exists to be based on apksigner, that's the requirement
Before, lots of pieces of the Android SDK were required for fdroidserver to operate, like aapt, zipalign, etc. Now, apksigner is the only requirement. %"support APK Signature v2+" !889
This commit is contained in:
parent
b470ad2a6f
commit
3757add164
2 changed files with 82 additions and 7 deletions
|
|
@ -2051,6 +2051,75 @@ class CommonTest(unittest.TestCase):
|
|||
config = fdroidserver.common.read_config(fdroidserver.common.options)
|
||||
self.assertEqual('/usr/lib/jvm/java-8-openjdk', config.get('java_paths', {}).get('8'))
|
||||
|
||||
@mock.patch.dict(os.environ, {'PATH': os.getenv('PATH')}, clear=True)
|
||||
def test_test_sdk_exists_fails_on_bad_sdk_path(self):
|
||||
config = {'sdk_path': 'nothinghere'}
|
||||
self.assertFalse(fdroidserver.common.test_sdk_exists(config))
|
||||
|
||||
@mock.patch.dict(os.environ, {'PATH': os.getenv('PATH')}, clear=True)
|
||||
def test_test_sdk_exists_fails_on_empty(self):
|
||||
self.assertFalse(fdroidserver.common.test_sdk_exists(dict()))
|
||||
|
||||
@mock.patch.dict(os.environ, {'PATH': os.getenv('PATH')}, clear=True)
|
||||
def test_test_sdk_exists_fails_on_non_existent(self):
|
||||
config = {'sdk_path': os.path.join(self.testdir, 'non_existent')}
|
||||
self.assertFalse(fdroidserver.common.test_sdk_exists(config))
|
||||
|
||||
@mock.patch.dict(os.environ, {'PATH': os.getenv('PATH')}, clear=True)
|
||||
def test_test_sdk_exists_fails_on_file(self):
|
||||
f = os.path.join(self.testdir, 'testfile')
|
||||
open(f, 'w').close()
|
||||
config = {'sdk_path': f}
|
||||
self.assertFalse(fdroidserver.common.test_sdk_exists(config))
|
||||
|
||||
@mock.patch.dict(os.environ, {'PATH': '/nonexistent'}, clear=True)
|
||||
def test_test_sdk_exists_valid_apksigner_in_config(self):
|
||||
apksigner = os.path.join(
|
||||
self.testdir,
|
||||
'build-tools',
|
||||
fdroidserver.common.MINIMUM_APKSIGNER_BUILD_TOOLS_VERSION,
|
||||
'apksigner',
|
||||
)
|
||||
os.makedirs(os.path.dirname(apksigner))
|
||||
with open(apksigner, 'w') as fp:
|
||||
fp.write('#!/bin/sh\ndate\n')
|
||||
os.chmod(apksigner, 0o0755)
|
||||
config = {'apksigner': apksigner}
|
||||
self.assertTrue(fdroidserver.common.test_sdk_exists(config))
|
||||
|
||||
@mock.patch.dict(os.environ, {'PATH': '/nonexistent'}, clear=True)
|
||||
def test_test_sdk_exists_old_apksigner_in_config(self):
|
||||
apksigner = os.path.join(self.testdir, 'build-tools', '28.0.0', 'apksigner')
|
||||
os.makedirs(os.path.dirname(apksigner))
|
||||
with open(apksigner, 'w') as fp:
|
||||
fp.write('#!/bin/sh\ndate\n')
|
||||
os.chmod(apksigner, 0o0755)
|
||||
config = {'apksigner': apksigner}
|
||||
self.assertFalse(fdroidserver.common.test_sdk_exists(config))
|
||||
|
||||
@mock.patch.dict(os.environ, {'PATH': '/nonexistent'}, clear=True)
|
||||
def test_test_sdk_exists_with_valid_apksigner(self):
|
||||
apksigner = (
|
||||
Path(self.testdir)
|
||||
/ 'build-tools'
|
||||
/ fdroidserver.common.MINIMUM_APKSIGNER_BUILD_TOOLS_VERSION
|
||||
/ 'apksigner'
|
||||
)
|
||||
apksigner.parent.mkdir(parents=True)
|
||||
apksigner.write_text('#!/bin/sh\ndate\n')
|
||||
apksigner.chmod(0o0755)
|
||||
config = {'sdk_path': self.testdir}
|
||||
self.assertTrue(fdroidserver.common.test_sdk_exists(config))
|
||||
|
||||
@mock.patch.dict(os.environ, {'PATH': '/nonexistent'}, clear=True)
|
||||
def test_test_sdk_exists_with_old_apksigner(self):
|
||||
apksigner = Path(self.testdir) / 'build-tools' / '17.0.0' / 'apksigner'
|
||||
apksigner.parent.mkdir(parents=True)
|
||||
apksigner.write_text('#!/bin/sh\ndate\n')
|
||||
apksigner.chmod(0o0755)
|
||||
config = {'sdk_path': self.testdir}
|
||||
self.assertFalse(fdroidserver.common.test_sdk_exists(config))
|
||||
|
||||
def test_loading_config_buildserver_yml(self):
|
||||
"""Smoke check to make sure this file is properly parsed"""
|
||||
os.chdir(self.tmpdir)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue