(t *testing.T)
| 322 | } |
| 323 | |
| 324 | func TestGeminiEngineFirewallIntegration(t *testing.T) { |
| 325 | engine := NewGeminiEngine() |
| 326 | |
| 327 | t.Run("firewall enabled", func(t *testing.T) { |
| 328 | workflowData := &WorkflowData{ |
| 329 | Name: "test-workflow", |
| 330 | NetworkPermissions: &NetworkPermissions{ |
| 331 | Allowed: []string{"defaults"}, |
| 332 | Firewall: &FirewallConfig{ |
| 333 | Enabled: true, |
| 334 | }, |
| 335 | }, |
| 336 | } |
| 337 | |
| 338 | steps := engine.GetExecutionSteps(workflowData, "/tmp/test.log") |
| 339 | require.Len(t, steps, 2, "Should generate settings step and execution step") |
| 340 | |
| 341 | stepContent := strings.Join(steps[1], "\n") |
| 342 | |
| 343 | // Should use AWF command |
| 344 | assert.Contains(t, stepContent, "awf", "Should use AWF when firewall is enabled") |
| 345 | // With config file support, domains and apiProxy are in the JSON config |
| 346 | assert.Contains(t, stepContent, "allowDomains", "Should include allowDomains in config JSON") |
| 347 | assert.Contains(t, stepContent, `\"enabled\":true`, "Should include apiProxy enabled in config JSON") |
| 348 | assert.Contains(t, stepContent, "GEMINI_API_BASE_URL: http://host.docker.internal:10003", "Should set GEMINI_API_BASE_URL to LLM gateway URL") |
| 349 | }) |
| 350 | |
| 351 | t.Run("firewall disabled", func(t *testing.T) { |
| 352 | workflowData := &WorkflowData{ |
| 353 | Name: "test-workflow", |
| 354 | NetworkPermissions: &NetworkPermissions{ |
| 355 | Firewall: &FirewallConfig{ |
| 356 | Enabled: false, |
| 357 | }, |
| 358 | }, |
| 359 | } |
| 360 | |
| 361 | steps := engine.GetExecutionSteps(workflowData, "/tmp/test.log") |
| 362 | require.Len(t, steps, 2, "Should generate settings step and execution step") |
| 363 | |
| 364 | stepContent := strings.Join(steps[1], "\n") |
| 365 | |
| 366 | // Should use simple command without AWF |
| 367 | assert.Contains(t, stepContent, "set -o pipefail", "Should use simple command with pipefail") |
| 368 | assert.NotContains(t, stepContent, "awf", "Should not use AWF when firewall is disabled") |
| 369 | assert.NotContains(t, stepContent, "GEMINI_API_BASE_URL", "Should not set GEMINI_API_BASE_URL when firewall is disabled") |
| 370 | }) |
| 371 | } |
| 372 | |
| 373 | func TestComputeGeminiToolsCore(t *testing.T) { |
| 374 | t.Run("nil tools includes default read-only tools", func(t *testing.T) { |
nothing calls this directly
no test coverage detected