MCPcopy Create free account
hub / github.com/conforma/cli / Test_ValidateImageCommandYAMLPolicyFile

Function Test_ValidateImageCommandYAMLPolicyFile

cmd/validate/image_test.go:527–615  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

525}
526
527func Test_ValidateImageCommandYAMLPolicyFile(t *testing.T) {
528 cases := []struct {
529 name string
530 config string
531 }{
532 {
533 name: "spec",
534 config: `
535description: My custom enterprise contract policy configuration
536sources:
537 - policy:
538 - quay.io/hacbs-contract/ec-release-policy:latest
539 config:
540 exclude:
541 - not_useful
542 - test:conftest-clair
543 include:
544 - always_checked
545 - "@salsa_one_collection"
546`,
547 },
548 {
549 name: "ecp",
550 config: `
551apiVersion: appstudio.redhat.com/v1alpha1
552kind: EnterpriseContractPolicy
553metadata:
554 name: enterprisecontractpolicy-sample
555spec:
556 description: My custom enterprise contract policy configuration
557 sources:
558 - policy:
559 - quay.io/hacbs-contract/ec-release-policy:latest
560 config:
561 exclude:
562 - not_useful
563 - test:conftest-clair
564 include:
565 - always_checked
566 - "@salsa_one_collection"
567`,
568 },
569 }
570
571 for _, c := range cases {
572 t.Run(c.name, func(t *testing.T) {
573 validateImageCmd := validateImageCmd(happyValidator())
574 cmd := setUpCobra(validateImageCmd)
575
576 client := fake.FakeClient{}
577 commonMockClient(&client)
578 fs := afero.NewMemMapFs()
579 ctx := utils.WithFS(context.Background(), fs)
580 ctx = oci.WithClient(ctx, &client)
581
582 mdl := MockDownloader{}
583 mdl.On("Download", mock.Anything, "quay.io/hacbs-contract/ec-release-policy:latest", false).Return(&ociMetadata.OCIMetadata{Digest: "sha256:da54bca5477bf4e3449bc37de1822888fa0fbb8d89c640218cb31b987374d357"}, nil)
584 ctx = context.WithValue(ctx, source.DownloaderFuncKey, &mdl)

Callers

nothing calls this directly

Calls 9

WithFSFunction · 0.92
WithClientFunction · 0.92
SetTestRekorPublicKeyFunction · 0.92
validateImageCmdFunction · 0.85
happyValidatorFunction · 0.85
commonMockClientFunction · 0.85
setUpCobraFunction · 0.70
RunMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected