diff --git a/oras/provider.py b/oras/provider.py index 8056ce4..3f31215 100644 --- a/oras/provider.py +++ b/oras/provider.py @@ -805,7 +805,10 @@ def push( # Final upload of the manifest manifest["config"] = conf - self._check_200_response(self.upload_manifest(manifest, container)) + response = self.upload_manifest( + manifest, container + ) # make the returned response from this method, the one pertaining to the uploaded Manifest + self._check_200_response(response) print(f"Successfully pushed {container}") return response diff --git a/oras/tests/test_oras.py b/oras/tests/test_oras.py index 82ebd31..d5248c2 100644 --- a/oras/tests/test_oras.py +++ b/oras/tests/test_oras.py @@ -66,6 +66,28 @@ def test_basic_push_pull(tmp_path, registry, credentials, target): assert res.status_code == 201 +@pytest.mark.with_auth(False) +def test_basic_push_pul_via_sha_ref(tmp_path, registry, credentials, target): + """ + Basic tests for oras pushing and then pulling with SHA reference + """ + client = oras.client.OrasClient(hostname=registry, insecure=True) + artifact = os.path.join(here, "artifact.txt") + + assert os.path.exists(artifact) + + res = client.push(files=[artifact], target=target) + assert res.status_code in [200, 201] + + # Test pulling elsewhere + using_ref = f"{registry}/dinosaur/artifact@{res.headers['Docker-Content-Digest']}" + files = client.pull(target=using_ref, outdir=tmp_path) + assert len(files) == 1 + assert os.path.basename(files[0]) == "artifact.txt" + assert str(tmp_path) in files[0] + assert os.path.exists(files[0]) + + @pytest.mark.with_auth(False) def test_get_delete_tags(tmp_path, registry, credentials, target): """