index: fail if user sets mirrors:isPrimary wrong

Really, this is not meant to be set by the user in the config.  But if they
add something harmless that'll be ignored anyway, it seems that throwing an
error is too much.  So only throw the error if it is set wrongly.
This commit is contained in:
Hans-Christoph Steiner 2025-03-19 17:39:45 +01:00
parent 8e39f82eb9
commit 20569217d9
2 changed files with 24 additions and 0 deletions

View file

@ -814,6 +814,19 @@ class IndexTest(unittest.TestCase):
with self.assertRaises(fdroidserver.exception.FDroidException):
index.add_mirrors_to_repodict('repo', repodict)
def test_erroneous_isPrimary_in_mirrors_config(self):
"""There can be only one primary mirror aka canonical URL"""
common.config = {
'repo_url': 'http://one/fdroid',
'mirrors': [
{'url': 'http://one/fdroid', 'countryCode': 'SA'},
{'url': 'http://two/fdroid', 'isPrimary': True},
],
}
repodict = {'address': common.config['repo_url']}
with self.assertRaises(fdroidserver.exception.FDroidException):
index.add_mirrors_to_repodict('repo', repodict)
class AltstoreIndexTest(unittest.TestCase):
def test_make_altstore(self):