(t *testing.T)
| 479 | } |
| 480 | |
| 481 | func Test_ValidateImageCommandKeyless(t *testing.T) { |
| 482 | called := false |
| 483 | validateImageCmd := validateImageCmd(func(_ context.Context, _ app.SnapshotComponent, _ *app.SnapshotSpec, p policy.Policy, _ []evaluator.Evaluator, _ bool) (*output.Output, error) { |
| 484 | assert.Equal(t, cosign.Identity{ |
| 485 | Issuer: "my-certificate-oidc-issuer", |
| 486 | Subject: "my-certificate-identity", |
| 487 | IssuerRegExp: "my-certificate-oidc-issuer-regexp", |
| 488 | SubjectRegExp: "my-certificate-identity-regexp", |
| 489 | }, p.Identity()) |
| 490 | |
| 491 | called = true |
| 492 | |
| 493 | return &output.Output{}, nil |
| 494 | }) |
| 495 | cmd := setUpCobra(validateImageCmd) |
| 496 | |
| 497 | client := fake.FakeClient{} |
| 498 | commonMockClient(&client) |
| 499 | ctx := utils.WithFS(context.Background(), afero.NewMemMapFs()) |
| 500 | ctx = oci.WithClient(ctx, &client) |
| 501 | cmd.SetContext(ctx) |
| 502 | |
| 503 | cmd.SetArgs(append(rootArgs, []string{ |
| 504 | "--image", |
| 505 | "registry/image:tag", |
| 506 | "--policy", |
| 507 | "", |
| 508 | "--certificate-identity", |
| 509 | "my-certificate-identity", |
| 510 | "--certificate-oidc-issuer", |
| 511 | "my-certificate-oidc-issuer", |
| 512 | "--certificate-identity-regexp", |
| 513 | "my-certificate-identity-regexp", |
| 514 | "--certificate-oidc-issuer-regexp", |
| 515 | "my-certificate-oidc-issuer-regexp", |
| 516 | }...)) |
| 517 | |
| 518 | utils.SetTestRekorPublicKey(t) |
| 519 | utils.SetTestFulcioRoots(t) |
| 520 | utils.SetTestCTLogPublicKey(t) |
| 521 | |
| 522 | err := cmd.Execute() |
| 523 | assert.NoError(t, err) |
| 524 | assert.True(t, called) |
| 525 | } |
| 526 | |
| 527 | func Test_ValidateImageCommandYAMLPolicyFile(t *testing.T) { |
| 528 | cases := []struct { |
nothing calls this directly
no test coverage detected