MCPcopy Create free account
hub / github.com/cli/cli / TestTokenRunSecureStorage

Function TestTokenRunSecureStorage

pkg/cmd/auth/token/token_test.go:195–276  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

193}
194
195func TestTokenRunSecureStorage(t *testing.T) {
196 tests := []struct {
197 name string
198 opts TokenOptions
199 cfgStubs func(*testing.T, gh.Config)
200 wantStdout string
201 wantErr bool
202 wantErrMsg string
203 }{
204 {
205 name: "token",
206 opts: TokenOptions{},
207 cfgStubs: func(t *testing.T, cfg gh.Config) {
208 login(t, cfg, "github.com", "test-user", "gho_ABCDEFG", "https", true)
209 },
210 wantStdout: "gho_ABCDEFG\n",
211 },
212 {
213 name: "token by hostname",
214 opts: TokenOptions{
215 Hostname: "mycompany.com",
216 },
217 cfgStubs: func(t *testing.T, cfg gh.Config) {
218 login(t, cfg, "mycompany.com", "test-user", "gho_1234567", "https", true)
219 },
220 wantStdout: "gho_1234567\n",
221 },
222 {
223 name: "no token",
224 opts: TokenOptions{},
225 wantErr: true,
226 wantErrMsg: "no oauth token found for github.com",
227 },
228 {
229 name: "no token for hostname user",
230 opts: TokenOptions{
231 Hostname: "ghe.io",
232 Username: "test-user",
233 },
234 wantErr: true,
235 wantErrMsg: "no oauth token found for ghe.io account test-user",
236 },
237 {
238 name: "token for user",
239 opts: TokenOptions{
240 Hostname: "github.com",
241 Username: "test-user",
242 },
243 cfgStubs: func(t *testing.T, cfg gh.Config) {
244 login(t, cfg, "github.com", "test-user", "gho_ABCDEFG", "https", true)
245 login(t, cfg, "github.com", "test-user-2", "gho_1234567", "https", true)
246 },
247 wantStdout: "gho_ABCDEFG\n",
248 },
249 }
250
251 for _, tt := range tests {
252 t.Run(tt.name, func(t *testing.T) {

Callers

nothing calls this directly

Calls 8

TestFunction · 0.92
NewIsolatedTestConfigFunction · 0.92
tokenRunFunction · 0.85
EqualMethod · 0.80
loginFunction · 0.70
RunMethod · 0.65
StringMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected