Skip to content

Commit 6f76343

Browse files
committed
test: exercise manifest list backwards compat
Signed-off-by: Antonio Murdaca <[email protected]>
1 parent 22951a0 commit 6f76343

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed

schema/manifest_backwards_compatibility_test.go

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,89 @@ func convertFormats(input string) string {
4242
return out
4343
}
4444

45+
func TestBackwardsCompatibilityManifestList(t *testing.T) {
46+
for i, tt := range []struct {
47+
manifest string
48+
digest string
49+
fail bool
50+
}{
51+
{
52+
digest: "sha256:e588eb8123f2031a41f2e60bc27f30a4388e181e07410aff392f7dc96b585969",
53+
manifest: `{
54+
"schemaVersion": 2,
55+
"mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
56+
"manifests": [
57+
{
58+
"mediaType": "application/vnd.docker.distribution.manifest.v1+json",
59+
"size": 2094,
60+
"digest": "sha256:7820f9a86d4ad15a2c4f0c0e5479298df2aa7c2f6871288e2ef8546f3e7b6783",
61+
"platform": {
62+
"architecture": "ppc64le",
63+
"os": "linux"
64+
}
65+
},
66+
{
67+
"mediaType": "application/vnd.docker.distribution.manifest.v1+json",
68+
"size": 1922,
69+
"digest": "sha256:ae1b0e06e8ade3a11267564a26e750585ba2259c0ecab59ab165ad1af41d1bdd",
70+
"platform": {
71+
"architecture": "amd64",
72+
"os": "linux",
73+
"features": [
74+
"sse"
75+
]
76+
}
77+
},
78+
{
79+
"mediaType": "application/vnd.docker.distribution.manifest.v1+json",
80+
"size": 2084,
81+
"digest": "sha256:e4c0df75810b953d6717b8f8f28298d73870e8aa2a0d5e77b8391f16fdfbbbe2",
82+
"platform": {
83+
"architecture": "s390x",
84+
"os": "linux"
85+
}
86+
},
87+
{
88+
"mediaType": "application/vnd.docker.distribution.manifest.v1+json",
89+
"size": 2084,
90+
"digest": "sha256:07ebe243465ef4a667b78154ae6c3ea46fdb1582936aac3ac899ea311a701b40",
91+
"platform": {
92+
"architecture": "arm",
93+
"os": "linux",
94+
"variant": "armv7"
95+
}
96+
},
97+
{
98+
"mediaType": "application/vnd.docker.distribution.manifest.v1+json",
99+
"size": 2090,
100+
"digest": "sha256:fb2fc0707b86dafa9959fe3d29e66af8787aee4d9a23581714be65db4265ad8a",
101+
"platform": {
102+
"architecture": "arm64",
103+
"os": "linux",
104+
"variant": "armv8"
105+
}
106+
}
107+
]
108+
}`,
109+
fail: false,
110+
},
111+
} {
112+
sum := sha256.Sum256([]byte(tt.manifest))
113+
got := fmt.Sprintf("sha256:%s", hex.EncodeToString(sum[:]))
114+
if tt.digest != got {
115+
t.Errorf("test %d: expected digest %s but got %s", i, tt.digest, got)
116+
}
117+
118+
manifest := convertFormats(tt.manifest)
119+
r := strings.NewReader(manifest)
120+
err := schema.MediaTypeManifestList.Validate(r)
121+
122+
if got := err != nil; tt.fail != got {
123+
t.Errorf("test %d: expected validation failure %t but got %t, err %v", i, tt.fail, got, err)
124+
}
125+
}
126+
}
127+
45128
func TestBackwardsCompatibilityManifest(t *testing.T) {
46129
for i, tt := range []struct {
47130
manifest string

0 commit comments

Comments
 (0)