Skip to content

Commit 738b825

Browse files
committed
Restore python-gnupg to functional tests only
Not worth trying to replace this fixture like-for-like
1 parent 537e653 commit 738b825

File tree

2 files changed

+9
-39
lines changed

2 files changed

+9
-39
lines changed

functest_requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pytest<10
22
pytest-custom_exit_code
33
pytest-xdist
4-
pysequoia
4+
python-gnupg
55
proxy.py~=2.4.10
66
trustme~=1.2.1
77

pulpcore/pytest_plugin.py

Lines changed: 8 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import aiohttp
22
import asyncio
3+
import gnupg
34
import json
45
import os
56
import pathlib
@@ -1147,21 +1148,6 @@ def _sign_with_ascii_armored_detached_signing_service(filename):
11471148
return _sign_with_ascii_armored_detached_signing_service
11481149

11491150

1150-
class _GpgCompat:
1151-
"""Wrapper around a pysequoia Cert that provides the python-gnupg GPG interface needed by
1152-
downstream plugins (e.g. pulp_container) which access .gnupghome and .export_keys()."""
1153-
1154-
def __init__(self, cert, gnupghome):
1155-
self.cert = cert
1156-
self.gnupghome = gnupghome
1157-
1158-
def export_keys(self, keyids=None):
1159-
return str(self.cert)
1160-
1161-
def __str__(self):
1162-
return str(self.cert)
1163-
1164-
11651151
@pytest.fixture(scope="session")
11661152
def signing_gpg_metadata(signing_gpg_homedir_path):
11671153
"""A fixture that returns a GPG instance and related metadata (i.e., fingerprint, keyid)."""
@@ -1177,37 +1163,21 @@ def signing_gpg_metadata(signing_gpg_homedir_path):
11771163
with suppress(FileNotFoundError, PermissionError):
11781164
key_file.write_text(private_key_data)
11791165

1180-
from pysequoia import Cert
1166+
gpg = gnupg.GPG(gnupghome=signing_gpg_homedir_path)
1167+
gpg.import_keys(private_key_data)
11811168

1182-
cert = Cert.from_bytes(private_key_data.encode())
1183-
fingerprint = cert.fingerprint.upper()
1184-
keyid = fingerprint[-16:]
1185-
1186-
gpg_cmd = ["gpg", "--homedir", str(signing_gpg_homedir_path)]
1187-
subprocess.run(
1188-
gpg_cmd + ["--import"],
1189-
input=private_key_data,
1190-
capture_output=True,
1191-
text=True,
1192-
check=True,
1193-
)
1194-
subprocess.run(
1195-
gpg_cmd + ["--import-ownertrust"],
1196-
input=f"{fingerprint}:6:\n",
1197-
capture_output=True,
1198-
text=True,
1199-
check=True,
1200-
)
1169+
fingerprint = gpg.list_keys()[0]["fingerprint"]
1170+
keyid = gpg.list_keys()[0]["keyid"]
12011171

1202-
gpg = _GpgCompat(cert, str(signing_gpg_homedir_path))
1172+
gpg.trust_keys(fingerprint, "TRUST_ULTIMATE")
12031173
return gpg, fingerprint, keyid
12041174

12051175

12061176
@pytest.fixture(scope="session")
12071177
def pulp_trusted_public_key(signing_gpg_metadata):
12081178
"""Fixture to extract the ascii armored trusted public test key."""
12091179
gpg, _, keyid = signing_gpg_metadata
1210-
return str(gpg)
1180+
return gpg.export_keys([keyid])
12111181

12121182

12131183
@pytest.fixture(scope="session")
@@ -1223,7 +1193,7 @@ def _ascii_armored_detached_signing_service_name(
12231193
signing_gpg_homedir_path,
12241194
):
12251195
service_name = str(uuid.uuid4())
1226-
_, fingerprint, keyid = signing_gpg_metadata
1196+
_gpg, fingerprint, _keyid = signing_gpg_metadata
12271197

12281198
cmd = (
12291199
"pulpcore-manager",

0 commit comments

Comments
 (0)