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

Function TestExtractSecretsFromHeaders

pkg/workflow/mcp_http_headers_test.go:69–96  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

67}
68
69func TestExtractSecretsFromHeaders(t *testing.T) {
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 "Static": "no-secrets-here",
75 }
76
77 result := ExtractSecretsFromMap(headers)
78
79 expected := map[string]string{
80 "DD_API_KEY": "${{ secrets.DD_API_KEY }}",
81 "DD_APPLICATION_KEY": "${{ secrets.DD_APPLICATION_KEY }}",
82 "DD_SITE": "${{ secrets.DD_SITE || 'datadoghq.com' }}",
83 }
84
85 if len(result) != len(expected) {
86 t.Errorf("Expected %d secrets, got %d", len(expected), len(result))
87 }
88
89 for key, expectedValue := range expected {
90 if actualValue, exists := result[key]; !exists {
91 t.Errorf("Expected secret %s not found", key)
92 } else if actualValue != expectedValue {
93 t.Errorf("For key %s, expected %q, got %q", key, expectedValue, actualValue)
94 }
95 }
96}
97
98func TestReplaceSecretsWithEnvVars(t *testing.T) {
99 tests := []struct {

Callers

nothing calls this directly

Calls 2

ExtractSecretsFromMapFunction · 0.85
ErrorfMethod · 0.45

Tested by

no test coverage detected