(t *testing.T)
| 59 | } |
| 60 | |
| 61 | func TestExtractSecretsFromConfig(t *testing.T) { |
| 62 | tests := []struct { |
| 63 | name string |
| 64 | config parser.RegistryMCPServerConfig |
| 65 | expectedSecrets []string |
| 66 | }{ |
| 67 | { |
| 68 | name: "HTTP headers with secrets", |
| 69 | config: parser.RegistryMCPServerConfig{BaseMCPServerConfig: types.BaseMCPServerConfig{Type: "http", |
| 70 | Headers: map[string]string{ |
| 71 | "DD_API_KEY": "${{ secrets.DD_API_KEY }}", |
| 72 | "DD_APPLICATION_KEY": "${{ secrets.DD_APPLICATION_KEY }}", |
| 73 | "DD_SITE": "${{ secrets.DD_SITE || 'datadoghq.com' }}", |
| 74 | }}, Name: "datadog", |
| 75 | }, |
| 76 | expectedSecrets: []string{"DD_API_KEY", "DD_APPLICATION_KEY", "DD_SITE"}, |
| 77 | }, |
| 78 | { |
| 79 | name: "env vars with secrets", |
| 80 | config: parser.RegistryMCPServerConfig{BaseMCPServerConfig: types.BaseMCPServerConfig{Type: "stdio", |
| 81 | Env: map[string]string{ |
| 82 | "API_KEY": "${{ secrets.API_KEY }}", |
| 83 | "TOKEN": "${{ secrets.TOKEN }}", |
| 84 | }}, Name: "test-server", |
| 85 | }, |
| 86 | expectedSecrets: []string{"API_KEY", "TOKEN"}, |
| 87 | }, |
| 88 | { |
| 89 | name: "mixed headers and env", |
| 90 | config: parser.RegistryMCPServerConfig{BaseMCPServerConfig: types.BaseMCPServerConfig{Type: "http", |
| 91 | Headers: map[string]string{ |
| 92 | "Authorization": "Bearer ${{ secrets.AUTH_TOKEN }}", |
| 93 | }, |
| 94 | Env: map[string]string{ |
| 95 | "API_KEY": "${{ secrets.API_KEY }}", |
| 96 | }}, Name: "mixed-server", |
| 97 | }, |
| 98 | expectedSecrets: []string{"AUTH_TOKEN", "API_KEY"}, |
| 99 | }, |
| 100 | { |
| 101 | name: "no secrets", |
| 102 | config: parser.RegistryMCPServerConfig{BaseMCPServerConfig: types.BaseMCPServerConfig{Type: "stdio", |
| 103 | Env: map[string]string{ |
| 104 | "SIMPLE_VAR": "plain value", |
| 105 | }}, Name: "simple-server", |
| 106 | }, |
| 107 | expectedSecrets: []string{}, |
| 108 | }, |
| 109 | { |
| 110 | name: "duplicate secrets (should only appear once)", |
| 111 | config: parser.RegistryMCPServerConfig{BaseMCPServerConfig: types.BaseMCPServerConfig{Type: "http", |
| 112 | Headers: map[string]string{ |
| 113 | "Header1": "${{ secrets.API_KEY }}", |
| 114 | "Header2": "${{ secrets.API_KEY }}", |
| 115 | }}, Name: "duplicate-server", |
| 116 | }, |
| 117 | expectedSecrets: []string{"API_KEY"}, |
| 118 | }, |
nothing calls this directly
no test coverage detected