22import hashlib
33import shutil
44import uuid
5- from importlib_resources import files
65
76from pulp_deb .app .models import AptPackageSigningService
87import requests
98from pulp_deb .tests .functional .utils import get_local_package_absolute_path
109import pytest
1110
11+
1212@pytest .mark .parallel
1313def test_register_rpm_package_signing_service (deb_package_signing_service ):
1414 """
1515 Register a sample rpmsign-based signing service and validate it works.
1616 """
1717 service = deb_package_signing_service
1818 assert "/api/v3/signing-services/" in service .pulp_href
19-
19+
20+
2021@dataclass
2122class GPGMetadata :
2223 pubkey : str
@@ -45,7 +46,8 @@ def signing_gpg_extra(signing_gpg_metadata):
4546 GPGMetadata (pubkey_a , fingerprint_a , fingerprint_a [- 8 :]),
4647 GPGMetadata (pubkey_b , fingerprint_b , fingerprint_b [- 8 :]),
4748 )
48-
49+
50+
4951@pytest .mark .parallel
5052def test_sign_package_on_upload (
5153 tmp_path ,
@@ -73,7 +75,9 @@ def test_sign_package_on_upload(
7375 tmp_path ,
7476 )
7577 with pytest .raises (Exception , match = "No such file or directory:.*" ):
76- AptPackageSigningService ._validate_deb_package (file_to_upload , gpg_metadata_a .fingerprint , str (tmp_path ), gpg )
78+ AptPackageSigningService ._validate_deb_package (
79+ file_to_upload , gpg_metadata_a .fingerprint , str (tmp_path ), gpg
80+ )
7781
7882 # Upload Package to Repository
7983 # The same file is uploaded, but signed with different keys each time
@@ -95,44 +99,38 @@ def test_sign_package_on_upload(
9599 downloaded_package .write_bytes (
96100 download_content_unit (distribution .base_path , "pool/upload/f/frigg/frigg_1.0_ppc64.deb" )
97101 )
98- AptPackageSigningService ._validate_deb_package (str (downloaded_package ), fingerprint , str (tmp_path ), gpg )
99-
102+ AptPackageSigningService ._validate_deb_package (
103+ str (downloaded_package ), fingerprint , str (tmp_path ), gpg
104+ )
105+
100106 # Test release override
101107 repository = deb_repository_factory (
102108 package_signing_service = deb_package_signing_service .pulp_href ,
103109 package_signing_fingerprint = gpg_metadata_a .fingerprint ,
104- package_signing_fingerprint_release_overrides = {"test" : gpg_metadata_b .fingerprint }
105- )
106-
107- deb_release_factory (
108- "test" , "test" , "test" , repository = repository .pulp_href
109- )
110- deb_release_factory (
111- "test2" , "test2" , "test2" , repository = repository .pulp_href
110+ package_signing_fingerprint_release_overrides = {"test" : gpg_metadata_b .fingerprint },
112111 )
113-
112+
113+ deb_release_factory ("test" , "test" , "test" , repository = repository .pulp_href )
114+ deb_release_factory ("test2" , "test2" , "test2" , repository = repository .pulp_href )
115+
114116 deb_package_factory (
115117 file = file_to_upload ,
116118 repository = repository .pulp_href ,
117119 distribution = "test" ,
118120 )
119- # uncommenting this line causes a failure since it overrides the existing package with a version signed with fingerprint_a
120- # deb_package_factory(
121- # file=file_to_upload,
122- # repository=repository.pulp_href,
123- # distribution="test2",
124- # )
125-
121+
126122 # Verify that the final served package is signed
127123 publication = deb_publication_factory (repository )
128124 distribution = deb_distribution_factory (publication = publication )
129125 downloaded_package = tmp_path / "package.deb"
130126 downloaded_package .write_bytes (
131127 download_content_unit (distribution .base_path , "pool/upload/f/frigg/frigg_1.0_ppc64.deb" )
132128 )
133- AptPackageSigningService ._validate_deb_package (str (downloaded_package ), gpg_metadata_b .fingerprint , str (tmp_path ), gpg )
134-
135-
129+ AptPackageSigningService ._validate_deb_package (
130+ str (downloaded_package ), gpg_metadata_b .fingerprint , str (tmp_path ), gpg
131+ )
132+
133+
136134@pytest .fixture
137135def pulpcore_chunked_file_factory (tmp_path ):
138136 """Returns a function to create chunks from file to be uploaded."""
@@ -189,7 +187,8 @@ def _upload_chunks(size, chunks, sha256, include_chunk_sha256=False):
189187 return upload
190188
191189 yield _upload_chunks
192-
190+
191+
193192def test_sign_chunked_package_on_upload (
194193 tmp_path ,
195194 download_content_unit ,
@@ -217,7 +216,9 @@ def test_sign_chunked_package_on_upload(
217216 tmp_path ,
218217 )
219218 with pytest .raises (Exception , match = "No such file or directory:.*" ):
220- AptPackageSigningService ._validate_deb_package (file_to_upload , gpg_metadata_a .fingerprint , str (tmp_path ), gpg )
219+ AptPackageSigningService ._validate_deb_package (
220+ file_to_upload , gpg_metadata_a .fingerprint , str (tmp_path ), gpg
221+ )
221222
222223 # Upload Package to Repository
223224 # The same file is uploaded, but signed with different keys each time
@@ -244,4 +245,6 @@ def test_sign_chunked_package_on_upload(
244245 downloaded_package .write_bytes (
245246 download_content_unit (distribution .base_path , "pool/upload/f/frigg/frigg_1.0_ppc64.deb" )
246247 )
247- AptPackageSigningService ._validate_deb_package (str (downloaded_package ), fingerprint , str (tmp_path ), gpg )
248+ AptPackageSigningService ._validate_deb_package (
249+ str (downloaded_package ), fingerprint , str (tmp_path ), gpg
250+ )
0 commit comments