From d69c778779ee6dfed2297ffa70c50245f4d752e6 Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Fri, 1 Sep 2023 11:08:47 +0800 Subject: [PATCH] test(e2e): cover pulling test for image spec 1.1.0-rc.2 artifact (#1098) Signed-off-by: Billy Zha --- test/e2e/suite/command/pull.go | 40 ++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/test/e2e/suite/command/pull.go b/test/e2e/suite/command/pull.go index 504171609..d219af7c5 100644 --- a/test/e2e/suite/command/pull.go +++ b/test/e2e/suite/command/pull.go @@ -174,3 +174,43 @@ var _ = Describe("OCI image layout users:", func() { }) }) }) + +var _ = Describe("OCI image spec v1.1.0-rc2 artifact users:", func() { + It("should pull all files in an image to a target folder", func() { + pullRoot := "pulled" + configName := "test.config" + tempDir := PrepareTempFiles() + stateKeys := append(foobar.ImageLayerStateKeys, foobar.ManifestStateKey, foobar.ImageConfigStateKey(configName)) + ORAS("pull", RegistryRef(Host, ImageRepo, foobar.Tag), "-v", "--config", configName, "-o", pullRoot). + MatchStatus(stateKeys, true, len(stateKeys)). + WithWorkDir(tempDir).Exec() + // check config + configPath := filepath.Join(tempDir, pullRoot, configName) + Expect(configPath).Should(BeAnExistingFile()) + f, err := os.Open(configPath) + Expect(err).ShouldNot(HaveOccurred()) + defer f.Close() + 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() + } + + ORAS("pull", RegistryRef(Host, ImageRepo, foobar.Tag), "-v", "-o", pullRoot, "--keep-old-files"). + ExpectFailure(). + WithDescription("fail if overwrite old files are disabled") + }) + + It("should pull subject", func() { + tempDir := GinkgoT().TempDir() + stateKeys := append(append( + foobar.ImageLayerStateKeys, + foobar.ManifestStateKey), + foobar.ArtifactReferrerStateKeys..., + ) + ORAS("pull", RegistryRef(Host, ArtifactRepo, foobar.SignatureArtifactReferrer.Digest.String()), "-v", "--include-subject"). + MatchStatus(stateKeys, true, len(stateKeys)). + WithWorkDir(tempDir).Exec() + }) +})