@@ -7277,6 +7277,62 @@ func testExportAttestations(t *testing.T, sb integration.Sandbox) {
7277
7277
require .Equal (t , subjects , attest2 .Subject )
7278
7278
}
7279
7279
})
7280
+
7281
+ t .Run ("tar" , func (t * testing.T ) {
7282
+ dir := t .TempDir ()
7283
+ out := filepath .Join (dir , "out.tar" )
7284
+ outW , err := os .Create (out )
7285
+ require .NoError (t , err )
7286
+
7287
+ _ , err = c .Build (sb .Context (), SolveOpt {
7288
+ Exports : []ExportEntry {
7289
+ {
7290
+ Type : ExporterTar ,
7291
+ Output : fixedWriteCloser (outW ),
7292
+ Attrs : map [string ]string {
7293
+ "attestation-prefix" : "test." ,
7294
+ },
7295
+ },
7296
+ },
7297
+ }, "" , frontend , nil )
7298
+ require .NoError (t , err )
7299
+
7300
+ dt , err := os .ReadFile (out )
7301
+ require .NoError (t , err )
7302
+
7303
+ m , err := testutil .ReadTarToMap (dt , false )
7304
+ require .NoError (t , err )
7305
+
7306
+ for _ , p := range ps {
7307
+ var attest intoto.Statement
7308
+ dt := m [path .Join (strings .ReplaceAll (platforms .Format (p ), "/" , "_" ), "test.attestation.json" )].Data
7309
+ require .NoError (t , json .Unmarshal (dt , & attest ))
7310
+
7311
+ require .Equal (t , "https://in-toto.io/Statement/v0.1" , attest .Type )
7312
+ require .Equal (t , "https://example.com/attestations/v1.0" , attest .PredicateType )
7313
+ require .Equal (t , map [string ]interface {}{"success" : true }, attest .Predicate )
7314
+
7315
+ require .Equal (t , []intoto.Subject {{
7316
+ Name : "greeting" ,
7317
+ Digest : result .ToDigestMap (digest .Canonical .FromString ("hello " + platforms .Format (p ) + "!" )),
7318
+ }}, attest .Subject )
7319
+
7320
+ var attest2 intoto.Statement
7321
+ dt = m [path .Join (strings .ReplaceAll (platforms .Format (p ), "/" , "_" ), "test.attestation2.json" )].Data
7322
+ require .NoError (t , json .Unmarshal (dt , & attest2 ))
7323
+
7324
+ require .Equal (t , "https://in-toto.io/Statement/v0.1" , attest2 .Type )
7325
+ require .Equal (t , "https://example.com/attestations2/v1.0" , attest2 .PredicateType )
7326
+ require .Nil (t , attest2 .Predicate )
7327
+ subjects := []intoto.Subject {{
7328
+ Name : "/attestation.json" ,
7329
+ Digest : map [string ]string {
7330
+ "sha256" : successDigest .Encoded (),
7331
+ },
7332
+ }}
7333
+ require .Equal (t , subjects , attest2 .Subject )
7334
+ }
7335
+ })
7280
7336
}
7281
7337
7282
7338
func testAttestationDefaultSubject (t * testing.T , sb integration.Sandbox ) {
0 commit comments