MCPcopy
hub / github.com/openpubkey/opkssh / TestLoadPolicyPlugins

Function TestLoadPolicyPlugins

policy/plugins/plugins_test.go:60–163  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

58}
59
60func TestLoadPolicyPlugins(t *testing.T) {
61 tests := []struct {
62 name string
63 files map[string]string // File name to content mapping
64 expectedCount int
65 expectErrorCount int
66 expectError bool
67 }{
68 {
69 name: "Valid plugin config",
70 files: map[string]string{
71 "valid_policy.yml": `
72name: Example Policy Command
73enforce_providers: true
74command: /usr/bin/local/opk/policy-cmd`,
75 },
76 expectedCount: 1,
77 expectErrorCount: 0,
78 },
79 {
80 name: "Invalid plugin configs (missing required fields)",
81 files: map[string]string{
82 "invalid_policy1.yml": `
83name: Invalid Policy Command
84command:
85enforce_providers: true
86`,
87 "invalid_policy2.yml": `
88name:
89command:
90enforce_providers: true
91`,
92 },
93 expectedCount: 2,
94 expectErrorCount: 2,
95 },
96 {
97 name: "Mixed valid and invalid plugin config",
98 files: map[string]string{
99 "valid_policy.yml": `
100name: Example Policy Command
101enforce_providers: true
102command: /usr/bin/local/opk/policy-cmd
103`,
104 "invalid_policy.yml": `
105name: Invalid Policy Command
106enforce_providers: true
107invalid_field: true
108`,
109 },
110 expectedCount: 2,
111 expectErrorCount: 1,
112 },
113 {
114 name: "Corrupt YAML file",
115 files: map[string]string{
116 "corrupt_policy.yml": `{`,
117 },

Callers

nothing calls this directly

Calls 4

loadPluginsMethod · 0.95
ErrorsMethod · 0.80
WriteFileMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected