-
Notifications
You must be signed in to change notification settings - Fork 142
Fix issues introduced by gnupg removal patch #7602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| pytest<10 | ||
| pytest-custom_exit_code | ||
| pytest-xdist | ||
| pysequoia | ||
| python-gnupg | ||
| proxy.py~=2.4.10 | ||
| trustme~=1.2.1 | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| import aiohttp | ||
| import asyncio | ||
| import gnupg | ||
| import json | ||
| import os | ||
| import pathlib | ||
|
|
@@ -1147,21 +1148,6 @@ def _sign_with_ascii_armored_detached_signing_service(filename): | |
| return _sign_with_ascii_armored_detached_signing_service | ||
|
|
||
|
|
||
| class _GpgCompat: | ||
| """Wrapper around a pysequoia Cert that provides the python-gnupg GPG interface needed by | ||
| downstream plugins (e.g. pulp_container) which access .gnupghome and .export_keys().""" | ||
|
|
||
| def __init__(self, cert, gnupghome): | ||
| self.cert = cert | ||
| self.gnupghome = gnupghome | ||
|
|
||
| def export_keys(self, keyids=None): | ||
| return str(self.cert) | ||
|
|
||
| def __str__(self): | ||
| return str(self.cert) | ||
|
|
||
|
|
||
| @pytest.fixture(scope="session") | ||
| def signing_gpg_metadata(signing_gpg_homedir_path): | ||
| """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): | |
| with suppress(FileNotFoundError, PermissionError): | ||
| key_file.write_text(private_key_data) | ||
|
|
||
| from pysequoia import Cert | ||
| gpg = gnupg.GPG(gnupghome=signing_gpg_homedir_path) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can use python-gnupg in functional tests, it's fine for now. Not worth trying to replace with layers of compat right now. |
||
| gpg.import_keys(private_key_data) | ||
|
|
||
| cert = Cert.from_bytes(private_key_data.encode()) | ||
| fingerprint = cert.fingerprint.upper() | ||
| keyid = fingerprint[-16:] | ||
|
|
||
| gpg_cmd = ["gpg", "--homedir", str(signing_gpg_homedir_path)] | ||
| subprocess.run( | ||
| gpg_cmd + ["--import"], | ||
| input=private_key_data, | ||
| capture_output=True, | ||
| text=True, | ||
| check=True, | ||
| ) | ||
| subprocess.run( | ||
| gpg_cmd + ["--import-ownertrust"], | ||
| input=f"{fingerprint}:6:\n", | ||
| capture_output=True, | ||
| text=True, | ||
| check=True, | ||
| ) | ||
| key = gpg.list_keys()[0] | ||
| fingerprint = key["fingerprint"] | ||
| keyid = key["keyid"] | ||
|
|
||
| gpg = _GpgCompat(cert, str(signing_gpg_homedir_path)) | ||
| gpg.trust_keys(fingerprint, "TRUST_ULTIMATE") | ||
| return gpg, fingerprint, keyid | ||
|
|
||
|
|
||
| @pytest.fixture(scope="session") | ||
| def pulp_trusted_public_key(signing_gpg_metadata): | ||
| """Fixture to extract the ascii armored trusted public test key.""" | ||
| gpg, _, keyid = signing_gpg_metadata | ||
| return str(gpg) | ||
| return gpg.export_keys([keyid]) | ||
|
|
||
|
|
||
| @pytest.fixture(scope="session") | ||
|
|
@@ -1223,7 +1194,7 @@ def _ascii_armored_detached_signing_service_name( | |
| signing_gpg_homedir_path, | ||
| ): | ||
| service_name = str(uuid.uuid4()) | ||
| _, fingerprint, keyid = signing_gpg_metadata | ||
| _gpg, fingerprint, _keyid = signing_gpg_metadata | ||
|
|
||
| cmd = ( | ||
| "pulpcore-manager", | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.