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

Function TestChrootModeInAWFContainer

pkg/workflow/gh_cli_mount_test.go:11–157  ·  view source on GitHub ↗

TestChrootModeInAWFContainer tests that AWF uses chroot mode (default in v0.15.0+) for transparent host access

(t *testing.T)

Source from the content-addressed store, hash-verified

9
10// TestChrootModeInAWFContainer tests that AWF uses chroot mode (default in v0.15.0+) for transparent host access
11func TestChrootModeInAWFContainer(t *testing.T) {
12 t.Run("chroot mode is enabled by default when firewall is enabled", func(t *testing.T) {
13 workflowData := &WorkflowData{
14 Name: "test-workflow",
15 EngineConfig: &EngineConfig{
16 ID: "copilot",
17 },
18 NetworkPermissions: &NetworkPermissions{
19 Firewall: &FirewallConfig{
20 Enabled: true,
21 },
22 },
23 }
24
25 engine := NewCopilotEngine()
26 steps := engine.GetExecutionSteps(workflowData, "test.log")
27
28 stepContent := requireCopilotExecutionStep(t, steps)
29
30 // Check that AWF is used (chroot mode is default in v0.15.0+)
31 if !strings.Contains(stepContent, "sudo -E awf") {
32 t.Error("Expected AWF command for transparent host access")
33 }
34 })
35
36 t.Run("AWF command is NOT used when firewall is disabled", func(t *testing.T) {
37 workflowData := &WorkflowData{
38 Name: "test-workflow",
39 EngineConfig: &EngineConfig{
40 ID: "copilot",
41 },
42 SandboxConfig: &SandboxConfig{
43 Agent: &AgentSandboxConfig{
44 Disabled: true,
45 },
46 },
47 }
48
49 engine := NewCopilotEngine()
50 steps := engine.GetExecutionSteps(workflowData, "test.log")
51
52 stepContent := requireCopilotExecutionStep(t, steps)
53
54 // Check that AWF command is not used
55 if strings.Contains(stepContent, "awf") {
56 t.Error("Expected no AWF command when firewall is disabled")
57 }
58 })
59
60 t.Run("chroot mode replaces individual binary mounts", func(t *testing.T) {
61 workflowData := &WorkflowData{
62 Name: "test-workflow",
63 EngineConfig: &EngineConfig{
64 ID: "copilot",
65 },
66 NetworkPermissions: &NetworkPermissions{
67 Firewall: &FirewallConfig{
68 Enabled: true,

Callers

nothing calls this directly

Calls 6

GetExecutionStepsMethod · 0.95
NewCopilotEngineFunction · 0.85
RunMethod · 0.45
ErrorMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected