mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-13 22:42:29 +03: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
2 changed files with 34 additions and 2 deletions
|
@ -139,7 +139,6 @@ def main():
|
||||||
index_file = os.path.join(output_dir, json_name)
|
index_file = os.path.join(output_dir, json_name)
|
||||||
if os.path.exists(index_file):
|
if os.path.exists(index_file):
|
||||||
sign_index_v1(output_dir, json_name)
|
sign_index_v1(output_dir, json_name)
|
||||||
os.remove(index_file)
|
|
||||||
logging.info('Signed ' + index_file)
|
logging.info('Signed ' + index_file)
|
||||||
signed.append(index_file)
|
signed.append(index_file)
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,19 @@ print('localmodule: ' + localmodule)
|
||||||
if localmodule not in sys.path:
|
if localmodule not in sys.path:
|
||||||
sys.path.insert(0, localmodule)
|
sys.path.insert(0, localmodule)
|
||||||
|
|
||||||
from fdroidserver import common, signindex
|
from fdroidserver import common, signindex, update
|
||||||
from pathlib import Path
|
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):
|
class SignindexTest(unittest.TestCase):
|
||||||
|
@ -49,6 +60,7 @@ class SignindexTest(unittest.TestCase):
|
||||||
shutil.copy(str(self.basedir / 'repo/index-v1.json'), 'repo')
|
shutil.copy(str(self.basedir / 'repo/index-v1.json'), 'repo')
|
||||||
signindex.sign_index_v1(str(self.repodir), 'index-v1.json')
|
signindex.sign_index_v1(str(self.repodir), 'index-v1.json')
|
||||||
self.assertTrue((self.repodir / 'index-v1.jar').exists())
|
self.assertTrue((self.repodir / 'index-v1.jar').exists())
|
||||||
|
self.assertTrue((self.repodir / 'index-v1.json').exists())
|
||||||
|
|
||||||
def test_sign_index_v1_corrupt(self):
|
def test_sign_index_v1_corrupt(self):
|
||||||
with open('repo/index-v1.json', 'w') as fp:
|
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'):
|
with self.assertRaises(json.decoder.JSONDecodeError, msg='error on bad JSON'):
|
||||||
signindex.sign_index_v1(str(self.repodir), 'index-v1.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__":
|
if __name__ == "__main__":
|
||||||
os.chdir(os.path.dirname(__file__))
|
os.chdir(os.path.dirname(__file__))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue