From 14c86479099a4510d650f7392f569f70baab7a91 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Tue, 7 May 2024 10:57:55 +0200 Subject: [PATCH] add additional tests --- tests/lint.TestCase | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/lint.TestCase b/tests/lint.TestCase index e8e1efba..e5a0bd75 100755 --- a/tests/lint.TestCase +++ b/tests/lint.TestCase @@ -438,6 +438,32 @@ class LintTest(unittest.TestCase): with self.assertRaises(TypeError): fdroidserver.lint.lint_config('mirrors.yml') + def test_check_certificate_pinned_binaries_empty(self): + fdroidserver.common.config = {} + app = fdroidserver.metadata.App() + app.AllowedAPKSigningKeys = [ + 'a40da80a59d170caa950cf15c18c454d47a39b26989d8b640ecd745ba71bf5dc' + ] + self.assertEqual( + [], + list(fdroidserver.lint.check_certificate_pinned_binaries(app)), + "when the config is empty, any signing key should be allowed", + ) + + def test_lint_known_debug_keys_no_match(self): + fdroidserver.common.config = { + "apk_signing_key_block_list": "a40da80a59d170caa950cf15c18c454d47a39b26989d8b640ecd745ba71bf5dc" + } + app = fdroidserver.metadata.App() + app.AllowedAPKSigningKeys = [ + '2fd4fd5f54babba4bcb21237809bb653361d0d2583c80964ec89b28a26e9539e' + ] + self.assertEqual( + [], + list(fdroidserver.lint.check_certificate_pinned_binaries(app)), + "A signing key that does not match one in the config should be allowed", + ) + def test_lint_known_debug_keys(self): config = dict() fdroidserver.common.fill_config_defaults(config)