@@ -6,52 +6,52 @@ import (
7func TestPermissionService_AllowedCommands(t *testing.T) {
7func TestPermissionService_AllowedCommands(t *testing.T) {
8 tests := []struct {
8 tests := []struct {
9− name string
9+ name string
10− allowedCommands []string
10+ allowedTools []string
11− toolName string
11+ toolName string
12− action string
12+ action string
13− expected bool
13+ expected bool
16− name: "tool in allowlist",
16+ name: "tool in allowlist",
17− allowedCommands: []string{"bash", "view"},
17+ allowedTools: []string{"bash", "view"},
18− toolName: "bash",
18+ toolName: "bash",
19− action: "execute",
19+ action: "execute",
20− expected: true,
20+ expected: true,
23− name: "tool:action in allowlist",
23+ name: "tool:action in allowlist",
24− allowedCommands: []string{"bash:execute", "edit:create"},
24+ allowedTools: []string{"bash:execute", "edit:create"},
25− toolName: "bash",
25+ toolName: "bash",
26− action: "execute",
26+ action: "execute",
27− expected: true,
27+ expected: true,
30− name: "tool not in allowlist",
30+ name: "tool not in allowlist",
31− allowedCommands: []string{"view", "ls"},
31+ allowedTools: []string{"view", "ls"},
32− toolName: "bash",
32+ toolName: "bash",
33− action: "execute",
33+ action: "execute",
34− expected: false,
34+ expected: false,
37− name: "tool:action not in allowlist",
37+ name: "tool:action not in allowlist",
38− allowedCommands: []string{"bash:read", "edit:create"},
38+ allowedTools: []string{"bash:read", "edit:create"},
39− toolName: "bash",
39+ toolName: "bash",
40− action: "execute",
40+ action: "execute",
41− expected: false,
41+ expected: false,
44− name: "empty allowlist",
44+ name: "empty allowlist",
45− allowedCommands: []string{},
45+ allowedTools: []string{},
46− toolName: "bash",
46+ toolName: "bash",
47− action: "execute",
47+ action: "execute",
48− expected: false,
48+ expected: false,
52 for _, tt := range tests {
52 for _, tt := range tests {
53 t.Run(tt.name, func(t *testing.T) {
53 t.Run(tt.name, func(t *testing.T) {
54− service := NewPermissionService("/tmp", false, tt.allowedCommands)
54+ service := NewPermissionService("/tmp", false, tt.allowedTools)
56 // Create a channel to capture the permission request
56 // Create a channel to capture the permission request
57 // Since we're testing the allowlist logic, we need to simulate the request
57 // Since we're testing the allowlist logic, we need to simulate the request
@@ -60,7 +60,7 @@ func TestPermissionService_AllowedCommands(t *testing.T) {
60 // Test the allowlist logic directly
60 // Test the allowlist logic directly
61 commandKey := tt.toolName + ":" + tt.action
61 commandKey := tt.toolName + ":" + tt.action
62 allowed := false
62 allowed := false
63− for _, cmd := range ps.allowedCommands {
63+ for _, cmd := range ps.allowedTools {
64 if cmd == commandKey || cmd == tt.toolName {
64 if cmd == commandKey || cmd == tt.toolName {
65 allowed = true
65 allowed = true
@@ -69,7 +69,7 @@ func TestPermissionService_AllowedCommands(t *testing.T) {
70 if allowed != tt.expected {
70 if allowed != tt.expected {
71 t.Errorf("expected %v, got %v for tool %s action %s with allowlist %v",
71 t.Errorf("expected %v, got %v for tool %s action %s with allowlist %v",
72− tt.expected, allowed, tt.toolName, tt.action, tt.allowedCommands)
72+ tt.expected, allowed, tt.toolName, tt.action, tt.allowedTools)