Skip to content

Commit 4acf777

Browse files
authored
Fix provenance sync for Pulp User publishers (#1273)
* Fix provenance sync to use Pulp's extended Provenance model Sync was validating provenance with pypi_attestations.Provenance, which rejects Pulp User publishers created during upload. Use the extended model from pulp_python.app.provenance instead.
1 parent f168ae8 commit 4acf777

3 files changed

Lines changed: 50 additions & 1 deletion

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed provenance sync failing when syncing Pulp-created attestations that use a `Pulp User` publisher.

pulp_python/app/tasks/sync.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from bandersnatch.mirror import Mirror
1010
from lxml.etree import LxmlError
1111
from packaging.requirements import Requirement
12-
from pypi_attestations import Provenance
1312
from pypi_simple import IndexPage
1413

1514
from pulpcore.plugin.download import HttpDownloader
@@ -28,6 +27,7 @@
2827
PythonPackageContent,
2928
PythonRemote,
3029
)
30+
from pulp_python.app.provenance import Provenance
3131
from pulp_python.app.utils import PYPI_LAST_SERIAL, aget_remote_simple_page, parse_metadata
3232

3333
logger = logging.getLogger(__name__)

pulp_python/tests/functional/api/test_attestations.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,54 @@ def test_attestation_sync_upload(python_bindings, twine_package, download_python
154154
assert att_bundle["publisher"]["kind"] == "Pulp User"
155155

156156

157+
@pytest.mark.parallel
158+
def test_sync_pulp_created_provenance(
159+
domain_factory,
160+
python_bindings,
161+
twine_package,
162+
python_repo_factory,
163+
python_distribution_factory,
164+
python_remote_factory,
165+
python_repo_with_sync,
166+
python_content_summary,
167+
monitor_task,
168+
):
169+
"""Test syncing provenance across domains from a Pulp upload."""
170+
source_domain = domain_factory()
171+
attestations = get_attestations(twine_package.provenance_url)
172+
source_repo = python_repo_factory(pulp_domain=source_domain.name)
173+
body = {
174+
"relative_path": twine_package.filename,
175+
"file_url": twine_package.url,
176+
"attestations": json.dumps(attestations),
177+
"repository": source_repo.pulp_href,
178+
}
179+
task = python_bindings.ContentPackagesApi.create(pulp_domain=source_domain.name, **body).task
180+
monitor_task(task)
181+
182+
source_distro = python_distribution_factory(
183+
repository=source_repo, pulp_domain=source_domain.name
184+
)
185+
dest_domain = domain_factory()
186+
remote = python_remote_factory(
187+
url=source_distro.base_url,
188+
provenance=True,
189+
includes=[f"twine=={twine_package.version}"],
190+
pulp_domain=dest_domain.name,
191+
)
192+
dest_repo = python_repo_with_sync(remote=remote, pulp_domain=dest_domain.name)
193+
194+
summary = python_content_summary(repository_version=dest_repo.latest_version_href)
195+
assert summary.present["python.provenance"]["count"] == 1
196+
197+
provs = python_bindings.ContentProvenanceApi.list(
198+
repository_version=dest_repo.latest_version_href,
199+
pulp_domain=dest_domain.name,
200+
)
201+
assert provs.count == 1
202+
assert provs.results[0].provenance["attestation_bundles"][0]["publisher"]["kind"] == "Pulp User"
203+
204+
157205
def test_attestation_twine_upload(
158206
pulpcore_bindings,
159207
python_content_summary,

0 commit comments

Comments
 (0)