TestValidateSingleVSA tests the single VSA validation function
(t *testing.T)
| 967 | |
| 968 | // TestValidateSingleVSA tests the single VSA validation function |
| 969 | func TestValidateSingleVSA(t *testing.T) { |
| 970 | tests := []struct { |
| 971 | name string |
| 972 | data *validateVSAData |
| 973 | args []string |
| 974 | expectError bool |
| 975 | errorMsg string |
| 976 | }{ |
| 977 | { |
| 978 | name: "valid VSA validation with args", |
| 979 | data: &validateVSAData{ |
| 980 | vsaIdentifier: "", |
| 981 | policyConfig: "test-policy.yaml", |
| 982 | vsaExpirationStr: "24h", |
| 983 | vsaExpiration: 24 * time.Hour, |
| 984 | ignoreSignatureVerification: true, |
| 985 | policySpec: ecapi.EnterpriseContractPolicySpec{ |
| 986 | Sources: []ecapi.Source{ |
| 987 | {Name: "test", Policy: []string{"test-policy"}}, |
| 988 | }, |
| 989 | }, |
| 990 | }, |
| 991 | args: []string{"sha256:abc123"}, |
| 992 | expectError: false, |
| 993 | }, |
| 994 | { |
| 995 | name: "valid VSA validation with flag", |
| 996 | data: &validateVSAData{ |
| 997 | vsaIdentifier: "sha256:abc123", |
| 998 | policyConfig: "test-policy.yaml", |
| 999 | vsaExpirationStr: "24h", |
| 1000 | vsaExpiration: 24 * time.Hour, |
| 1001 | ignoreSignatureVerification: true, |
| 1002 | policySpec: ecapi.EnterpriseContractPolicySpec{ |
| 1003 | Sources: []ecapi.Source{ |
| 1004 | {Name: "test", Policy: []string{"test-policy"}}, |
| 1005 | }, |
| 1006 | }, |
| 1007 | }, |
| 1008 | args: []string{}, |
| 1009 | expectError: false, |
| 1010 | }, |
| 1011 | { |
| 1012 | name: "error with missing retriever", |
| 1013 | data: &validateVSAData{ |
| 1014 | vsaIdentifier: "sha256:abc123", |
| 1015 | policyConfig: "test-policy.yaml", |
| 1016 | vsaExpirationStr: "24h", |
| 1017 | vsaExpiration: 24 * time.Hour, |
| 1018 | ignoreSignatureVerification: true, |
| 1019 | retriever: nil, |
| 1020 | policySpec: ecapi.EnterpriseContractPolicySpec{ |
| 1021 | Sources: []ecapi.Source{ |
| 1022 | {Name: "test", Policy: []string{"test-policy"}}, |
| 1023 | }, |
| 1024 | }, |
| 1025 | }, |
| 1026 | args: []string{}, |
nothing calls this directly
no test coverage detected