diff --git a/.gitignore b/.gitignore index 163bf6ab3..f925d1241 100644 --- a/.gitignore +++ b/.gitignore @@ -53,7 +53,8 @@ test/e2e/testdata/distribution/mount_fallback/docker/ # OCI Layout Files ZOT storage files for local E2E testing test/e2e/testdata/zot/ -!test/e2e/testdata/zot/command/images -!test/e2e/testdata/zot/command/blobs +!test/e2e/testdata/zot/command/images/ +!test/e2e/testdata/zot/command/artifacts/ +!test/e2e/testdata/zot/command/blobs/ !test/e2e/testdata/zot/config.json !test/e2e/testdata/zot/passwd_bcrypt \ No newline at end of file diff --git a/test/e2e/suite/command/pull.go b/test/e2e/suite/command/pull.go index 21dfce721..504171609 100644 --- a/test/e2e/suite/command/pull.go +++ b/test/e2e/suite/command/pull.go @@ -51,7 +51,7 @@ var _ = Describe("Remote registry users:", func() { pullRoot := "pulled" tempDir := PrepareTempFiles() stateKeys := append(foobar.ImageLayerStateKeys, foobar.ManifestStateKey, foobar.ImageConfigStateKey(configName)) - ORAS("pull", RegistryRef(Host, ImageRepo, foobar.Tag), "-v", "--config", configName, "-o", pullRoot). + ORAS("pull", RegistryRef(ZOTHost, ImageRepo, foobar.Tag), "-v", "--config", configName, "-o", pullRoot). MatchStatus(stateKeys, true, len(stateKeys)). WithWorkDir(tempDir).Exec() // check config @@ -67,7 +67,7 @@ var _ = Describe("Remote registry users:", func() { WithWorkDir(tempDir).Exec() } - ORAS("pull", RegistryRef(Host, ImageRepo, foobar.Tag), "-v", "-o", pullRoot, "--keep-old-files"). + ORAS("pull", RegistryRef(ZOTHost, ImageRepo, foobar.Tag), "-v", "-o", pullRoot, "--keep-old-files"). ExpectFailure(). WithDescription("fail if overwrite old files are disabled") }) @@ -76,7 +76,7 @@ var _ = Describe("Remote registry users:", func() { pullRoot := "pulled" tempDir := PrepareTempFiles() stateKeys := append(foobar.ImageLayerStateKeys, foobar.ManifestStateKey, foobar.ImageConfigStateKey(oras.MediaTypeUnknownConfig)) - ORAS("pull", RegistryRef(Host, ImageRepo, foobar.Tag), "-v", "--config", fmt.Sprintf("%s:%s", configName, "???"), "-o", pullRoot). + ORAS("pull", RegistryRef(ZOTHost, ImageRepo, foobar.Tag), "-v", "--config", fmt.Sprintf("%s:%s", configName, "???"), "-o", pullRoot). MatchStatus(stateKeys, true, len(stateKeys)). WithWorkDir(tempDir).Exec() // check config @@ -96,13 +96,13 @@ var _ = Describe("Remote registry users:", func() { foobar.ManifestStateKey), foobar.ImageReferrersStateKeys..., ) - ORAS("pull", RegistryRef(Host, ArtifactRepo, foobar.SignatureImageReferrer.Digest.String()), "-v", "--include-subject"). + ORAS("pull", RegistryRef(ZOTHost, ArtifactRepo, foobar.SignatureImageReferrer.Digest.String()), "-v", "--include-subject"). MatchStatus(stateKeys, true, len(stateKeys)). WithWorkDir(tempDir).Exec() }) It("should pull specific platform", func() { - ORAS("pull", RegistryRef(Host, ImageRepo, "multi"), "--platform", "linux/amd64", "-v", "-o", GinkgoT().TempDir()). + ORAS("pull", RegistryRef(ZOTHost, ImageRepo, "multi"), "--platform", "linux/amd64", "-v", "-o", GinkgoT().TempDir()). MatchStatus(multi_arch.LinuxAMD64StateKeys, true, len(multi_arch.LinuxAMD64StateKeys)).Exec() }) }) @@ -113,19 +113,15 @@ var _ = Describe("OCI image layout users:", func() { var ( configName = "test.config" ) - prepare := func(root string, repo string, tagOrDigest string) { - ORAS("cp", RegistryRef(Host, repo, tagOrDigest), Flags.ToLayout, LayoutRef(root, tagOrDigest), "-r").WithDescription("prepare oci layout test env").Exec() - } It("should pull all files in an image to a target folder", func() { pullRoot := "pulled" - tempDir := PrepareTempFiles() - prepare(tempDir, ArtifactRepo, foobar.Tag) + root := PrepareTempOCI(ImageRepo) stateKeys := append(foobar.ImageLayerStateKeys, foobar.ManifestStateKey, foobar.ImageConfigStateKey(configName)) - ORAS("pull", Flags.Layout, LayoutRef(tempDir, foobar.Tag), "-v", "--config", configName, "-o", pullRoot). + ORAS("pull", Flags.Layout, LayoutRef(root, foobar.Tag), "-v", "--config", configName, "-o", pullRoot). MatchStatus(stateKeys, true, len(stateKeys)). - WithWorkDir(tempDir).Exec() + WithWorkDir(root).Exec() // check config - configPath := filepath.Join(tempDir, pullRoot, configName) + configPath := filepath.Join(root, pullRoot, configName) Expect(configPath).Should(BeAnExistingFile()) f, err := os.Open(configPath) Expect(err).ShouldNot(HaveOccurred()) @@ -133,50 +129,47 @@ var _ = Describe("OCI image layout users:", func() { Eventually(gbytes.BufferReader(f)).Should(gbytes.Say("{}")) for _, f := range foobar.ImageLayerNames { // check layers - Binary("diff", filepath.Join(tempDir, "foobar", f), filepath.Join(pullRoot, f)). - WithWorkDir(tempDir).Exec() + Binary("diff", filepath.Join(root, "foobar", f), filepath.Join(pullRoot, f)). + WithWorkDir(root).Exec() } - ORAS("pull", Flags.Layout, LayoutRef(tempDir, foobar.Tag), "-v", "-o", pullRoot, "--keep-old-files"). + ORAS("pull", Flags.Layout, LayoutRef(root, foobar.Tag), "-v", "-o", pullRoot, "--keep-old-files"). ExpectFailure(). WithDescription("fail if overwrite old files are disabled") }) It("should skip config if media type does not match", func() { pullRoot := "pulled" - tempDir := PrepareTempFiles() - prepare(tempDir, ArtifactRepo, foobar.Tag) + root := PrepareTempOCI(ImageRepo) stateKeys := append(foobar.ImageLayerStateKeys, foobar.ManifestStateKey, foobar.ImageConfigStateKey(oras.MediaTypeUnknownConfig)) - ORAS("pull", Flags.Layout, LayoutRef(tempDir, foobar.Tag), "-v", "--config", fmt.Sprintf("%s:%s", configName, "???"), "-o", pullRoot). + ORAS("pull", Flags.Layout, LayoutRef(root, foobar.Tag), "-v", "--config", fmt.Sprintf("%s:%s", configName, "???"), "-o", pullRoot). MatchStatus(stateKeys, true, len(stateKeys)). - WithWorkDir(tempDir).Exec() + WithWorkDir(root).Exec() // check config Expect(filepath.Join(pullRoot, configName)).ShouldNot(BeAnExistingFile()) for _, f := range foobar.ImageLayerNames { // check layers - Binary("diff", filepath.Join(tempDir, "foobar", f), filepath.Join(pullRoot, f)). - WithWorkDir(tempDir). + Binary("diff", filepath.Join(root, "foobar", f), filepath.Join(pullRoot, f)). + WithWorkDir(root). WithDescription("should download identical file " + f).Exec() } }) It("should pull subject", func() { - tempDir := GinkgoT().TempDir() - prepare(tempDir, ArtifactRepo, foobar.Tag) + root := PrepareTempOCI(ArtifactRepo) stateKeys := append(append( foobar.ImageLayerStateKeys, foobar.ManifestStateKey), foobar.ImageReferrersStateKeys..., ) - ORAS("pull", Flags.Layout, LayoutRef(tempDir, foobar.SignatureImageReferrer.Digest.String()), "-v", "--include-subject"). + ORAS("pull", Flags.Layout, LayoutRef(root, foobar.SignatureImageReferrer.Digest.String()), "-v", "--include-subject"). MatchStatus(stateKeys, true, len(stateKeys)). - WithWorkDir(tempDir).Exec() + WithWorkDir(root).Exec() }) It("should pull specific platform", func() { - tempDir := GinkgoT().TempDir() - prepare(tempDir, ImageRepo, multi_arch.Tag) - ORAS("pull", Flags.Layout, LayoutRef(tempDir, multi_arch.Tag), "--platform", "linux/amd64", "-v", "-o", tempDir). + root := PrepareTempOCI(ImageRepo) + ORAS("pull", Flags.Layout, LayoutRef(root, multi_arch.Tag), "--platform", "linux/amd64", "-v", "-o", root). MatchStatus(multi_arch.LinuxAMD64StateKeys, true, len(multi_arch.LinuxAMD64StateKeys)).Exec() }) }) diff --git a/test/e2e/testdata/zot/command/artifacts/blobs/sha256/0e007dcb9ded7f49c4dc8e3eed4a446712eb6fdf08a665a4f2352d6d2f8bdf17 b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/0e007dcb9ded7f49c4dc8e3eed4a446712eb6fdf08a665a4f2352d6d2f8bdf17 new file mode 100644 index 000000000..a51f76dac --- /dev/null +++ b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/0e007dcb9ded7f49c4dc8e3eed4a446712eb6fdf08a665a4f2352d6d2f8bdf17 @@ -0,0 +1 @@ +{"schemaVersion":2,"mediaType":"application/vnd.oci.image.manifest.v1+json","config":{"mediaType":"test.signature.file","digest":"sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a","size":2},"layers":[{"mediaType":"application/vnd.oci.image.layer.v1.tar","digest":"sha256:ae2d56717c9334fdc5fdb1888b9351d80f6f5458dca9d3abef6560e7be255a3d","size":16,"annotations":{"org.opencontainers.image.title":"signature"}}],"subject":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:32b78bd00723cd7d5251d4586f84d252530b7b5fe1c4104532767e6da4e04e47","size":660},"annotations":{"org.opencontainers.image.created":"2023-01-18T08:37:57Z"}} \ No newline at end of file diff --git a/test/e2e/testdata/zot/command/artifacts/blobs/sha256/2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae new file mode 100644 index 000000000..191028156 --- /dev/null +++ b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae @@ -0,0 +1 @@ +foo \ No newline at end of file diff --git a/test/e2e/testdata/zot/command/artifacts/blobs/sha256/32b78bd00723cd7d5251d4586f84d252530b7b5fe1c4104532767e6da4e04e47 b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/32b78bd00723cd7d5251d4586f84d252530b7b5fe1c4104532767e6da4e04e47 new file mode 100644 index 000000000..73ffd55d3 --- /dev/null +++ b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/32b78bd00723cd7d5251d4586f84d252530b7b5fe1c4104532767e6da4e04e47 @@ -0,0 +1 @@ +{"schemaVersion":2,"mediaType":"application/vnd.oci.image.manifest.v1+json","config":{"mediaType":"test.sbom.file","digest":"sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a","size":2},"layers":[{"mediaType":"application/vnd.oci.image.layer.v1.tar","digest":"sha256:f5d51c0823fc419652bb6beb40e8175760dbb8615d2f815a6ca5239c901c6b38","size":11,"annotations":{"org.opencontainers.image.title":"sbom"}}],"subject":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:fd6ed2f36b5465244d5dc86cb4e7df0ab8a9d24adc57825099f522fe009a22bb","size":851},"annotations":{"org.opencontainers.image.created":"2023-01-18T08:37:42Z"}} \ No newline at end of file diff --git a/test/e2e/testdata/zot/command/artifacts/blobs/sha256/44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a new file mode 100644 index 000000000..9e26dfeeb --- /dev/null +++ b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/test/e2e/testdata/zot/command/artifacts/blobs/sha256/ae2d56717c9334fdc5fdb1888b9351d80f6f5458dca9d3abef6560e7be255a3d b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/ae2d56717c9334fdc5fdb1888b9351d80f6f5458dca9d3abef6560e7be255a3d new file mode 100644 index 000000000..c180babc7 --- /dev/null +++ b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/ae2d56717c9334fdc5fdb1888b9351d80f6f5458dca9d3abef6560e7be255a3d @@ -0,0 +1 @@ +mocked signature \ No newline at end of file diff --git a/test/e2e/testdata/zot/command/artifacts/blobs/sha256/f5d51c0823fc419652bb6beb40e8175760dbb8615d2f815a6ca5239c901c6b38 b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/f5d51c0823fc419652bb6beb40e8175760dbb8615d2f815a6ca5239c901c6b38 new file mode 100644 index 000000000..68b8080ee --- /dev/null +++ b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/f5d51c0823fc419652bb6beb40e8175760dbb8615d2f815a6ca5239c901c6b38 @@ -0,0 +1 @@ +mocked sbom \ No newline at end of file diff --git a/test/e2e/testdata/zot/command/artifacts/blobs/sha256/fcde2b2edba56bf408601fb721fe9b5c338d10ee429ea04fae5511b68fbf8fb9 b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/fcde2b2edba56bf408601fb721fe9b5c338d10ee429ea04fae5511b68fbf8fb9 new file mode 100644 index 000000000..ba0e162e1 --- /dev/null +++ b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/fcde2b2edba56bf408601fb721fe9b5c338d10ee429ea04fae5511b68fbf8fb9 @@ -0,0 +1 @@ +bar \ No newline at end of file diff --git a/test/e2e/testdata/zot/command/artifacts/blobs/sha256/fd6ed2f36b5465244d5dc86cb4e7df0ab8a9d24adc57825099f522fe009a22bb b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/fd6ed2f36b5465244d5dc86cb4e7df0ab8a9d24adc57825099f522fe009a22bb new file mode 100644 index 000000000..0ddf954a1 --- /dev/null +++ b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/fd6ed2f36b5465244d5dc86cb4e7df0ab8a9d24adc57825099f522fe009a22bb @@ -0,0 +1 @@ +{"schemaVersion":2,"mediaType":"application/vnd.oci.image.manifest.v1+json","config":{"mediaType":"application/vnd.unknown.config.v1+json","digest":"sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a","size":2},"layers":[{"mediaType":"application/vnd.oci.image.layer.v1.tar","digest":"sha256:2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae","size":3,"annotations":{"org.opencontainers.image.title":"foo1"}},{"mediaType":"application/vnd.oci.image.layer.v1.tar","digest":"sha256:2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae","size":3,"annotations":{"org.opencontainers.image.title":"foo2"}},{"mediaType":"application/vnd.oci.image.layer.v1.tar","digest":"sha256:fcde2b2edba56bf408601fb721fe9b5c338d10ee429ea04fae5511b68fbf8fb9","size":3,"annotations":{"org.opencontainers.image.title":"bar"}}]} \ No newline at end of file diff --git a/test/e2e/testdata/zot/command/artifacts/index.json b/test/e2e/testdata/zot/command/artifacts/index.json new file mode 100644 index 000000000..e1a345312 --- /dev/null +++ b/test/e2e/testdata/zot/command/artifacts/index.json @@ -0,0 +1,23 @@ +{ + "schemaVersion": 2, + "manifests": [ + { + "mediaType": "application/vnd.oci.image.manifest.v1+json", + "digest": "sha256:fd6ed2f36b5465244d5dc86cb4e7df0ab8a9d24adc57825099f522fe009a22bb", + "size": 851, + "annotations": { + "org.opencontainers.image.ref.name": "foobar" + } + }, + { + "mediaType": "application/vnd.oci.image.manifest.v1+json", + "digest": "sha256:32b78bd00723cd7d5251d4586f84d252530b7b5fe1c4104532767e6da4e04e47", + "size": 660 + }, + { + "mediaType": "application/vnd.oci.image.manifest.v1+json", + "digest": "sha256:0e007dcb9ded7f49c4dc8e3eed4a446712eb6fdf08a665a4f2352d6d2f8bdf17", + "size": 670 + } + ] +} \ No newline at end of file diff --git a/test/e2e/testdata/zot/command/artifacts/oci-layout b/test/e2e/testdata/zot/command/artifacts/oci-layout new file mode 100644 index 000000000..1343d370f --- /dev/null +++ b/test/e2e/testdata/zot/command/artifacts/oci-layout @@ -0,0 +1 @@ +{"imageLayoutVersion":"1.0.0"} \ No newline at end of file