Skip to content

Commit

Permalink
Test pull of manifest pushed by digest (#427)
Browse files Browse the repository at this point in the history
Signed-off-by: Brandon Mitchell <git@bmitch.net>
  • Loading branch information
sudo-bmitch committed Jun 26, 2023
1 parent f49a193 commit 657d95d
Showing 1 changed file with 95 additions and 0 deletions.
95 changes: 95 additions & 0 deletions conformance/01_pull_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,24 @@ var test01Pull = func() {
BeNumerically("<", 300)))
})

g.Specify("Populate registry with test blob", func() {
SkipIfDisabled(pull)
RunOnlyIf(runPullSetup)
req := client.NewRequest(reggie.POST, "/v2/<name>/blobs/uploads/")
resp, err := client.Do(req)
Expect(err).To(BeNil())
req = client.NewRequest(reggie.PUT, resp.GetRelativeLocation()).
SetQueryParam("digest", configs[1].Digest).
SetHeader("Content-Type", "application/octet-stream").
SetHeader("Content-Length", configs[1].ContentLength).
SetBody(configs[1].Content)
resp, err = client.Do(req)
Expect(err).To(BeNil())
Expect(resp.StatusCode()).To(SatisfyAll(
BeNumerically(">=", 200),
BeNumerically("<", 300)))
})

g.Specify("Populate registry with test layer", func() {
SkipIfDisabled(pull)
RunOnlyIf(runPullSetup)
Expand Down Expand Up @@ -66,6 +84,20 @@ var test01Pull = func() {
BeNumerically("<", 300)))
})

g.Specify("Populate registry with test manifest", func() {
SkipIfDisabled(pull)
RunOnlyIf(runPullSetup)
req := client.NewRequest(reggie.PUT, "/v2/<name>/manifests/<reference>",
reggie.WithReference(manifests[1].Digest)).
SetHeader("Content-Type", "application/vnd.oci.image.manifest.v1+json").
SetBody(manifests[1].Content)
resp, err := client.Do(req)
Expect(err).To(BeNil())
Expect(resp.StatusCode()).To(SatisfyAll(
BeNumerically(">=", 200),
BeNumerically("<", 300)))
})

g.Specify("Get the name of a tag", func() {
SkipIfDisabled(pull)
RunOnlyIf(runPullSetup)
Expand Down Expand Up @@ -151,6 +183,18 @@ var test01Pull = func() {
}
})

g.Specify("HEAD request to manifest path (digest) should yield 200 response", func() {
SkipIfDisabled(pull)
req := client.NewRequest(reggie.HEAD, "/v2/<name>/manifests/<digest>", reggie.WithDigest(manifests[1].Digest)).
SetHeader("Accept", "application/vnd.oci.image.manifest.v1+json")
resp, err := client.Do(req)
Expect(err).To(BeNil())
Expect(resp.StatusCode()).To(Equal(http.StatusOK))
if h := resp.Header().Get("Docker-Content-Digest"); h != "" {
Expect(h).To(Equal(manifests[1].Digest))
}
})

g.Specify("HEAD request to manifest path (tag) should yield 200 response", func() {
SkipIfDisabled(pull)
Expect(tag).ToNot(BeEmpty())
Expand Down Expand Up @@ -182,6 +226,15 @@ var test01Pull = func() {
Expect(resp.StatusCode()).To(Equal(http.StatusOK))
})

g.Specify("GET request to manifest path (digest) should yield 200 response", func() {
SkipIfDisabled(pull)
req := client.NewRequest(reggie.GET, "/v2/<name>/manifests/<digest>", reggie.WithDigest(manifests[1].Digest)).
SetHeader("Accept", "application/vnd.oci.image.manifest.v1+json")
resp, err := client.Do(req)
Expect(err).To(BeNil())
Expect(resp.StatusCode()).To(Equal(http.StatusOK))
})

g.Specify("GET request to manifest path (tag) should yield 200 response", func() {
SkipIfDisabled(pull)
Expect(tag).ToNot(BeEmpty())
Expand Down Expand Up @@ -231,6 +284,20 @@ var test01Pull = func() {
Equal(http.StatusMethodNotAllowed),
))
})
g.Specify("Delete manifest created in setup", func() {
SkipIfDisabled(pull)
RunOnlyIf(runPullSetup)
req := client.NewRequest(reggie.DELETE, "/v2/<name>/manifests/<digest>", reggie.WithDigest(manifests[1].Digest))
resp, err := client.Do(req)
Expect(err).To(BeNil())
Expect(resp.StatusCode()).To(SatisfyAny(
SatisfyAll(
BeNumerically(">=", 200),
BeNumerically("<", 300),
),
Equal(http.StatusMethodNotAllowed),
))
})
}

g.Specify("Delete config blob created in setup", func() {
Expand All @@ -247,6 +314,20 @@ var test01Pull = func() {
Equal(http.StatusMethodNotAllowed),
))
})
g.Specify("Delete config blob created in setup", func() {
SkipIfDisabled(pull)
RunOnlyIf(runPullSetup)
req := client.NewRequest(reggie.DELETE, "/v2/<name>/blobs/<digest>", reggie.WithDigest(configs[1].Digest))
resp, err := client.Do(req)
Expect(err).To(BeNil())
Expect(resp.StatusCode()).To(SatisfyAny(
SatisfyAll(
BeNumerically(">=", 200),
BeNumerically("<", 300),
),
Equal(http.StatusMethodNotAllowed),
))
})

g.Specify("Delete layer blob created in setup", func() {
SkipIfDisabled(pull)
Expand Down Expand Up @@ -278,6 +359,20 @@ var test01Pull = func() {
Equal(http.StatusMethodNotAllowed),
))
})
g.Specify("Delete manifest created in setup", func() {
SkipIfDisabled(pull)
RunOnlyIf(runPullSetup)
req := client.NewRequest(reggie.DELETE, "/v2/<name>/manifests/<digest>", reggie.WithDigest(manifests[1].Digest))
resp, err := client.Do(req)
Expect(err).To(BeNil())
Expect(resp.StatusCode()).To(SatisfyAny(
SatisfyAll(
BeNumerically(">=", 200),
BeNumerically("<", 300),
),
Equal(http.StatusMethodNotAllowed),
))
})
}
})
})
Expand Down

0 comments on commit 657d95d

Please sign in to comment.