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

Function TestSharedExtractSecretsFromMap

pkg/workflow/secret_extraction_test.go:186–267  ·  view source on GitHub ↗

TestSharedExtractSecretsFromMap tests the shared ExtractSecretsFromMap utility function

(t *testing.T)

Source from the content-addressed store, hash-verified

184
185// TestSharedExtractSecretsFromMap tests the shared ExtractSecretsFromMap utility function
186func TestSharedExtractSecretsFromMap(t *testing.T) {
187 tests := []struct {
188 name string
189 values map[string]string
190 expected map[string]string
191 }{
192 {
193 name: "HTTP headers with secrets",
194 values: map[string]string{
195 "DD_API_KEY": "${{ secrets.DD_API_KEY }}",
196 "DD_APPLICATION_KEY": "${{ secrets.DD_APPLICATION_KEY }}",
197 "DD_SITE": "${{ secrets.DD_SITE || 'datadoghq.com' }}",
198 },
199 expected: map[string]string{
200 "DD_API_KEY": "${{ secrets.DD_API_KEY }}",
201 "DD_APPLICATION_KEY": "${{ secrets.DD_APPLICATION_KEY }}",
202 "DD_SITE": "${{ secrets.DD_SITE || 'datadoghq.com' }}",
203 },
204 },
205 {
206 name: "env vars with secrets",
207 values: map[string]string{
208 "API_KEY": "${{ secrets.API_KEY }}",
209 "TOKEN": "${{ secrets.TOKEN }}",
210 },
211 expected: map[string]string{
212 "API_KEY": "${{ secrets.API_KEY }}",
213 "TOKEN": "${{ secrets.TOKEN }}",
214 },
215 },
216 {
217 name: "mixed secrets and plain values",
218 values: map[string]string{
219 "Authorization": "Bearer ${{ secrets.AUTH_TOKEN }}",
220 "Content-Type": "application/json",
221 "API_KEY": "${{ secrets.API_KEY }}",
222 },
223 expected: map[string]string{
224 "AUTH_TOKEN": "${{ secrets.AUTH_TOKEN }}",
225 "API_KEY": "${{ secrets.API_KEY }}",
226 },
227 },
228 {
229 name: "no secrets",
230 values: map[string]string{
231 "SIMPLE_VAR": "plain value",
232 },
233 expected: map[string]string{},
234 },
235 {
236 name: "duplicate secrets (same secret in multiple values)",
237 values: map[string]string{
238 "Header1": "${{ secrets.API_KEY }}",
239 "Header2": "${{ secrets.API_KEY }}",
240 },
241 expected: map[string]string{
242 "API_KEY": "${{ secrets.API_KEY }}",
243 },

Callers

nothing calls this directly

Calls 3

ExtractSecretsFromMapFunction · 0.85
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected