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

Function TestSimpleWASMExecution

pkg/policies/engine/wasm/engine_test.go:117–139  ·  view source on GitHub ↗

TestSimpleWASMExecution verifies that basic WASM policy execution works

(t *testing.T)

Source from the content-addressed store, hash-verified

115
116// TestSimpleWASMExecution verifies that basic WASM policy execution works
117func TestSimpleWASMExecution(t *testing.T) {
118 // Load a simple test WASM policy
119 wasmPath := filepath.Join("testdata", "simple_test_policy.wasm")
120 wasmBytes, err := os.ReadFile(wasmPath)
121 require.NoError(t, err, "Failed to load simple test WASM policy")
122
123 eng := NewEngine()
124 ctx := context.Background()
125
126 policy := &engine.Policy{
127 Name: "simple-test",
128 Source: wasmBytes,
129 }
130 input := []byte(`{}`)
131
132 result, err := eng.Verify(ctx, policy, input, nil)
133 require.NoError(t, err, "Policy execution should not error")
134 require.NotNil(t, result)
135
136 // Should have one violation: "test violation"
137 assert.Len(t, result.Violations, 1)
138 assert.Equal(t, "test violation", result.Violations[0].Violation)
139}
140
141// TestFilesystemIsolation verifies that WASM policies CANNOT access the host filesystem
142//

Callers

nothing calls this directly

Calls 2

VerifyMethod · 0.95
NewEngineFunction · 0.70

Tested by

no test coverage detected