-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoolset_test.go
More file actions
61 lines (50 loc) · 1.51 KB
/
toolset_test.go
File metadata and controls
61 lines (50 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package vulnerability
import (
"testing"
"github.com/stackrox/stackrox-mcp/internal/client"
"github.com/stackrox/stackrox-mcp/internal/config"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestNewToolset(t *testing.T) {
cfg := &config.Config{
Tools: config.ToolsConfig{
Vulnerability: config.ToolsetVulnerabilityConfig{
Enabled: true,
},
},
}
toolset := NewToolset(cfg, &client.Client{})
require.NotNil(t, toolset)
assert.Equal(t, "vulnerability", toolset.GetName())
}
func TestToolset_IsEnabled_True(t *testing.T) {
cfg := &config.Config{
Tools: config.ToolsConfig{
Vulnerability: config.ToolsetVulnerabilityConfig{
Enabled: true,
},
},
}
toolset := NewToolset(cfg, &client.Client{})
assert.True(t, toolset.IsEnabled())
tools := toolset.GetTools()
require.NotEmpty(t, tools, "Should return tools when enabled")
require.Len(t, tools, 3, "Should have all vulnerability tools")
assert.Equal(t, "get_deployments_for_cve", tools[0].GetName())
assert.Equal(t, "get_nodes_for_cve", tools[1].GetName())
assert.Equal(t, "get_clusters_with_orchestrator_cve", tools[2].GetName())
}
func TestToolset_IsEnabled_False(t *testing.T) {
cfg := &config.Config{
Tools: config.ToolsConfig{
Vulnerability: config.ToolsetVulnerabilityConfig{
Enabled: false,
},
},
}
toolset := NewToolset(cfg, &client.Client{})
assert.False(t, toolset.IsEnabled())
tools := toolset.GetTools()
assert.Empty(t, tools, "Should return empty list when toolset is disabled")
}