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

Function TestNewEngine

pkg/policies/engine/wasm/engine_test.go:30–58  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

28)
29
30func TestNewEngine(t *testing.T) {
31 t.Run("default options", func(t *testing.T) {
32 eng := NewEngine()
33 assert.NotNil(t, eng)
34 assert.Equal(t, 5*time.Second, eng.executionTimeout)
35 assert.False(t, eng.IncludeRawData)
36 assert.False(t, eng.EnablePrint)
37 // Base allowed hostnames should be included by default
38 assert.Contains(t, eng.AllowedHostnames, "www.chainloop.dev")
39 assert.Contains(t, eng.AllowedHostnames, "www.cisa.gov")
40 })
41
42 t.Run("with custom options", func(t *testing.T) {
43 eng := NewEngine(
44 engine.WithExecutionTimeout(30*time.Second),
45 engine.WithIncludeRawData(true),
46 engine.WithEnablePrint(true),
47 engine.WithAllowedHostnames("api.example.com"),
48 )
49 assert.NotNil(t, eng)
50 assert.Equal(t, 30*time.Second, eng.executionTimeout)
51 assert.True(t, eng.IncludeRawData)
52 assert.True(t, eng.EnablePrint)
53 // Should include both custom and base hostnames
54 assert.Contains(t, eng.AllowedHostnames, "api.example.com")
55 assert.Contains(t, eng.AllowedHostnames, "www.chainloop.dev")
56 assert.Contains(t, eng.AllowedHostnames, "www.cisa.gov")
57 })
58}
59
60func TestEngineVerify_InvalidWASM(t *testing.T) {
61 eng := NewEngine()

Callers

nothing calls this directly

Calls 6

WithExecutionTimeoutFunction · 0.92
WithIncludeRawDataFunction · 0.92
WithEnablePrintFunction · 0.92
WithAllowedHostnamesFunction · 0.92
NewEngineFunction · 0.70
RunMethod · 0.45

Tested by

no test coverage detected