Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions pulp_deb/tests/functional/api/test_package_signing.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

from pulpcore.client.pulp_deb.exceptions import ApiException

from pulp_deb.app.models import AptPackageSigningService
from pulp_deb.tests.functional.utils import get_local_package_absolute_path


Expand Down Expand Up @@ -62,6 +61,7 @@ def _add_package_to_repo(
def test_sign_package_on_upload(
tmp_path,
download_content_unit,
deb_check_signature,
deb_signing_key_primary,
deb_signing_key_secondary,
deb_package_signing_service,
Expand All @@ -86,7 +86,7 @@ def test_sign_package_on_upload(
tmp_path,
)
with pytest.raises(Exception, match=".*Package is unsigned.*"):
AptPackageSigningService._check_deb_signature(
deb_check_signature(
file_to_upload,
deb_signing_key_primary.fingerprint,
str(tmp_path),
Expand All @@ -113,7 +113,7 @@ def test_sign_package_on_upload(
downloaded_package.write_bytes(
download_content_unit(distribution.base_path, "pool/upload/f/frigg/frigg_1.0_ppc64.deb")
)
AptPackageSigningService._check_deb_signature(
deb_check_signature(
str(downloaded_package), fingerprint, str(tmp_path), combined_public_key
)

Expand Down Expand Up @@ -142,7 +142,7 @@ def test_sign_package_on_upload(
downloaded_package.write_bytes(
download_content_unit(distribution.base_path, "pool/upload/f/frigg/frigg_1.0_ppc64.deb")
)
AptPackageSigningService._check_deb_signature(
deb_check_signature(
str(downloaded_package),
deb_signing_key_secondary.fingerprint,
str(tmp_path),
Expand Down Expand Up @@ -211,6 +211,7 @@ def _upload_chunks(size, chunks, sha256, include_chunk_sha256=False):
def test_sign_chunked_package_on_upload(
tmp_path,
download_content_unit,
deb_check_signature,
deb_signing_key_primary,
deb_signing_key_secondary,
deb_package_signing_service,
Expand All @@ -235,7 +236,7 @@ def test_sign_chunked_package_on_upload(
tmp_path,
)
with pytest.raises(Exception, match=".*Package is unsigned.*"):
AptPackageSigningService._check_deb_signature(
deb_check_signature(
file_to_upload,
deb_signing_key_primary.fingerprint,
str(tmp_path),
Expand Down Expand Up @@ -267,7 +268,7 @@ def test_sign_chunked_package_on_upload(
downloaded_package.write_bytes(
download_content_unit(distribution.base_path, "pool/upload/f/frigg/frigg_1.0_ppc64.deb")
)
AptPackageSigningService._check_deb_signature(
deb_check_signature(
str(downloaded_package), fingerprint, str(tmp_path), combined_public_key
)

Expand All @@ -276,6 +277,7 @@ def test_signed_repo_modify(
tmp_path,
add_package_to_repo,
download_content_unit,
deb_check_signature,
deb_signing_key_primary,
deb_package_signing_service,
deb_repository_factory,
Expand All @@ -294,9 +296,7 @@ def test_signed_repo_modify(
tmp_path,
)
with pytest.raises(Exception, match=".*Package is unsigned.*"):
AptPackageSigningService._check_deb_signature(
file_to_upload, fingerprint, str(tmp_path), public_key
)
deb_check_signature(file_to_upload, fingerprint, str(tmp_path), public_key)

repository = deb_repository_factory(
package_signing_service=deb_package_signing_service.pulp_href,
Expand All @@ -314,9 +314,7 @@ def test_signed_repo_modify(
downloaded_package.write_bytes(
download_content_unit(distribution.base_path, "pool/main/f/frigg/frigg_1.0_ppc64.deb")
)
AptPackageSigningService._check_deb_signature(
str(downloaded_package), fingerprint, str(tmp_path), public_key
)
deb_check_signature(str(downloaded_package), fingerprint, str(tmp_path), public_key)

repository = apt_repository_api.read(repository.pulp_href)
signed_package = apt_package_api.list(
Expand Down Expand Up @@ -555,6 +553,7 @@ def _prefixed(fp):
def test_presigned_package_not_resigned(
tmp_path,
add_package_to_repo,
deb_check_signature,
deb_signing_key_secondary,
package_signing_script_path,
deb_package_signing_service,
Expand Down Expand Up @@ -583,7 +582,7 @@ def test_presigned_package_not_resigned(
assert result.returncode == 0, f"Signing failed: {result.stderr}"

# Verify the package is signed with key B
AptPackageSigningService._check_deb_signature(
deb_check_signature(
str(file_to_upload),
deb_signing_key_secondary.fingerprint,
str(tmp_path),
Expand Down
13 changes: 13 additions & 0 deletions pulp_deb/tests/functional/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -865,3 +865,16 @@ def deb_package_signing_service(_deb_package_signing_service_name, pulpcore_bind
return pulpcore_bindings.SigningServicesApi.list(
name=_deb_package_signing_service_name
).results[0]


@pytest.fixture(scope="session")
def deb_check_signature():
"""Return the server side deb signature check helper."""
import django

# Importing models requires a populated app registry. setup() is idempotent.
django.setup()

from pulp_deb.app.models import AptPackageSigningService

return AptPackageSigningService._check_deb_signature