gpg requires a short path to the socket to talk to gpg-agent

This commit is contained in:
Hans-Christoph Steiner 2025-02-13 17:53:37 +01:00
parent efda0f5d6c
commit 1694966455

View file

@ -235,11 +235,15 @@ class IntegrationTest(unittest.TestCase):
@unittest.skipUnless(shutil.which("gpg"), "requires command line gpg") @unittest.skipUnless(shutil.which("gpg"), "requires command line gpg")
def test_copy_repo_generate_java_gpg_keys_update_and_gpgsign(self): def test_copy_repo_generate_java_gpg_keys_update_and_gpgsign(self):
"""Needs tricks to make gpg-agent run in a test harness."""
self.fdroid_init_with_prebuilt_keystore() self.fdroid_init_with_prebuilt_keystore()
shutil.copytree(FILES / "repo", "repo", dirs_exist_ok=True) shutil.copytree(FILES / "repo", "repo", dirs_exist_ok=True)
for dir in ["config", "metadata", "gnupghome"]: for dir in ["config", "metadata"]:
shutil.copytree(FILES / dir, dir) shutil.copytree(FILES / dir, dir)
gnupghome = Path("gnupghome").resolve() # gpg requires a short path to the socket to talk to gpg-agent
gnupghome = (WORKSPACE / '.testfiles/gnupghome').resolve()
shutil.rmtree(gnupghome, ignore_errors=True)
shutil.copytree(FILES / "gnupghome", gnupghome)
os.chmod(gnupghome, 0o700) os.chmod(gnupghome, 0o700)
self.update_yaml( self.update_yaml(
"config.yml", "config.yml",
@ -266,6 +270,9 @@ class IntegrationTest(unittest.TestCase):
self.assertTrue(Path("repo/index-v1.jar").is_file()) self.assertTrue(Path("repo/index-v1.jar").is_file())
self.assert_run(self.fdroid_cmd + ["gpgsign", "--verbose"]) self.assert_run(self.fdroid_cmd + ["gpgsign", "--verbose"])
env = os.environ.copy()
env["GNUPGHOME"] = gnupghome
self.assert_run(['gpgconf', '--kill', 'gpg-agent'], env=env)
self.assertTrue(Path("repo/obb.mainpatch.current_1619.apk.asc").is_file()) self.assertTrue(Path("repo/obb.mainpatch.current_1619.apk.asc").is_file())
self.assertTrue( self.assertTrue(