(t *testing.T)
| 10 | ) |
| 11 | |
| 12 | func TestCustomAWFConfiguration(t *testing.T) { |
| 13 | t.Run("custom command replaces AWF installation", func(t *testing.T) { |
| 14 | agentConfig := &AgentSandboxConfig{ |
| 15 | ID: "awf", |
| 16 | Command: "docker run my-custom-awf", |
| 17 | } |
| 18 | |
| 19 | step := generateAWFInstallationStep("", agentConfig) |
| 20 | stepStr := strings.Join(step, "\n") |
| 21 | |
| 22 | // Step should be empty (installation skipped) |
| 23 | if len(step) > 0 { |
| 24 | t.Error("Expected installation step to be skipped when custom command is specified") |
| 25 | } |
| 26 | |
| 27 | // Verify no curl commands |
| 28 | if strings.Contains(stepStr, "curl") { |
| 29 | t.Error("Should not contain curl command when custom command is specified") |
| 30 | } |
| 31 | }) |
| 32 | |
| 33 | t.Run("nil agent config uses standard installation", func(t *testing.T) { |
| 34 | step := generateAWFInstallationStep("", nil) |
| 35 | stepStr := strings.Join(step, "\n") |
| 36 | |
| 37 | // Step should not be empty |
| 38 | if len(step) == 0 { |
| 39 | t.Error("Expected installation step to be generated when no agent config is provided") |
| 40 | } |
| 41 | |
| 42 | // Should contain reference to installation script |
| 43 | if !strings.Contains(stepStr, "install_awf_binary.sh") { |
| 44 | t.Error("Should contain reference to install_awf_binary.sh script for standard installation") |
| 45 | } |
| 46 | }) |
| 47 | |
| 48 | t.Run("agent config without command uses standard installation", func(t *testing.T) { |
| 49 | agentConfig := &AgentSandboxConfig{ |
| 50 | ID: "awf", |
| 51 | } |
| 52 | |
| 53 | step := generateAWFInstallationStep("", agentConfig) |
| 54 | stepStr := strings.Join(step, "\n") |
| 55 | |
| 56 | // Step should not be empty |
| 57 | if len(step) == 0 { |
| 58 | t.Error("Expected installation step to be generated when command is not specified") |
| 59 | } |
| 60 | |
| 61 | // Should contain reference to installation script |
| 62 | if !strings.Contains(stepStr, "install_awf_binary.sh") { |
| 63 | t.Error("Should contain reference to install_awf_binary.sh script for standard installation") |
| 64 | } |
| 65 | }) |
| 66 | |
| 67 | t.Run("sudo: false agent config passes --rootless to install script", func(t *testing.T) { |
| 68 | agentConfig := &AgentSandboxConfig{ |
| 69 | ID: "awf", |
nothing calls this directly
no test coverage detected