@@ -192,7 +192,8 @@ var allTests = []func(t *testing.T, sb integration.Sandbox){
192192 testPullWithLayerLimit ,
193193 testExportAnnotations ,
194194 testExportAnnotationsMediaTypes ,
195- testExportAttestations ,
195+ testExportAttestationsOCIArtifact ,
196+ testExportAttestationsImageManifest ,
196197 testExportedImageLabels ,
197198 testAttestationDefaultSubject ,
198199 testSourceDateEpochLayerTimestamps ,
@@ -8833,7 +8834,15 @@ func testExportAnnotationsMediaTypes(t *testing.T, sb integration.Sandbox) {
88338834 require .Equal (t , ocispecs .MediaTypeImageIndex , imgs2 .Index .MediaType )
88348835}
88358836
8836- func testExportAttestations (t * testing.T , sb integration.Sandbox ) {
8837+ func testExportAttestationsOCIArtifact (t * testing.T , sb integration.Sandbox ) {
8838+ testExportAttestations (t , sb , true )
8839+ }
8840+
8841+ func testExportAttestationsImageManifest (t * testing.T , sb integration.Sandbox ) {
8842+ testExportAttestations (t , sb , false )
8843+ }
8844+
8845+ func testExportAttestations (t * testing.T , sb integration.Sandbox , ociArtifact bool ) {
88378846 workers .CheckFeatureCompat (t , sb , workers .FeatureDirectPush )
88388847 requiresLinux (t )
88398848 c , err := New (sb .Context (), sb .Address ())
@@ -8953,8 +8962,9 @@ func testExportAttestations(t *testing.T, sb integration.Sandbox) {
89538962 {
89548963 Type : ExporterImage ,
89558964 Attrs : map [string ]string {
8956- "name" : strings .Join (targets , "," ),
8957- "push" : "true" ,
8965+ "name" : strings .Join (targets , "," ),
8966+ "push" : "true" ,
8967+ "oci-artifact" : strconv .FormatBool (ociArtifact ),
89588968 },
89598969 },
89608970 },
@@ -8984,12 +8994,25 @@ func testExportAttestations(t *testing.T, sb integration.Sandbox) {
89848994 for i , att := range atts .Images {
89858995 require .Equal (t , ocispecs .MediaTypeImageManifest , att .Desc .MediaType )
89868996 require .Equal (t , "unknown/unknown" , platforms .Format (* att .Desc .Platform ))
8987- require .Equal (t , "unknown/unknown" , att .Img .OS + "/" + att .Img .Architecture )
89888997 require .Equal (t , attestation .DockerAnnotationReferenceTypeDefault , att .Desc .Annotations [attestation .DockerAnnotationReferenceType ])
89898998 require .Equal (t , bases [i ].Desc .Digest .String (), att .Desc .Annotations [attestation .DockerAnnotationReferenceDigest ])
89908999 require .Equal (t , 2 , len (att .Layers ))
8991- require .Equal (t , len (att .Layers ), len (att .Img .RootFS .DiffIDs ))
8992- require .Equal (t , 0 , len (att .Img .History ))
9000+
9001+ if ociArtifact {
9002+ subject := att .Manifest .Subject
9003+ require .NotNil (t , subject )
9004+ require .Equal (t , bases [i ].Desc , * subject )
9005+ require .Equal (t , "application/vnd.docker.attestation.manifest.v1+json" , att .Manifest .ArtifactType )
9006+ require .Equal (t , ocispecs .DescriptorEmptyJSON , att .Manifest .Config )
9007+ } else {
9008+ require .Nil (t , att .Manifest .Subject )
9009+ require .Empty (t , att .Manifest .ArtifactType )
9010+
9011+ // image config is not included in the OCI artifact
9012+ require .Equal (t , "unknown/unknown" , att .Img .OS + "/" + att .Img .Architecture )
9013+ require .Equal (t , len (att .Layers ), len (att .Img .RootFS .DiffIDs ))
9014+ require .Equal (t , 0 , len (att .Img .History ))
9015+ }
89939016
89949017 var attest intoto.Statement
89959018 require .NoError (t , json .Unmarshal (att .LayersRaw [0 ], & attest ))
0 commit comments