Skip to content

Commit 04c6343

Browse files
committed
Support sha512 content
Signed-off-by: Brandon Mitchell <git@bmitch.net>
1 parent 58d034e commit 04c6343

File tree

7 files changed

+381
-31
lines changed

7 files changed

+381
-31
lines changed

Makefile

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -92,27 +92,33 @@ conformance-test:
9292

9393
conformance-binary: $(OUTPUT_DIRNAME)/conformance.test
9494

95-
TEST_REGISTRY_CONTAINER ?= ghcr.io/project-zot/zot-minimal-linux-amd64:v2.0.0-rc6@sha256:bf95a94849cd9c6f596fb10e5a2d03b74267e7886d1ba0b3dab33337d9e46e5c
95+
# TODO: update image once changes are merged in zot
96+
# TEST_REGISTRY_CONTAINER ?= ghcr.io/project-zot/zot-minimal-linux-amd64:v2.1.0
97+
TEST_REGISTRY_CONTAINER ?= ghcr.io/andaaron/zot-minimal-linux-amd64:v2.1.0-manifest-digest
9698
registry-ci:
97-
docker rm -f oci-conformance && \
98-
mkdir -p $(OUTPUT_DIRNAME) && \
99-
echo '{"distSpecVersion":"1.1.0-dev","storage":{"rootDirectory":"/tmp/zot","gc":false,"dedupe":false},"http":{"address":"0.0.0.0","port":"5000"},"log":{"level":"debug"}}' > $(shell pwd)/$(OUTPUT_DIRNAME)/zot-config.json
100-
docker run -d \
101-
-v $(shell pwd)/$(OUTPUT_DIRNAME)/zot-config.json:/etc/zot/config.json \
102-
--name=oci-conformance \
103-
-p 5000:5000 \
104-
$(TEST_REGISTRY_CONTAINER) && \
105-
sleep 5
106-
107-
conformance-ci:
108-
export OCI_ROOT_URL="http://localhost:5000" && \
99+
docker rm -f oci-conformance || true
100+
mkdir -p $(OUTPUT_DIRNAME)
101+
docker run -d --rm \
102+
--name=oci-conformance \
103+
-p 5000 \
104+
$(TEST_REGISTRY_CONTAINER)
105+
sleep 5
106+
107+
conformance-ci: conformance-binary
108+
export OCI_ROOT_URL="http://localhost:$$(docker port oci-conformance 5000 | head -1 | cut -f2 -d:)" && \
109109
export OCI_NAMESPACE="myorg/myrepo" && \
110110
export OCI_TEST_PULL=1 && \
111111
export OCI_TEST_PUSH=1 && \
112112
export OCI_TEST_CONTENT_DISCOVERY=1 && \
113113
export OCI_TEST_CONTENT_MANAGEMENT=1 && \
114114
$(shell pwd)/$(OUTPUT_DIRNAME)/conformance.test
115115

116+
conformance-clean:
117+
docker stop oci-conformance || true
118+
[ ! -f $(OUTPUT_DIRNAME)/conformance.test ] || rm "$(OUTPUT_DIRNAME)/conformance.test"
119+
[ ! -f "junit.xml" ] || rm junit.xml
120+
[ ! -f "report.html" ] || rm report.html
121+
116122
$(OUTPUT_DIRNAME)/conformance.test:
117123
cd conformance && \
118124
CGO_ENABLED=0 go test -c -o $(shell pwd)/$(OUTPUT_DIRNAME)/conformance.test \

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ runs:
3131
run: |
3232
set -x
3333
34-
# Enter the directory containing the checkout of this action which is surpisingly hard to do (but we did it... #OCI)
34+
# Enter the directory containing the checkout of this action which is surprisingly hard to do (but we did it... #OCI)
3535
cd "$(dirname $(find $(find ~/work/_actions -name distribution-spec -print -quit) -name Makefile -print -quit))"
3636
3737
# The .git folder is not present, but the dirname is the requested action ref, so use this as the conformance version

conformance/01_pull_test.go

Lines changed: 149 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package conformance
22

33
import (
44
"net/http"
5-
"os"
65

76
"github.com/bloodorangeio/reggie"
87
g "github.com/onsi/ginkgo/v2"
@@ -12,8 +11,6 @@ import (
1211
var test01Pull = func() {
1312
g.Context(titlePull, func() {
1413

15-
var tag string
16-
1714
g.Context("Setup", func() {
1815
g.Specify("Populate registry with test blob", func() {
1916
SkipIfDisabled(pull)
@@ -72,9 +69,8 @@ var test01Pull = func() {
7269
g.Specify("Populate registry with test manifest", func() {
7370
SkipIfDisabled(pull)
7471
RunOnlyIf(runPullSetup)
75-
tag = testTagName
7672
req := client.NewRequest(reggie.PUT, "/v2/<name>/manifests/<reference>",
77-
reggie.WithReference(tag)).
73+
reggie.WithReference(testTagName)).
7874
SetHeader("Content-Type", "application/vnd.oci.image.manifest.v1+json").
7975
SetBody(manifests[0].Content)
8076
resp, err := client.Do(req)
@@ -98,14 +94,41 @@ var test01Pull = func() {
9894
BeNumerically("<", 300)))
9995
})
10096

101-
g.Specify("Get tag name from environment", func() {
97+
g.Specify("Populate registry with sha512 blobs", func() {
10298
SkipIfDisabled(pull)
103-
RunOnlyIfNot(runPullSetup)
104-
tmp := os.Getenv(envVarTagName)
105-
if tmp != "" {
106-
tag = tmp
99+
RunOnlyIf(runPull512Setup)
100+
for _, blob := range testBlobs["sha512"] {
101+
req := client.NewRequest(reggie.POST, "/v2/<name>/blobs/uploads/").
102+
SetQueryParam("digest-algorithm", "sha512")
103+
resp, err := client.Do(req)
104+
Expect(err).To(BeNil())
105+
req = client.NewRequest(reggie.PUT, resp.GetRelativeLocation()).
106+
SetQueryParam("digest", blob.Digest).
107+
SetHeader("Content-Type", "application/octet-stream").
108+
SetHeader("Content-Length", blob.ContentLength).
109+
SetBody(blob.Content)
110+
resp, err = client.Do(req)
111+
Expect(err).To(BeNil())
112+
Expect(resp.StatusCode()).To(SatisfyAll(
113+
BeNumerically(">=", 200),
114+
BeNumerically("<", 300)))
107115
}
108116
})
117+
118+
g.Specify("Populate registry with test sha512 manifest", func() {
119+
SkipIfDisabled(pull)
120+
RunOnlyIf(runPull512Setup)
121+
req := client.NewRequest(reggie.PUT, "/v2/<name>/manifests/<reference>",
122+
reggie.WithReference(testTag512Name)).
123+
SetQueryParam("digest", testManifests["sha512"].Digest).
124+
SetHeader("Content-Type", "application/vnd.oci.image.manifest.v1+json").
125+
SetBody(testManifests["sha512"].Content)
126+
resp, err := client.Do(req)
127+
Expect(err).To(BeNil())
128+
Expect(resp.StatusCode()).To(SatisfyAll(
129+
BeNumerically(">=", 200),
130+
BeNumerically("<", 300)))
131+
})
109132
})
110133

111134
g.Context("Pull blobs", func() {
@@ -130,6 +153,18 @@ var test01Pull = func() {
130153
}
131154
})
132155

156+
g.Specify("HEAD request to existing sha512 blob should yield 200", func() {
157+
SkipIfDisabled(pull)
158+
req := client.NewRequest(reggie.HEAD, "/v2/<name>/blobs/<digest>",
159+
reggie.WithDigest(testBlobs["sha512"][0].Digest))
160+
resp, err := client.Do(req)
161+
Expect(err).To(BeNil())
162+
Expect(resp.StatusCode()).To(Equal(http.StatusOK))
163+
if h := resp.Header().Get("Docker-Content-Digest"); h != "" {
164+
Expect(h).To(Equal(testBlobs["sha512"][0].Digest))
165+
}
166+
})
167+
133168
g.Specify("GET nonexistent blob should result in 404 response", func() {
134169
SkipIfDisabled(pull)
135170
req := client.NewRequest(reggie.GET, "/v2/<name>/blobs/<digest>",
@@ -146,6 +181,15 @@ var test01Pull = func() {
146181
Expect(err).To(BeNil())
147182
Expect(resp.StatusCode()).To(Equal(http.StatusOK))
148183
})
184+
185+
g.Specify("GET request to existing sha512 blob URL should yield 200", func() {
186+
SkipIfDisabled(pull)
187+
req := client.NewRequest(reggie.GET, "/v2/<name>/blobs/<digest>",
188+
reggie.WithDigest(testBlobs["sha512"][0].Digest))
189+
resp, err := client.Do(req)
190+
Expect(err).To(BeNil())
191+
Expect(resp.StatusCode()).To(Equal(http.StatusOK))
192+
})
149193
})
150194

151195
g.Context("Pull manifests", func() {
@@ -182,10 +226,23 @@ var test01Pull = func() {
182226
}
183227
})
184228

229+
g.Specify("HEAD request to sha512 manifest (digest) should yield 200 response", func() {
230+
SkipIfDisabled(pull)
231+
req := client.NewRequest(reggie.HEAD, "/v2/<name>/manifests/<digest>",
232+
reggie.WithDigest(testManifests["sha512"].Digest)).
233+
SetHeader("Accept", "application/vnd.oci.image.manifest.v1+json")
234+
resp, err := client.Do(req)
235+
Expect(err).To(BeNil())
236+
Expect(resp.StatusCode()).To(Equal(http.StatusOK))
237+
if h := resp.Header().Get("Docker-Content-Digest"); h != "" {
238+
Expect(h).To(Equal(testManifests["sha512"].Digest))
239+
}
240+
})
241+
185242
g.Specify("HEAD request to manifest path (tag) should yield 200 response", func() {
186243
SkipIfDisabled(pull)
187-
Expect(tag).ToNot(BeEmpty())
188-
req := client.NewRequest(reggie.HEAD, "/v2/<name>/manifests/<reference>", reggie.WithReference(tag)).
244+
Expect(testTagName).ToNot(BeEmpty())
245+
req := client.NewRequest(reggie.HEAD, "/v2/<name>/manifests/<reference>", reggie.WithReference(testTagName)).
189246
SetHeader("Accept", "application/vnd.oci.image.manifest.v1+json")
190247
resp, err := client.Do(req)
191248
Expect(err).To(BeNil())
@@ -195,6 +252,19 @@ var test01Pull = func() {
195252
}
196253
})
197254

255+
g.Specify("HEAD request to sha512 manifest (tag) should yield 200 response", func() {
256+
SkipIfDisabled(pull)
257+
Expect(testTag512Name).ToNot(BeEmpty())
258+
req := client.NewRequest(reggie.HEAD, "/v2/<name>/manifests/<reference>", reggie.WithReference(testTag512Name)).
259+
SetHeader("Accept", "application/vnd.oci.image.manifest.v1+json")
260+
resp, err := client.Do(req)
261+
Expect(err).To(BeNil())
262+
Expect(resp.StatusCode()).To(Equal(http.StatusOK))
263+
if h := resp.Header().Get("Docker-Content-Digest"); h != "" {
264+
Expect(h).To(Equal(testManifests["sha512"].Digest))
265+
}
266+
})
267+
198268
g.Specify("GET nonexistent manifest should return 404", func() {
199269
SkipIfDisabled(pull)
200270
req := client.NewRequest(reggie.GET, "/v2/<name>/manifests/<reference>",
@@ -222,10 +292,29 @@ var test01Pull = func() {
222292
Expect(resp.StatusCode()).To(Equal(http.StatusOK))
223293
})
224294

295+
g.Specify("GET request to sha512 manifest (digest) should yield 200 response", func() {
296+
SkipIfDisabled(pull)
297+
req := client.NewRequest(reggie.GET, "/v2/<name>/manifests/<digest>", reggie.WithDigest(testManifests["sha512"].Digest)).
298+
SetHeader("Accept", "application/vnd.oci.image.manifest.v1+json")
299+
resp, err := client.Do(req)
300+
Expect(err).To(BeNil())
301+
Expect(resp.StatusCode()).To(Equal(http.StatusOK))
302+
})
303+
225304
g.Specify("GET request to manifest path (tag) should yield 200 response", func() {
226305
SkipIfDisabled(pull)
227-
Expect(tag).ToNot(BeEmpty())
228-
req := client.NewRequest(reggie.GET, "/v2/<name>/manifests/<reference>", reggie.WithReference(tag)).
306+
Expect(testTagName).ToNot(BeEmpty())
307+
req := client.NewRequest(reggie.GET, "/v2/<name>/manifests/<reference>", reggie.WithReference(testTagName)).
308+
SetHeader("Accept", "application/vnd.oci.image.manifest.v1+json")
309+
resp, err := client.Do(req)
310+
Expect(err).To(BeNil())
311+
Expect(resp.StatusCode()).To(Equal(http.StatusOK))
312+
})
313+
314+
g.Specify("GET request to sha512 manifest (tag) should yield 200 response", func() {
315+
SkipIfDisabled(pull)
316+
Expect(testTag512Name).ToNot(BeEmpty())
317+
req := client.NewRequest(reggie.GET, "/v2/<name>/manifests/<reference>", reggie.WithReference(testTag512Name)).
229318
SetHeader("Accept", "application/vnd.oci.image.manifest.v1+json")
230319
resp, err := client.Do(req)
231320
Expect(err).To(BeNil())
@@ -285,6 +374,20 @@ var test01Pull = func() {
285374
Equal(http.StatusMethodNotAllowed),
286375
))
287376
})
377+
g.Specify("Delete sha512 manifest created in setup", func() {
378+
SkipIfDisabled(pull)
379+
RunOnlyIf(runPull512Setup)
380+
req := client.NewRequest(reggie.DELETE, "/v2/<name>/manifests/<digest>", reggie.WithDigest(testManifests["sha512"].Digest))
381+
resp, err := client.Do(req)
382+
Expect(err).To(BeNil())
383+
Expect(resp.StatusCode()).To(SatisfyAny(
384+
SatisfyAll(
385+
BeNumerically(">=", 200),
386+
BeNumerically("<", 300),
387+
),
388+
Equal(http.StatusMethodNotAllowed),
389+
))
390+
})
288391
}
289392

290393
g.Specify("Delete config[0] blob created in setup", func() {
@@ -331,6 +434,24 @@ var test01Pull = func() {
331434
))
332435
})
333436

437+
for _, blob := range testBlobs["sha512"] {
438+
g.Specify("Delete blob created in setup", func() {
439+
SkipIfDisabled(pull)
440+
RunOnlyIf(runPull512Setup)
441+
req := client.NewRequest(reggie.DELETE, "/v2/<name>/blobs/<digest>", reggie.WithDigest(blob.Digest))
442+
resp, err := client.Do(req)
443+
Expect(err).To(BeNil())
444+
Expect(resp.StatusCode()).To(SatisfyAny(
445+
SatisfyAll(
446+
BeNumerically(">=", 200),
447+
BeNumerically("<", 300),
448+
),
449+
Equal(http.StatusNotFound),
450+
Equal(http.StatusMethodNotAllowed),
451+
))
452+
})
453+
}
454+
334455
if !deleteManifestBeforeBlobs {
335456
g.Specify("Delete manifest[0] created in setup", func() {
336457
SkipIfDisabled(pull)
@@ -360,6 +481,20 @@ var test01Pull = func() {
360481
Equal(http.StatusMethodNotAllowed),
361482
))
362483
})
484+
g.Specify("Delete sha512 manifest created in setup", func() {
485+
SkipIfDisabled(pull)
486+
RunOnlyIf(runPull512Setup)
487+
req := client.NewRequest(reggie.DELETE, "/v2/<name>/manifests/<digest>", reggie.WithDigest(testManifests["sha512"].Digest))
488+
resp, err := client.Do(req)
489+
Expect(err).To(BeNil())
490+
Expect(resp.StatusCode()).To(SatisfyAny(
491+
SatisfyAll(
492+
BeNumerically(">=", 200),
493+
BeNumerically("<", 300),
494+
),
495+
Equal(http.StatusMethodNotAllowed),
496+
))
497+
})
363498
}
364499
})
365500
})

0 commit comments

Comments
 (0)