Skip to content

Commit 76825a3

Browse files
committed
start on conformance testing
Signed-off-by: Josh Dolitsky <[email protected]>
1 parent 1b7662d commit 76825a3

File tree

3 files changed

+55
-14
lines changed

3 files changed

+55
-14
lines changed

conformance/03_discovery_test.go

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,24 @@ var test03ContentDiscovery = func() {
1919
var tagList []string
2020

2121
g.Context("Setup", func() {
22-
g.Specify("Populate registry with test blob", func() {
22+
g.Specify("Populate registry with test blobs", func() {
2323
SkipIfDisabled(contentDiscovery)
2424
RunOnlyIf(runContentDiscoverySetup)
25-
req := client.NewRequest(reggie.POST, "/v2/<name>/blobs/uploads/")
26-
resp, err := client.Do(req)
27-
Expect(err).To(BeNil())
28-
req = client.NewRequest(reggie.PUT, resp.GetRelativeLocation()).
29-
SetQueryParam("digest", configs[2].Digest).
30-
SetHeader("Content-Type", "application/octet-stream").
31-
SetHeader("Content-Length", configs[2].ContentLength).
32-
SetBody(configs[2].Content)
33-
resp, err = client.Do(req)
34-
Expect(err).To(BeNil())
35-
Expect(resp.StatusCode()).To(SatisfyAll(
36-
BeNumerically(">=", 200),
37-
BeNumerically("<", 300)))
25+
for i := 1; i <= 2; i++ {
26+
req := client.NewRequest(reggie.POST, "/v2/<name>/blobs/uploads/")
27+
resp, err := client.Do(req)
28+
Expect(err).To(BeNil())
29+
req = client.NewRequest(reggie.PUT, resp.GetRelativeLocation()).
30+
SetQueryParam("digest", configs[i].Digest).
31+
SetHeader("Content-Type", "application/octet-stream").
32+
SetHeader("Content-Length", configs[i].ContentLength).
33+
SetBody(configs[i].Content)
34+
resp, err = client.Do(req)
35+
Expect(err).To(BeNil())
36+
Expect(resp.StatusCode()).To(SatisfyAll(
37+
BeNumerically(">=", 200),
38+
BeNumerically("<", 300)))
39+
}
3840
})
3941

4042
g.Specify("Populate registry with test layer", func() {
@@ -77,6 +79,20 @@ var test03ContentDiscovery = func() {
7779
_ = err
7880
})
7981

82+
g.Specify("Populate registry with referred-to manifest", func() {
83+
SkipIfDisabled(contentDiscovery)
84+
RunOnlyIf(runContentDiscoverySetup)
85+
req := client.NewRequest(reggie.PUT, "/v2/<name>/manifests/<reference>",
86+
reggie.WithReference("test-something-points-to-me")).
87+
SetHeader("Content-Type", "application/vnd.oci.image.manifest.v1+json").
88+
SetBody(manifests[1].Content)
89+
resp, err := client.Do(req)
90+
Expect(err).To(BeNil())
91+
Expect(resp.StatusCode()).To(SatisfyAll(
92+
BeNumerically(">=", 200),
93+
BeNumerically("<", 300)))
94+
})
95+
8096
g.Specify("Populate registry with test tags (no push)", func() {
8197
SkipIfDisabled(contentDiscovery)
8298
RunOnlyIfNot(runContentDiscoverySetup)
@@ -125,6 +141,19 @@ var test03ContentDiscovery = func() {
125141
Expect(len(tagList)).To(BeNumerically("<=", numResults))
126142
Expect(tagList).To(ContainElement(tagList[numResults-1]))
127143
})
144+
145+
g.Specify("GET request to list of referrers should yield 200 response", func() {
146+
SkipIfDisabled(contentDiscovery)
147+
// TODO: should move to this form per the spec,
148+
// the endpoint used is supported currently by oci-playground/distribution
149+
// req := client.NewRequest(reggie.GET, "/v2/<name>/referrers/<digest>", reggie.WithDigest(manifests[2].Digest))
150+
req := client.NewRequest(reggie.GET, "/v2/<name>/_oci/artifacts/referrers")
151+
// set the digest to the one being pointed to by manifests[2]
152+
req.QueryParam.Add("digest", manifests[1].Digest)
153+
resp, err := client.Do(req)
154+
Expect(err).To(BeNil())
155+
Expect(resp.StatusCode()).To(Equal(http.StatusOK))
156+
})
128157
})
129158

130159
g.Context("Teardown", func() {

conformance/image.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ type Manifest struct {
2020

2121
// Layers is an indexed list of layers referenced by the manifest.
2222
Layers []Descriptor `json:"layers"`
23+
24+
// Refers links a manifest to another existing manifest.
25+
Refers *Descriptor `json:"refers,omitempty"`
2326
}
2427

2528
// Descriptor describes the disposition of targeted content.

conformance/setup.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,15 @@ func init() {
234234
}
235235
manifest.SchemaVersion = 2
236236

237+
// except for the first one, add "refers" field pointing to the last one
238+
if i > 0 {
239+
manifest.Refers = &Descriptor{
240+
MediaType: "application/vnd.oci.image.manifest.v1+json",
241+
Digest: godigest.Digest(configs[i-1].Digest),
242+
Size: int64(len(configs[i-1].Content)),
243+
}
244+
}
245+
237246
manifestContent, err := json.MarshalIndent(&manifest, "", "\t")
238247
if err != nil {
239248
log.Fatal(err)

0 commit comments

Comments
 (0)