MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / TestMultiKindAWithIgnore

Method TestMultiKindAWithIgnore

pkg/policies/policies_test.go:1238–1329  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1236}
1237
1238func (s *testSuite) TestMultiKindAWithIgnore() {
1239 cases := []struct {
1240 name string
1241 policy string
1242 material string
1243 expectErr bool
1244 expectedEvaluations int
1245 expectSkipped bool
1246 expectReasons []string
1247 expecteIgnore bool
1248 }{
1249 {
1250 name: "scripts should not be ignored and skipped",
1251 policy: "file://testdata/policy_multi_kind_with_ignore.yaml",
1252 material: "{\"specVersion\": \"1.4\"}",
1253 expectedEvaluations: 1,
1254 expectSkipped: true,
1255 expectReasons: []string{"this on is skipped"},
1256 },
1257 {
1258 name: "scripts should be ignored",
1259 policy: "file://testdata/policy_multi_kind_with_ignore.yaml",
1260 material: "{\"specVersion\": \"1.0\"}",
1261 expectedEvaluations: 0,
1262 expecteIgnore: true,
1263 },
1264 {
1265 name: "all scripts should not be ignored",
1266 policy: "file://testdata/policy_multi_kind_with_ignore.yaml",
1267 material: "{\"specVersion\": \"1.4\"}",
1268 expectedEvaluations: 1,
1269 expectSkipped: false,
1270 },
1271 }
1272
1273 for _, tc := range cases {
1274 s.Run(tc.name, func() {
1275 schema := &v12.CraftingSchema{
1276 Materials: []*v12.CraftingSchema_Material{
1277 {
1278 Name: "sbom",
1279 Type: v12.CraftingSchema_Material_SBOM_CYCLONEDX_JSON,
1280 },
1281 },
1282 Policies: &v12.Policies{
1283 Materials: []*v12.PolicyAttachment{
1284 {
1285 Policy: &v12.PolicyAttachment_Ref{Ref: tc.policy},
1286 },
1287 },
1288 },
1289 }
1290
1291 material := &v1.Attestation_Material{
1292 M: &v1.Attestation_Material_Artifact_{Artifact: &v1.Attestation_Material_Artifact{
1293 Content: []byte(tc.material),
1294 }},
1295 MaterialType: v12.CraftingSchema_Material_SBOM_CYCLONEDX_JSON,

Callers

nothing calls this directly

Calls 4

VerifyMaterialMethod · 0.95
NewPolicyVerifierFunction · 0.85
ErrorMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected