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

Function TestStringContainsSecretName

pkg/cli/engine_secrets_test.go:148–225  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

146}
147
148func TestStringContainsSecretName(t *testing.T) {
149 tests := []struct {
150 name string
151 output string
152 secretName string
153 want bool
154 }{
155 {
156 name: "exact match single line",
157 output: "GH_AW_GITHUB_TOKEN",
158 secretName: "GH_AW_GITHUB_TOKEN",
159 want: true,
160 },
161 {
162 name: "match with tab separator",
163 output: "GH_AW_GITHUB_TOKEN\t2024-01-01",
164 secretName: "GH_AW_GITHUB_TOKEN",
165 want: true,
166 },
167 {
168 name: "match with space separator",
169 output: "GH_AW_GITHUB_TOKEN 2024-01-01",
170 secretName: "GH_AW_GITHUB_TOKEN",
171 want: true,
172 },
173 {
174 name: "match in multiline output",
175 output: "SOME_SECRET\t2024-01-01\nGH_AW_GITHUB_TOKEN\t2024-02-01\nOTHER_SECRET\t2024-03-01",
176 secretName: "GH_AW_GITHUB_TOKEN",
177 want: true,
178 },
179 {
180 name: "no match - different secret",
181 output: "SOME_OTHER_TOKEN\t2024-01-01",
182 secretName: "GH_AW_GITHUB_TOKEN",
183 want: false,
184 },
185 {
186 name: "no match - prefix only",
187 output: "GH_AW_GITHUB_TOKEN_EXTENDED\t2024-01-01",
188 secretName: "GH_AW_GITHUB_TOKEN",
189 want: false,
190 },
191 {
192 name: "no match - empty output",
193 output: "",
194 secretName: "GH_AW_GITHUB_TOKEN",
195 want: false,
196 },
197 {
198 name: "no match - secret longer than line",
199 output: "SHORT",
200 secretName: "GH_AW_GITHUB_TOKEN",
201 want: false,
202 },
203 {
204 name: "match copilot token",
205 output: "COPILOT_GITHUB_TOKEN\t2024-01-15\nANTHROPIC_API_KEY\t2024-01-20",

Callers

nothing calls this directly

Calls 2

stringContainsSecretNameFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected