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

Method TestValidInlineMaterial

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

Source from the content-addressed store, hash-verified

520}
521
522func (s *testSuite) TestValidInlineMaterial() {
523 content, err := os.ReadFile("testdata/sbom-spdx.json")
524 s.Require().NoError(err)
525
526 schema := &v12.CraftingSchema{
527 Materials: []*v12.CraftingSchema_Material{
528 {
529 Name: "sbom",
530 Type: v12.CraftingSchema_Material_SBOM_SPDX_JSON,
531 },
532 },
533 Policies: &v12.Policies{
534 Materials: []*v12.PolicyAttachment{
535 {
536 Policy: &v12.PolicyAttachment_Ref{Ref: "file://testdata/sbom_syft.yaml"},
537 },
538 },
539 Attestation: nil,
540 },
541 }
542 material := &v1.Attestation_Material{
543 M: &v1.Attestation_Material_Artifact_{Artifact: &v1.Attestation_Material_Artifact{
544 Content: content,
545 }},
546 MaterialType: v12.CraftingSchema_Material_SBOM_SPDX_JSON,
547 InlineCas: true,
548 }
549
550 verifier := NewPolicyVerifier(schema.Policies, nil, &s.logger)
551
552 res, err := verifier.VerifyMaterial(context.TODO(), material, "")
553 s.Require().NoError(err)
554 s.Len(res, 1)
555 s.Equal("made-with-syft", res[0].Name)
556 s.Equal(v12.CraftingSchema_Material_SBOM_SPDX_JSON, res[0].GetType())
557 s.Len(res[0].Violations, 0)
558}
559
560func (s *testSuite) TestInvalidInlineMaterial() {
561 schema := &v12.CraftingSchema{

Callers

nothing calls this directly

Calls 3

VerifyMaterialMethod · 0.95
NewPolicyVerifierFunction · 0.85
GetTypeMethod · 0.45

Tested by

no test coverage detected