Skip to content

Commit 3db46f2

Browse files
committed
Fix issues introduced by removing python-gnupg
Restore python-gnupg to functional tests only - not worth trying to replace this fixture like-for-like Fix an issue with inlined signatures. We should only parse the sig separately in the detached case. (cherry picked from commit ac64ff3)
1 parent 0ae8327 commit 3db46f2

File tree

3 files changed

+11
-40
lines changed

3 files changed

+11
-40
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/app/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,8 @@ def store(key_ids):
439439
sig_data = signature.read()
440440

441441
try:
442-
sig = Sig.from_bytes(sig_data)
443442
if detached_data is not None:
443+
sig = Sig.from_bytes(sig_data)
444444
result = verify(file=detached_data, store=store, signature=sig)
445445
else:
446446
result = verify(bytes=sig_data, store=store)

pulpcore/pytest_plugin.py

Lines changed: 9 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,22 @@ 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+
key = gpg.list_keys()[0]
1170+
fingerprint = key["fingerprint"]
1171+
keyid = key["keyid"]
12011172

1202-
gpg = _GpgCompat(cert, str(signing_gpg_homedir_path))
1173+
gpg.trust_keys(fingerprint, "TRUST_ULTIMATE")
12031174
return gpg, fingerprint, keyid
12041175

12051176

12061177
@pytest.fixture(scope="session")
12071178
def pulp_trusted_public_key(signing_gpg_metadata):
12081179
"""Fixture to extract the ascii armored trusted public test key."""
12091180
gpg, _, keyid = signing_gpg_metadata
1210-
return str(gpg)
1181+
return gpg.export_keys([keyid])
12111182

12121183

12131184
@pytest.fixture(scope="session")
@@ -1223,7 +1194,7 @@ def _ascii_armored_detached_signing_service_name(
12231194
signing_gpg_homedir_path,
12241195
):
12251196
service_name = str(uuid.uuid4())
1226-
_, fingerprint, keyid = signing_gpg_metadata
1197+
_gpg, fingerprint, _keyid = signing_gpg_metadata
12271198

12281199
cmd = (
12291200
"pulpcore-manager",

0 commit comments

Comments
 (0)