@@ -232,6 +232,46 @@ func TestDescriptor(t *testing.T) {
232232` ,
233233 fail : true ,
234234 },
235+
236+ // expected success: artifactType is present and an IANA compliant value
237+ {
238+ descriptor : `
239+ {
240+ "mediaType": "application/vnd.oci.image.manifest.v1+json",
241+ "artifactType": "application/vnd.oci.image.manifest.v1+json",
242+ "size": 7682,
243+ "digest": "sha256:5b0bcabd1ed22e9fb1310cf6c2dec7cdef19f0ad69efa1f392e94a4333501270"
244+ }
245+ ` ,
246+ fail : false ,
247+ },
248+
249+ // expected failure: artifactType does not match pattern (invalid first subtype character)
250+ {
251+ descriptor : `
252+ {
253+ "mediaType": "application/vnd.oci.image.manifest.v1+json",
254+ "artifactType": "foo/.bar",
255+ "size": 7682,
256+ "digest": "sha256:5b0bcabd1ed22e9fb1310cf6c2dec7cdef19f0ad69efa1f392e94a4333501270"
257+ }
258+ ` ,
259+ fail : true ,
260+ },
261+
262+ // expected success: data field is present and has base64 content
263+ {
264+ descriptor : `
265+ {
266+ "mediaType": "text/plain",
267+ "size": 34,
268+ "data": "aHR0cHM6Ly9naXRodWIuY29tL29wZW5jb250YWluZXJzCg==",
269+ "digest": "sha256:2690af59371e9eca9453dc29882643f46e5ca47ec2862bd517b5e17351325153"
270+ }
271+ ` ,
272+ fail : false ,
273+ },
274+
235275 {
236276 descriptor : `{
237277 "mediaType": "application/vnd.oci.image.config.v1+json",
@@ -292,6 +332,17 @@ func TestDescriptor(t *testing.T) {
292332 "mediaType": "application/vnd.oci.image.config.v1+json"
293333 }` ,
294334 },
335+ {
336+ descriptor : `
337+ {
338+ "mediaType": "text/plain",
339+ "size": 34,
340+ "data": "aHR0cHM6Ly9naXRodWIuY29tL29wZW5jb250YWluZXJzCg",
341+ "digest": "sha256:2690af59371e9eca9453dc29882643f46e5ca47ec2862bd517b5e17351325153"
342+ }
343+ ` ,
344+ fail : true ,
345+ },
295346 } {
296347 r := strings .NewReader (tt .descriptor )
297348 err := schema .ValidatorMediaTypeDescriptor .Validate (r )
0 commit comments