Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(e2e): re-bake test data #1094

Merged
merged 7 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions test/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ graph TD;
direction TB
E1["test.sbom.file(artifact)"] -- subject --> C1
E2["test.signature.file(artifact)"] -- subject --> E1
end
subgraph "file: artifacts_fallback.tar.gz"
direction TB
D1["test.sbom.file(image)"] -- subject --> C1
D2["test.signature.file(image)"] -- subject --> D1
Expand Down
37 changes: 7 additions & 30 deletions test/e2e/internal/testdata/foobar/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,16 @@ func ImageConfigStateKey(configName string) match.StateKey {
var (
SBOMImageReferrer = ocispec.Descriptor{
MediaType: "application/vnd.oci.image.manifest.v1+json",
Digest: digest.Digest("sha256:32b78bd00723cd7d5251d4586f84d252530b7b5fe1c4104532767e6da4e04e47"),
Digest: digest.Digest("sha256:e2c6633a79985906f1ed55c592718c73c41e809fb9818de232a635904a74d48d"),
Size: 660,
Annotations: map[string]string{
"org.opencontainers.image.created": "2023-01-18T08:37:42Z",
},
ArtifactType: "test.sbom.file",
ArtifactType: "test/sbom.file",
}
SignatureImageReferrer = ocispec.Descriptor{
MediaType: "application/vnd.oci.image.manifest.v1+json",
Digest: digest.Digest("sha256:0e007dcb9ded7f49c4dc8e3eed4a446712eb6fdf08a665a4f2352d6d2f8bdf17"),
Digest: digest.Digest("sha256:0cb8c4da7e9ff2e7eefca33141091b9239218e3125a35e17e8bcd05fa3a5e714"),
Size: 670,
}
SBOMArtifactReferrer = ocispec.Descriptor{
Expand All @@ -122,34 +122,11 @@ var (
{Digest: "2dbea575a349", Name: "application/vnd.oci.artifact.manifest.v1+json"},
}
ImageReferrersStateKeys = []match.StateKey{
{Digest: "0e007dcb9ded", Name: "application/vnd.oci.image.manifest.v1+json"},
{Digest: "32b78bd00723", Name: "application/vnd.oci.image.manifest.v1+json"},
{Digest: "0cb8c4da7e9f", Name: "application/vnd.oci.image.manifest.v1+json"},
{Digest: "e2c6633a7998", Name: "application/vnd.oci.image.manifest.v1+json"},
}
ImageReferrerConfigStateKeys = []match.StateKey{
{Digest: "44136fa355b3", Name: "test.signature.file"},
{Digest: "44136fa355b3", Name: "test.sbom.file"},
}
FallbackImageReferrersStateKeys = []match.StateKey{
{Digest: "316405db72cc", Name: "application/vnd.oci.image.manifest.v1+json"},
{Digest: "8b3f7e000c4a", Name: "application/vnd.oci.image.manifest.v1+json"},
}
)

// fallback referrers
var (
FallbackSignatureImageReferrer = ocispec.Descriptor{
MediaType: "application/vnd.oci.image.manifest.v1+json",
Digest: digest.Digest("sha256:8b3f7e000c4a6d32cd6bfcabfe874ed470d470501a09adc65afaf1c342f988ff"),
Size: 670,
}

FallbackSBOMImageReferrer = ocispec.Descriptor{
MediaType: "application/vnd.oci.image.manifest.v1+json",
Digest: digest.Digest("sha256:316405db72cc8f0212c19db23b498f9af8a456c9cd288f9e33acd1ba9e7cd534"),
Size: 660,
Annotations: map[string]string{
"org.opencontainers.image.created": "2023-01-29T02:32:18Z",
},
ArtifactType: "test.sbom.file",
{Digest: "44136fa355b3", Name: "test/signature.file"},
{Digest: "44136fa355b3", Name: "test/sbom.file"},
}
)
8 changes: 4 additions & 4 deletions test/e2e/suite/command/cp.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,13 @@ var _ = Describe("OCI spec 1.0 registry users:", func() {
})
It("should copy an image artifact and its referrers from a fallback registry to a registry", func() {
repo := cpTestRepo("from-fallback")
stateKeys := append(append(foobarStates, foobar.FallbackImageReferrersStateKeys...), foobar.ImageReferrerConfigStateKeys...)
src := RegistryRef(FallbackHost, ArtifactRepo, foobar.FallbackSBOMImageReferrer.Digest.String())
stateKeys := append(append(foobarStates, foobar.ImageReferrersStateKeys...), foobar.ImageReferrerConfigStateKeys...)
src := RegistryRef(FallbackHost, ArtifactRepo, foobar.SBOMImageReferrer.Digest.String())
dst := RegistryRef(Host, repo, "")
ORAS("cp", "-r", src, dst, "-v").MatchStatus(stateKeys, true, len(stateKeys)).Exec()
CompareRef(src, RegistryRef(Host, repo, foobar.FallbackSBOMImageReferrer.Digest.String()))
CompareRef(src, RegistryRef(Host, repo, foobar.SBOMImageReferrer.Digest.String()))
ORAS("discover", "-o", "tree", RegistryRef(Host, repo, foobar.Digest)).
WithDescription("discover referrer via subject").MatchKeyWords(foobar.FallbackSignatureImageReferrer.Digest.String(), foobar.FallbackSBOMImageReferrer.Digest.String()).Exec()
WithDescription("discover referrer via subject").MatchKeyWords(foobar.SignatureImageReferrer.Digest.String(), foobar.SBOMImageReferrer.Digest.String()).Exec()
})

It("should copy an image from a fallback registry to an OCI image layout via digest", func() {
Expand Down
20 changes: 9 additions & 11 deletions test/e2e/suite/command/discover.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ var _ = Describe("1.1 registry users:", func() {
bytes := ORAS("discover", subjectRef, "-o", format, "--artifact-type", foobar.SBOMArtifactReferrer.ArtifactType).Exec().Out.Contents()
var index ocispec.Index
Expect(json.Unmarshal(bytes, &index)).ShouldNot(HaveOccurred())
Expect(index.Manifests).To(HaveLen(2))
Expect(index.Manifests).Should(ContainElement(foobar.SBOMImageReferrer))
Expect(index.Manifests).To(HaveLen(1))
Expect(index.Manifests).Should(ContainElement(foobar.SBOMArtifactReferrer))
})

Expand Down Expand Up @@ -145,15 +144,15 @@ var _ = Describe("1.0 registry users:", func() {
var index ocispec.Index
Expect(json.Unmarshal(bytes, &index)).ShouldNot(HaveOccurred())
Expect(index.Manifests).To(HaveLen(1))
Expect(index.Manifests).Should(ContainElement(foobar.FallbackSBOMImageReferrer))
Expect(index.Manifests).Should(ContainElement(foobar.SBOMImageReferrer))
})

It("should discover matched referrer when filtering via json output", func() {
bytes := ORAS("discover", subjectRef, "-o", "json", "--artifact-type", foobar.FallbackSBOMImageReferrer.ArtifactType).Exec().Out.Contents()
bytes := ORAS("discover", subjectRef, "-o", "json", "--artifact-type", foobar.SBOMImageReferrer.ArtifactType).Exec().Out.Contents()
var index ocispec.Index
Expect(json.Unmarshal(bytes, &index)).ShouldNot(HaveOccurred())
Expect(index.Manifests).To(HaveLen(1))
Expect(index.Manifests).Should(ContainElement(foobar.FallbackSBOMImageReferrer))
Expect(index.Manifests).Should(ContainElement(foobar.SBOMImageReferrer))
})

It("should discover no referrer when not matching via json output", func() {
Expand All @@ -164,28 +163,28 @@ var _ = Describe("1.0 registry users:", func() {
})

It("should discover all referrers of a subject via tree output", func() {
referrers := []ocispec.Descriptor{foobar.FallbackSBOMImageReferrer, foobar.FallbackSignatureImageReferrer}
referrers := []ocispec.Descriptor{foobar.SBOMImageReferrer, foobar.SignatureImageReferrer}
ORAS("discover", subjectRef, "-o", "tree").
MatchKeyWords(append(discoverKeyWords(false, referrers...), RegistryRef(FallbackHost, ArtifactRepo, foobar.Digest))...).
Exec()
})

It("should discover all referrers with annotation via tree output", func() {
referrers := []ocispec.Descriptor{foobar.FallbackSBOMImageReferrer, foobar.FallbackSignatureImageReferrer}
referrers := []ocispec.Descriptor{foobar.SBOMImageReferrer, foobar.SignatureImageReferrer}
ORAS("discover", subjectRef, "-o", "tree", "-v").
MatchKeyWords(append(discoverKeyWords(true, referrers...), RegistryRef(FallbackHost, ArtifactRepo, foobar.Digest))...).
Exec()
})

It("should discover direct referrers of a subject via table output", func() {
referrers := []ocispec.Descriptor{foobar.FallbackSBOMImageReferrer}
referrers := []ocispec.Descriptor{foobar.SBOMImageReferrer}
ORAS("discover", subjectRef, "-o", "table").
MatchKeyWords(append(discoverKeyWords(false, referrers...), foobar.Digest)...).
Exec()
})

It("should discover direct referrers explicitly via tag scheme", func() {
referrers := []ocispec.Descriptor{foobar.FallbackSBOMImageReferrer}
referrers := []ocispec.Descriptor{foobar.SBOMImageReferrer}
ORAS("discover", subjectRef, "-o", "table", "--distribution-spec", "v1.1-referrers-tag").
MatchKeyWords(append(discoverKeyWords(false, referrers...), foobar.Digest)...).
Exec()
Expand Down Expand Up @@ -220,8 +219,7 @@ var _ = Describe("OCI image layout users:", func() {
bytes := ORAS("discover", subjectRef, "-o", format, "--artifact-type", foobar.SBOMArtifactReferrer.ArtifactType, Flags.Layout).Exec().Out.Contents()
var index ocispec.Index
Expect(json.Unmarshal(bytes, &index)).ShouldNot(HaveOccurred())
Expect(index.Manifests).To(HaveLen(2))
Expect(index.Manifests).Should(ContainElement(foobar.SBOMImageReferrer))
Expect(index.Manifests).To(HaveLen(1))
Expect(index.Manifests).Should(ContainElement(foobar.SBOMArtifactReferrer))
})

Expand Down
Binary file modified test/e2e/testdata/distribution/mount/artifacts.tar.gz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +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"}}
{"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:e2c6633a79985906f1ed55c592718c73c41e809fb9818de232a635904a74d48d","size":660},"annotations":{"org.opencontainers.image.created":"2023-01-18T08:37:57Z"}}
Original file line number Diff line number Diff line change
@@ -1 +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"}}
{"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"}}
4 changes: 2 additions & 2 deletions test/e2e/testdata/zot/command/artifacts/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
},
{
"mediaType": "application/vnd.oci.image.manifest.v1+json",
"digest": "sha256:32b78bd00723cd7d5251d4586f84d252530b7b5fe1c4104532767e6da4e04e47",
"digest": "sha256:e2c6633a79985906f1ed55c592718c73c41e809fb9818de232a635904a74d48d",
"size": 660
},
{
"mediaType": "application/vnd.oci.image.manifest.v1+json",
"digest": "sha256:0e007dcb9ded7f49c4dc8e3eed4a446712eb6fdf08a665a4f2352d6d2f8bdf17",
"digest": "sha256:0cb8c4da7e9ff2e7eefca33141091b9239218e3125a35e17e8bcd05fa3a5e714",
"size": 670
}
]
Expand Down