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

Function TestTokenStoredInEnv

internal/config/auth_config_test.go:107–120  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

105}
106
107func TestTokenStoredInEnv(t *testing.T) {
108 // When the user is authenticated via env var
109 authCfg := newTestAuthConfig(t)
110 t.Setenv("GH_TOKEN", "test-token")
111
112 // When we get the token
113 cred := authCfg.ActiveToken("github.com")
114 token, source := cred.Token, cred.Source
115
116 // Then the token is successfully fetched
117 // and the source is set to the name of the env var
118 require.Equal(t, "test-token", token)
119 require.Equal(t, "GH_TOKEN", source)
120}
121
122func TestTokenStoredInKeyring(t *testing.T) {
123 // When the user has logged in securely

Callers

nothing calls this directly

Calls 3

newTestAuthConfigFunction · 0.85
EqualMethod · 0.80
ActiveTokenMethod · 0.65

Tested by

no test coverage detected