From 893e724630621b31953981eb5c5a705acdc5d336 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Degros?= Date: Mon, 3 Aug 2026 15:06:53 +1000 Subject: [PATCH] Isolate GPG integration testing environment Use a temporary directory under GNUPGHOME to prevent contaminating or relying on the host's global keyring during integration testing. Ensure the background gpg-agent is terminated and the directory is cleaned up afterwards. --- tests/test.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/tests/test.py b/tests/test.py index 689e977..adcdc38 100755 --- a/tests/test.py +++ b/tests/test.py @@ -2802,7 +2802,11 @@ def TestFuseErrors(): LogError("Missing a/b/d/file2 in multi-archive mount") +gpg_home = None if has_gpg: + gpg_home = tempfile.TemporaryDirectory() + os.environ['GNUPGHOME'] = gpg_home.name + env['GNUPGHOME'] = gpg_home.name b = b' BLOCK' k = b' KEY' p = b' PGP' @@ -2834,11 +2838,14 @@ try: TestFilteredZip() TestFilteredOpaque() finally: - if has_gpg: - subprocess.run([ - 'gpg', '--batch', '--yes', '--delete-secret-and-public-key', - '7D74961702BCAD35D591BB896EC5AAD2CC5FEC0E' - ]) + if gpg_home: + try: + subprocess.run(['gpgconf', '--kill', 'gpg-agent'], check=False) + except FileNotFoundError: + pass + gpg_home.cleanup() + os.environ.pop('GNUPGHOME', None) + env.pop('GNUPGHOME', None) TestHardlinks() TestHardlinks(['-o', 'nocache'])