MCPcopy Create free account
hub / github.com/github/gh-aw / TestCheckAndSuggestSecretsWithInvalidMCPSection

Function TestCheckAndSuggestSecretsWithInvalidMCPSection

pkg/cli/mcp_secrets_test.go:276–326  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

274}
275
276func TestCheckAndSuggestSecretsWithInvalidMCPSection(t *testing.T) {
277 t.Parallel()
278
279 tests := []struct {
280 name string
281 toolConfig map[string]any
282 wantErr bool
283 }{
284 {
285 name: "mcp is not a map",
286 toolConfig: map[string]any{
287 "mcp": "invalid",
288 },
289 wantErr: false, // Should handle gracefully
290 },
291 {
292 name: "env is not a map[string]string",
293 toolConfig: map[string]any{
294 "mcp": map[string]any{
295 "env": "invalid",
296 },
297 },
298 wantErr: false, // Should handle gracefully
299 },
300 {
301 name: "env is a map but wrong type",
302 toolConfig: map[string]any{
303 "mcp": map[string]any{
304 "env": map[string]int{
305 "KEY": 123,
306 },
307 },
308 },
309 wantErr: false, // Should handle gracefully
310 },
311 }
312
313 for _, tt := range tests {
314 t.Run(tt.name, func(t *testing.T) {
315 err := checkAndSuggestSecrets(tt.toolConfig, false)
316
317 if (err != nil) != tt.wantErr {
318 // Accept 403 errors
319 if err != nil && strings.Contains(err.Error(), "403") {
320 return
321 }
322 t.Errorf("checkAndSuggestSecrets() error = %v, wantErr %v", err, tt.wantErr)
323 }
324 })
325 }
326}
327
328func TestSecretExtractionEdgeCases(t *testing.T) {
329 t.Parallel()

Callers

nothing calls this directly

Calls 4

checkAndSuggestSecretsFunction · 0.85
RunMethod · 0.45
ErrorMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected