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

Method TestInvalidInlineMaterial

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

Source from the content-addressed store, hash-verified

558}
559
560func (s *testSuite) TestInvalidInlineMaterial() {
561 schema := &v12.CraftingSchema{
562 Materials: []*v12.CraftingSchema_Material{
563 {
564 Name: "sbom",
565 Type: v12.CraftingSchema_Material_SBOM_SPDX_JSON,
566 },
567 },
568 Policies: &v12.Policies{
569 Materials: []*v12.PolicyAttachment{
570 {
571 Policy: &v12.PolicyAttachment_Ref{Ref: "file://testdata/sbom_syft.yaml"},
572 },
573 },
574 Attestation: nil,
575 },
576 }
577 material := &v1.Attestation_Material{
578 M: &v1.Attestation_Material_Artifact_{Artifact: &v1.Attestation_Material_Artifact{
579 Content: []byte(`{"this": { "is": "not", "a": "sbom"}}`),
580 }},
581 MaterialType: v12.CraftingSchema_Material_SBOM_SPDX_JSON,
582 InlineCas: true,
583 }
584
585 verifier := NewPolicyVerifier(schema.Policies, nil, &s.logger)
586
587 res, err := verifier.VerifyMaterial(context.TODO(), material, "")
588 s.Require().NoError(err)
589 s.Len(res, 1)
590 s.Equal("made-with-syft", res[0].Name)
591 s.Len(res[0].Violations, 1)
592 s.Equal("made-with-syft", res[0].Violations[0].Subject)
593 s.Equal("Not made with syft", res[0].Violations[0].Message)
594}
595
596// TestVerifyMaterialScopedRuntimeInputs reproduces the trusted-binaries scenario
597// from PFM-6530: two policies both declare `ignored_paths`, and a runtime input

Callers

nothing calls this directly

Calls 2

VerifyMaterialMethod · 0.95
NewPolicyVerifierFunction · 0.85

Tested by

no test coverage detected