TestSimpleWASMExecution verifies that basic WASM policy execution works
(t *testing.T)
| 115 | |
| 116 | // TestSimpleWASMExecution verifies that basic WASM policy execution works |
| 117 | func 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 | // |