@@ -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 ,
@@ -8725,7 +8726,15 @@ func testExportAnnotationsMediaTypes(t *testing.T, sb integration.Sandbox) {
87258726 require .Equal (t , ocispecs .MediaTypeImageIndex , imgs2 .Index .MediaType )
87268727}
87278728
8728- func testExportAttestations (t * testing.T , sb integration.Sandbox ) {
8729+ func testExportAttestationsOCIArtifact (t * testing.T , sb integration.Sandbox ) {
8730+ testExportAttestations (t , sb , true )
8731+ }
8732+
8733+ func testExportAttestationsImageManifest (t * testing.T , sb integration.Sandbox ) {
8734+ testExportAttestations (t , sb , false )
8735+ }
8736+
8737+ func testExportAttestations (t * testing.T , sb integration.Sandbox , ociArtifact bool ) {
87298738 workers .CheckFeatureCompat (t , sb , workers .FeatureDirectPush )
87308739 requiresLinux (t )
87318740 c , err := New (sb .Context (), sb .Address ())
@@ -8845,8 +8854,9 @@ func testExportAttestations(t *testing.T, sb integration.Sandbox) {
88458854 {
88468855 Type : ExporterImage ,
88478856 Attrs : map [string ]string {
8848- "name" : strings .Join (targets , "," ),
8849- "push" : "true" ,
8857+ "name" : strings .Join (targets , "," ),
8858+ "push" : "true" ,
8859+ "oci-artifact" : strconv .FormatBool (ociArtifact ),
88508860 },
88518861 },
88528862 },
@@ -8876,12 +8886,25 @@ func testExportAttestations(t *testing.T, sb integration.Sandbox) {
88768886 for i , att := range atts .Images {
88778887 require .Equal (t , ocispecs .MediaTypeImageManifest , att .Desc .MediaType )
88788888 require .Equal (t , "unknown/unknown" , platforms .Format (* att .Desc .Platform ))
8879- require .Equal (t , "unknown/unknown" , att .Img .OS + "/" + att .Img .Architecture )
88808889 require .Equal (t , attestation .DockerAnnotationReferenceTypeDefault , att .Desc .Annotations [attestation .DockerAnnotationReferenceType ])
88818890 require .Equal (t , bases [i ].Desc .Digest .String (), att .Desc .Annotations [attestation .DockerAnnotationReferenceDigest ])
88828891 require .Equal (t , 2 , len (att .Layers ))
8883- require .Equal (t , len (att .Layers ), len (att .Img .RootFS .DiffIDs ))
8884- require .Equal (t , 0 , len (att .Img .History ))
8892+
8893+ if ociArtifact {
8894+ subject := att .Manifest .Subject
8895+ require .NotNil (t , subject )
8896+ require .Equal (t , bases [i ].Desc , * subject )
8897+ require .Equal (t , "application/vnd.docker.attestation.manifest.v1+json" , att .Manifest .ArtifactType )
8898+ require .Equal (t , ocispecs .DescriptorEmptyJSON , att .Manifest .Config )
8899+ } else {
8900+ require .Nil (t , att .Manifest .Subject )
8901+ require .Empty (t , att .Manifest .ArtifactType )
8902+
8903+ // image config is not included in the OCI artifact
8904+ require .Equal (t , "unknown/unknown" , att .Img .OS + "/" + att .Img .Architecture )
8905+ require .Equal (t , len (att .Layers ), len (att .Img .RootFS .DiffIDs ))
8906+ require .Equal (t , 0 , len (att .Img .History ))
8907+ }
88858908
88868909 var attest intoto.Statement
88878910 require .NoError (t , json .Unmarshal (att .LayersRaw [0 ], & attest ))
0 commit comments