MCPcopy Create free account
hub / github.com/github/gh-aw / TestEngineAWFEnableApiProxy

Function TestEngineAWFEnableApiProxy

pkg/workflow/enable_api_proxy_test.go:31–178  ·  view source on GitHub ↗

TestEngineAWFEnableApiProxy tests that engines with LLM gateway support emit API proxy enablement in the AWF config file (new) or as --enable-api-proxy CLI flag (legacy: only when the workflow pins an old AWF version).

(t *testing.T)

Source from the content-addressed store, hash-verified

29// emit API proxy enablement in the AWF config file (new) or as --enable-api-proxy
30// CLI flag (legacy: only when the workflow pins an old AWF version).
31func TestEngineAWFEnableApiProxy(t *testing.T) {
32 // The current default AWF version supports --config, so apiProxy.enabled is expressed
33 // in the JSON config file written by the run: step via printf. Tests verify that
34 // "enable" appears inside the JSON blob that is embedded in the step content.
35 // For legacy (old version) workflows, --enable-api-proxy is still emitted as a CLI flag.
36
37 t.Run("Claude AWF command includes apiProxy enabled in config file", func(t *testing.T) {
38 workflowData := &WorkflowData{
39 Name: "test-workflow",
40 EngineConfig: &EngineConfig{
41 ID: "claude",
42 },
43 NetworkPermissions: &NetworkPermissions{
44 Firewall: &FirewallConfig{
45 Enabled: true,
46 },
47 },
48 }
49
50 engine := NewClaudeEngine()
51 steps := engine.GetExecutionSteps(workflowData, "test.log")
52
53 if len(steps) == 0 {
54 t.Fatal("Expected at least one execution step")
55 }
56
57 stepContent := strings.Join(steps[0], "\n")
58
59 // New behavior: apiProxy.enabled is expressed in the JSON config file.
60 // The step content contains the printf command that writes the config JSON.
61 if !strings.Contains(stepContent, `\"enabled\":true`) {
62 t.Error("Expected Claude AWF command to contain apiProxy enabled in config JSON")
63 }
64 })
65
66 t.Run("Copilot AWF command includes apiProxy enabled in config file", func(t *testing.T) {
67 workflowData := &WorkflowData{
68 Name: "test-workflow",
69 EngineConfig: &EngineConfig{
70 ID: "copilot",
71 },
72 NetworkPermissions: &NetworkPermissions{
73 Firewall: &FirewallConfig{
74 Enabled: true,
75 },
76 },
77 }
78
79 engine := NewCopilotEngine()
80 steps := engine.GetExecutionSteps(workflowData, "test.log")
81
82 stepContent := requireCopilotExecutionStep(t, steps)
83
84 if !strings.Contains(stepContent, `\"enabled\":true`) {
85 t.Error("Expected Copilot AWF command to contain apiProxy enabled in config JSON")
86 }
87 })
88

Callers

nothing calls this directly

Calls 10

GetExecutionStepsMethod · 0.95
NewClaudeEngineFunction · 0.85
NewCopilotEngineFunction · 0.85
NewCodexEngineFunction · 0.85
NewGeminiEngineFunction · 0.85
NewToolsFunction · 0.85
NewPiEngineFunction · 0.85
RunMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected