Skip to content

Commit b220403

Browse files
committed
Add test and spec section for HEAD requests
Signed-off-by: Peter Engelbert <[email protected]>
1 parent 43d840e commit b220403

File tree

2 files changed

+63
-3
lines changed

2 files changed

+63
-3
lines changed

conformance/01_pull_test.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,24 @@ var test01Pull = func() {
8181
})
8282

8383
g.Context("Pull blobs", func() {
84+
g.Specify("HEAD request to nonexistent blob should result in 404 response", func() {
85+
SkipIfDisabled(pull)
86+
req := client.NewRequest(reggie.HEAD, "/v2/<name>/blobs/<digest>",
87+
reggie.WithDigest(dummyDigest))
88+
resp, err := client.Do(req)
89+
Expect(err).To(BeNil())
90+
Expect(resp.StatusCode()).To(Equal(http.StatusNotFound))
91+
})
92+
93+
g.Specify("HEAD request to existing blob should yield 200", func() {
94+
SkipIfDisabled(pull)
95+
req := client.NewRequest(reggie.HEAD, "/v2/<name>/blobs/<digest>",
96+
reggie.WithDigest(configBlobDigest))
97+
resp, err := client.Do(req)
98+
Expect(err).To(BeNil())
99+
Expect(resp.StatusCode()).To(Equal(http.StatusOK))
100+
})
101+
84102
g.Specify("GET nonexistent blob should result in 404 response", func() {
85103
SkipIfDisabled(pull)
86104
req := client.NewRequest(reggie.GET, "/v2/<name>/blobs/<digest>",
@@ -100,6 +118,34 @@ var test01Pull = func() {
100118
})
101119

102120
g.Context("Pull manifests", func() {
121+
g.Specify("HEAD request to nonexistent manifest should return 404", func() {
122+
SkipIfDisabled(pull)
123+
req := client.NewRequest(reggie.HEAD, "/v2/<name>/manifests/<reference>",
124+
reggie.WithReference(nonexistentManifest))
125+
resp, err := client.Do(req)
126+
Expect(err).To(BeNil())
127+
Expect(resp.StatusCode()).To(Equal(http.StatusNotFound))
128+
})
129+
130+
g.Specify("HEAD request to manifest path (digest) should yield 200 response", func() {
131+
SkipIfDisabled(pull)
132+
req := client.NewRequest(reggie.HEAD, "/v2/<name>/manifests/<digest>", reggie.WithDigest(manifestDigest)).
133+
SetHeader("Accept", "application/vnd.oci.image.manifest.v1+json")
134+
resp, err := client.Do(req)
135+
Expect(err).To(BeNil())
136+
Expect(resp.StatusCode()).To(Equal(http.StatusOK))
137+
})
138+
139+
g.Specify("HEAD request to manifest path (tag) should yield 200 response", func() {
140+
SkipIfDisabled(pull)
141+
Expect(tag).ToNot(BeEmpty())
142+
req := client.NewRequest(reggie.GET, "/v2/<name>/manifests/<reference>", reggie.WithReference(tag)).
143+
SetHeader("Accept", "application/vnd.oci.image.manifest.v1+json")
144+
resp, err := client.Do(req)
145+
Expect(err).To(BeNil())
146+
Expect(resp.StatusCode()).To(Equal(http.StatusOK))
147+
})
148+
103149
g.Specify("GET nonexistent manifest should return 404", func() {
104150
SkipIfDisabled(pull)
105151
req := client.NewRequest(reggie.GET, "/v2/<name>/manifests/<reference>",

spec.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ Typically, the first step in pulling an artifact is to retrieve the manifest. Ho
128128

129129
##### Pulling manifests
130130

131-
To pull a manifest, perform a `GET` request to a url in the following form:
131+
To pull a manifest, perform a `GET` request to a URL in the following form:
132132
`/v2/<name>/manifests/<reference>` <sup>[end-3](#endpoints)</sup>
133133

134134
`<name>` refers to the namespace of the repository. `<reference>` MUST be either (a) the digest of the manifest or (b) a tag name.
@@ -146,9 +146,9 @@ blob data.
146146

147147
If the manifest is not found in the registry, the response code MUST be `404 Not Found`.
148148

149-
##### Pulling Blobs
149+
##### Pulling blobs
150150

151-
To pull a blob, perform a `GET` request to a url in the following form:
151+
To pull a blob, perform a `GET` request to a URL in the following form:
152152
`/v2/<name>/blobs/<digest>` <sup>[end-2](#endpoints)</sup>
153153

154154
`<name>` is the namespace of the repository, and `<digest>` is the blob's digest.
@@ -157,6 +157,18 @@ A GET request to an existing blob URL MUST provide the expected blob, with a res
157157

158158
If the blob is not found in the registry, the response code MUST be `404 Not Found`.
159159

160+
##### Checking if content exists in the registry
161+
162+
In order to verify that a repository contains a given manifest or blob, make a `HEAD` request to a URL in the following form:
163+
164+
`/v2/<name>/manifests/<reference>` <sup>[end-12](#endpoints)</sup> (for manifests), or
165+
166+
`/v2/<name>/blobs/<digest>` <sup>[end-11](#endpoints)</sup> (for blobs).
167+
168+
A HEAD request to an existing blob or manifest URL MUST return `200 OK`.
169+
170+
If the blob or manifest is not found in the registry, the response code MUST be `404 Not Found`.
171+
160172

161173
#### Push
162174

@@ -467,6 +479,8 @@ of this specification.
467479
| end-9 | `DELETE` | `/v2/<name>/manifests/<reference>` | `202` | `404`/`400`/`405` |
468480
| end-10 | `DELETE` | `/v2/<name>/blobs/<digest>` | `202` | `404`/`405` |
469481
| end-11 | `POST` | `/v2/<name>/blobs/uploads/?mount=<digest>&from=<other_namespace>` | `201` | `404` |
482+
| end-12 | `HEAD` | `/v2/<name>/blobs/<digest>` | `200` | `404` |
483+
| end-13 | `HEAD` | `/v2/<name>/manifests/<reference>` | `200` | `404` |
470484

471485
#### Error Codes
472486

0 commit comments

Comments
 (0)