@@ -122,20 +122,20 @@ def test_push_with_dist_perms(
122122 },
123123 )
124124
125- assert container_bindings .RepositoriesContainerPushApi .list (name = repo_name ).count == 1
125+ assert container_bindings .RepositoriesContainerApi .list (name = repo_name ).count == 1
126126 with user_creator :
127- assert container_bindings .RepositoriesContainerPushApi .list (name = repo_name ).count == 1
127+ assert container_bindings .RepositoriesContainerApi .list (name = repo_name ).count == 1
128128 with user_dist_collaborator :
129- assert container_bindings .RepositoriesContainerPushApi .list (name = repo_name ).count == 1
129+ assert container_bindings .RepositoriesContainerApi .list (name = repo_name ).count == 1
130130 with user_dist_consumer :
131- assert container_bindings .RepositoriesContainerPushApi .list (name = repo_name ).count == 1
131+ assert container_bindings .RepositoriesContainerApi .list (name = repo_name ).count == 1
132132 with user_namespace_collaborator :
133- assert container_bindings .RepositoriesContainerPushApi .list (name = repo_name ).count == 1
133+ assert container_bindings .RepositoriesContainerApi .list (name = repo_name ).count == 1
134134 with user_reader :
135- assert container_bindings .RepositoriesContainerPushApi .list (name = repo_name ).count == 1
135+ assert container_bindings .RepositoriesContainerApi .list (name = repo_name ).count == 1
136136 with user_helpless :
137137 # "{repo_name}" turns out to be a public repository
138- assert container_bindings .RepositoriesContainerPushApi .list (name = repo_name ).count == 1
138+ assert container_bindings .RepositoriesContainerApi .list (name = repo_name ).count == 1
139139
140140
141141def test_push_with_view_perms (
@@ -407,20 +407,49 @@ def test_push_to_existing_regular_repository(
407407 container_repository_factory ,
408408 local_registry ,
409409 registry_client ,
410+ container_bindings ,
410411 full_path ,
411412):
412- """
413- Test the push to an existing non-push repository.
414-
415- It should fail to create a new push repository.
416- """
417- container_repository_factory (name = "foo" )
413+ """Test that push succeeds when a container repository already exists."""
414+ repository = container_repository_factory (name = "foo" )
418415 image_path = f"{ REGISTRY_V2_REPO_PULP } :manifest_a"
419416 local_url = full_path ("foo:1.0" )
420417
421418 registry_client .pull (image_path )
422- with pytest .raises (CalledProcessError ):
423- local_registry .tag_and_push (image_path , local_url )
419+ local_registry .tag_and_push (image_path , local_url )
420+
421+ repository = container_bindings .RepositoriesContainerApi .read (repository .pulp_href )
422+ tags = container_bindings .ContentTagsApi .list (repository_version = repository .latest_version_href )
423+ assert tags .count == 1
424+
425+
426+ def test_push_to_existing_push_repository (
427+ add_to_cleanup ,
428+ container_push_repository_factory ,
429+ local_registry ,
430+ registry_client ,
431+ container_bindings ,
432+ full_path ,
433+ ):
434+ """Test that push still works when a legacy ContainerPushRepository already exists."""
435+ repo_name = "legacy/push"
436+ container_push_repository_factory (name = repo_name )
437+ image_path = f"{ REGISTRY_V2_REPO_PULP } :manifest_a"
438+ local_url = full_path (f"{ repo_name } :1.0" )
439+
440+ registry_client .pull (image_path )
441+ local_registry .tag_and_push (image_path , local_url )
442+
443+ assert container_bindings .RepositoriesContainerPushApi .list (name = repo_name ).count == 1
444+ assert container_bindings .RepositoriesContainerApi .list (name = repo_name ).count == 0
445+
446+ repository = container_bindings .RepositoriesContainerPushApi .list (name = repo_name ).results [0 ]
447+ tags = container_bindings .ContentTagsApi .list (repository_version = repository .latest_version_href )
448+ assert tags .count == 1
449+
450+ distribution = container_bindings .DistributionsContainerApi .list (name = repo_name ).results [0 ]
451+ namespace = container_bindings .PulpContainerNamespacesApi .read (distribution .namespace )
452+ add_to_cleanup (container_bindings .PulpContainerNamespacesApi , namespace .pulp_href )
424453
425454
426455class TestPushManifestList :
@@ -492,7 +521,7 @@ def test_push_manifest_list_v2s2(
492521 distribution = container_bindings .DistributionsContainerApi .list (name = "foo_v2s2" ).results [0 ]
493522 add_to_cleanup (container_bindings .DistributionsContainerApi , distribution .pulp_href )
494523
495- repo_version = container_bindings .RepositoriesContainerPushApi .read (
524+ repo_version = container_bindings .RepositoriesContainerApi .read (
496525 distribution .repository
497526 ).latest_version_href
498527
@@ -544,7 +573,7 @@ def test_push_manifest_list_oci(
544573 distribution = container_bindings .DistributionsContainerApi .list (name = "foo_oci" ).results [0 ]
545574 add_to_cleanup (container_bindings .DistributionsContainerApi , distribution .pulp_href )
546575
547- repo_version = container_bindings .RepositoriesContainerPushApi .read (
576+ repo_version = container_bindings .RepositoriesContainerApi .read (
548577 distribution .repository
549578 ).latest_version_href
550579
@@ -592,7 +621,7 @@ def test_push_empty_manifest_list(
592621 ]
593622 add_to_cleanup (container_bindings .DistributionsContainerApi , distribution .pulp_href )
594623
595- repo_version = container_bindings .RepositoriesContainerPushApi .read (
624+ repo_version = container_bindings .RepositoriesContainerApi .read (
596625 distribution .repository
597626 ).latest_version_href
598627 latest_tag = container_bindings .ContentTagsApi .list (
0 commit comments