40
40
GHA_ARTIFACT_PATH_BUILDERS = []string {"gha_go" , "gha_generic" }
41
41
// TODO(https://github.com/slsa-framework/slsa-verifier/issues/485): Merge this with
42
42
// GHA_ARTIFACT_PATH_BUILDERS.
43
- GHA_ARTIFACT_DOCKER_BUILDERS = []string {"gha_docker -based" }
44
- GHA_ARTIFACT_IMAGE_BUILDERS = []string {"gha_generic_container" }
45
- GCB_ARTIFACT_IMAGE_BUILDERS = []string {"gcb_container" }
43
+ GHA_ARTIFACT_CONTAINER_BUILDERS = []string {"gha_container -based" }
44
+ GHA_ARTIFACT_IMAGE_BUILDERS = []string {"gha_generic_container" }
45
+ GCB_ARTIFACT_IMAGE_BUILDERS = []string {"gcb_container" }
46
46
)
47
47
48
48
func getBuildersAndVersions (t * testing.T ,
@@ -1298,16 +1298,14 @@ func Test_runVerifyGCBArtifactImage(t *testing.T) {
1298
1298
}
1299
1299
}
1300
1300
1301
- // TODO(https://github.com/slsa-framework/slsa-verifier/issues/485): Version the test-cases
1302
- // when a version for the builder is released.
1303
- func Test_runVerifyGHADockerBased (t * testing.T ) {
1301
+ // TODO(#485): Version the test-cases when a version for the builder is released.
1302
+ func Test_runVerifyGHAContainerBased (t * testing.T ) {
1304
1303
// We cannot use t.Setenv due to parallelized tests.
1305
1304
os .Setenv ("SLSA_VERIFIER_EXPERIMENTAL" , "1" )
1306
1305
os .Setenv ("SLSA_VERIFIER_TESTING" , "1" )
1307
1306
1308
1307
t .Parallel ()
1309
1308
1310
- builder := "https://github.com/slsa-framework/slsa-github-generator/.github/workflows/builder_docker-based_slsa3.yml"
1311
1309
tests := []struct {
1312
1310
name string
1313
1311
artifacts []string
@@ -1319,44 +1317,38 @@ func Test_runVerifyGHADockerBased(t *testing.T) {
1319
1317
inputs map [string ]string
1320
1318
err error
1321
1319
}{
1322
- // TODO(#610): Re-enable these tests.
1323
- // {
1324
- // name: "valid main branch default",
1325
- // artifacts: []string{"workflow_dispatch.main.default"},
1326
- // source: "github.com/slsa-framework/example-package",
1327
- // pBuilderID: pString("https://github.com/slsa-framework/slsa-github-generator/.github/workflows/builder_docker-based_slsa3.yml"),
1328
- // },
1329
- // {
1330
- // name: "versioned tag no match empty tag workflow_dispatch",
1331
- // artifacts: []string{"workflow_dispatch.main.default"},
1332
- // source: "github.com/slsa-framework/example-package",
1333
- // pBuilderID: pString("https://github.com/slsa-framework/slsa-github-generator/.github/workflows/builder_docker-based_slsa3.yml"),
1334
- // pversiontag: pString("v1"),
1335
- // err: serrors.ErrorInvalidSemver,
1336
- // },
1337
- // {
1338
- // name: "tag no match empty tag workflow_dispatch",
1339
- // artifacts: []string{"workflow_dispatch.main.default"},
1340
- // source: "github.com/slsa-framework/example-package",
1341
- // pBuilderID: pString("https://github.com/slsa-framework/slsa-github-generator/.github/workflows/builder_docker-based_slsa3.yml"),
1342
- // ptag: pString("v1.2.3"),
1343
- // err: serrors.ErrorMismatchTag,
1344
- // },
1345
- // {
1346
- // name: "wrong branch master",
1347
- // artifacts: []string{"workflow_dispatch.main.default"},
1348
- // source: "github.com/slsa-framework/example-package",
1349
- // pbranch: pString("master"),
1350
- // pBuilderID: pString("https://github.com/slsa-framework/slsa-github-generator/.github/workflows/builder_docker-based_slsa3.yml"),
1351
- // err: serrors.ErrorMismatchBranch,
1352
- // },
1353
- // {
1354
- // name: "valid main branch set",
1355
- // artifacts: []string{"workflow_dispatch.main.default"},
1356
- // source: "github.com/slsa-framework/example-package",
1357
- // pBuilderID: pString("https://github.com/slsa-framework/slsa-github-generator/.github/workflows/builder_docker-based_slsa3.yml"),
1358
- // pbranch: pString("main"),
1359
- // },
1320
+ {
1321
+ name : "valid main branch default" ,
1322
+ artifacts : []string {"workflow_dispatch.main.default" },
1323
+ source : "github.com/slsa-framework/example-package" ,
1324
+ },
1325
+ {
1326
+ name : "versioned tag no match empty tag workflow_dispatch" ,
1327
+ artifacts : []string {"workflow_dispatch.main.default" },
1328
+ source : "github.com/slsa-framework/example-package" ,
1329
+ pversiontag : pString ("v1" ),
1330
+ err : serrors .ErrorInvalidSemver ,
1331
+ },
1332
+ {
1333
+ name : "tag no match empty tag workflow_dispatch" ,
1334
+ artifacts : []string {"workflow_dispatch.main.default" },
1335
+ source : "github.com/slsa-framework/example-package" ,
1336
+ ptag : pString ("v1.2.3" ),
1337
+ err : serrors .ErrorMismatchTag ,
1338
+ },
1339
+ {
1340
+ name : "wrong branch master" ,
1341
+ artifacts : []string {"workflow_dispatch.main.default" },
1342
+ source : "github.com/slsa-framework/example-package" ,
1343
+ pbranch : pString ("master" ),
1344
+ err : serrors .ErrorMismatchBranch ,
1345
+ },
1346
+ {
1347
+ name : "valid main branch set" ,
1348
+ artifacts : []string {"workflow_dispatch.main.default" },
1349
+ source : "github.com/slsa-framework/example-package" ,
1350
+ pbranch : pString ("main" ),
1351
+ },
1360
1352
{
1361
1353
name : "valid main branch default - invalid builderID" ,
1362
1354
artifacts : []string {"workflow_dispatch.main.default" },
@@ -1365,33 +1357,30 @@ func Test_runVerifyGHADockerBased(t *testing.T) {
1365
1357
err : serrors .ErrorUntrustedReusableWorkflow ,
1366
1358
},
1367
1359
{
1368
- name : "wrong source append A" ,
1369
- artifacts : []string {"workflow_dispatch.main.default" },
1370
- source : "github.com/slsa-framework/example-packageA" ,
1371
- pBuilderID : pString ("https://github.com/slsa-framework/slsa-github-generator/.github/workflows/builder_docker-based_slsa3.yml" ),
1372
- err : serrors .ErrorMismatchSource ,
1360
+ name : "wrong source append A" ,
1361
+ artifacts : []string {"workflow_dispatch.main.default" },
1362
+ source : "github.com/slsa-framework/example-packageA" ,
1363
+ err : serrors .ErrorMismatchSource ,
1373
1364
},
1374
1365
{
1375
- name : "wrong source prepend A" ,
1376
- artifacts : []string {"workflow_dispatch.main.default" },
1377
- source : "Agithub.com/slsa-framework/example-package" ,
1378
- pBuilderID : pString ("https://github.com/slsa-framework/slsa-github-generator/.github/workflows/builder_docker-based_slsa3.yml" ),
1379
- err : serrors .ErrorMismatchSource ,
1366
+ name : "wrong source prepend A" ,
1367
+ artifacts : []string {"workflow_dispatch.main.default" },
1368
+ source : "Agithub.com/slsa-framework/example-package" ,
1369
+ err : serrors .ErrorMismatchSource ,
1380
1370
},
1381
1371
{
1382
- name : "wrong source middle A" ,
1383
- artifacts : []string {"workflow_dispatch.main.default" },
1384
- source : "github.com/Aslsa-framework/example-package" ,
1385
- pBuilderID : pString ("https://github.com/slsa-framework/slsa-github-generator/.github/workflows/builder_docker-based_slsa3.yml" ),
1386
- err : serrors .ErrorMismatchSource ,
1372
+ name : "wrong source middle A" ,
1373
+ artifacts : []string {"workflow_dispatch.main.default" },
1374
+ source : "github.com/Aslsa-framework/example-package" ,
1375
+ err : serrors .ErrorMismatchSource ,
1387
1376
},
1388
1377
}
1389
1378
for _ , tt := range tests {
1390
1379
tt := tt // Re-initializing variable so it is not changed while executing the closure below
1391
1380
t .Run (tt .name , func (t * testing.T ) {
1392
1381
t .Parallel ()
1393
1382
1394
- checkVersions := getBuildersAndVersions (t , "" , nil , GHA_ARTIFACT_DOCKER_BUILDERS )
1383
+ checkVersions := getBuildersAndVersions (t , "" , nil , GHA_ARTIFACT_CONTAINER_BUILDERS )
1395
1384
1396
1385
for _ , v := range checkVersions {
1397
1386
testPath := filepath .Clean (filepath .Join (TEST_DIR , v , tt .artifacts [0 ]))
@@ -1408,9 +1397,16 @@ func Test_runVerifyGHADockerBased(t *testing.T) {
1408
1397
// 3. With only the name of the builder.
1409
1398
// 4. With no builder ID.
1410
1399
sv := path .Base (v )
1400
+ builder := "https://github.com/slsa-framework/slsa-github-generator/.github/workflows/builder_container-based_slsa3.yml"
1401
+
1402
+ refName := "@refs/tags/"
1403
+ if sv == "main" {
1404
+ refName = "@refs/heads/"
1405
+ }
1406
+ // TODO(#485): Add pString(builder + "@" + sv) when migrating to tagged builders
1407
+ // and remove main builder test.
1411
1408
builderIDs := []* string {
1412
- pString (builder + "@" + sv ),
1413
- pString (builder + "@refs/tags/" + sv ),
1409
+ pString (builder + refName + sv ),
1414
1410
pString (builder ),
1415
1411
nil ,
1416
1412
}
0 commit comments