mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-10-02 09:10:11 +02:00
Merge branch 'keep-index-v1.json' into 'master'
signindex: do not remove index-v1.json after signing Closes #969 See merge request fdroid/fdroidserver!1124
This commit is contained in:
commit
ddcbe23f9e
@ -139,7 +139,6 @@ def main():
|
||||
index_file = os.path.join(output_dir, json_name)
|
||||
if os.path.exists(index_file):
|
||||
sign_index_v1(output_dir, json_name)
|
||||
os.remove(index_file)
|
||||
logging.info('Signed ' + index_file)
|
||||
signed.append(index_file)
|
||||
|
||||
|
@ -17,8 +17,19 @@ print('localmodule: ' + localmodule)
|
||||
if localmodule not in sys.path:
|
||||
sys.path.insert(0, localmodule)
|
||||
|
||||
from fdroidserver import common, signindex
|
||||
from fdroidserver import common, signindex, update
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
|
||||
class Options:
|
||||
allow_disabled_algorithms = False
|
||||
clean = False
|
||||
delete_unknown = False
|
||||
nosign = False
|
||||
pretty = True
|
||||
rename_apks = False
|
||||
verbose = False
|
||||
|
||||
|
||||
class SignindexTest(unittest.TestCase):
|
||||
@ -49,6 +60,7 @@ class SignindexTest(unittest.TestCase):
|
||||
shutil.copy(str(self.basedir / 'repo/index-v1.json'), 'repo')
|
||||
signindex.sign_index_v1(str(self.repodir), 'index-v1.json')
|
||||
self.assertTrue((self.repodir / 'index-v1.jar').exists())
|
||||
self.assertTrue((self.repodir / 'index-v1.json').exists())
|
||||
|
||||
def test_sign_index_v1_corrupt(self):
|
||||
with open('repo/index-v1.json', 'w') as fp:
|
||||
@ -56,6 +68,27 @@ class SignindexTest(unittest.TestCase):
|
||||
with self.assertRaises(json.decoder.JSONDecodeError, msg='error on bad JSON'):
|
||||
signindex.sign_index_v1(str(self.repodir), 'index-v1.json')
|
||||
|
||||
def test_signindex(self):
|
||||
os.mkdir('archive')
|
||||
metadata = Path('metadata')
|
||||
metadata.mkdir()
|
||||
with (metadata / 'info.guardianproject.urzip.yml').open('w') as fp:
|
||||
fp.write('# placeholder')
|
||||
shutil.copy(str(self.basedir / 'urzip.apk'), 'repo')
|
||||
index_files = []
|
||||
for f in ('index.xml', 'index.jar', 'index-v1.json', 'index-v1.jar'):
|
||||
for section in (Path('repo'), Path('archive')):
|
||||
path = section / f
|
||||
self.assertFalse(path.exists(), '%s should not exist yet!' % path)
|
||||
index_files.append(path)
|
||||
common.options = Options
|
||||
with patch('sys.argv', ['fdroid update']):
|
||||
update.main()
|
||||
with patch('sys.argv', ['fdroid signindex', '--verbose']):
|
||||
signindex.main()
|
||||
for f in index_files:
|
||||
self.assertTrue(f.exists(), '%s should exist!' % f)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
os.chdir(os.path.dirname(__file__))
|
||||
|
Loading…
Reference in New Issue
Block a user