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

Function TestTokenStoredInConfig

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

Source from the content-addressed store, hash-verified

88}
89
90func TestTokenStoredInConfig(t *testing.T) {
91 // Given the user has logged in insecurely
92 authCfg := newTestAuthConfig(t)
93 _, err := authCfg.Login("github.com", "test-user", "test-token", "", false)
94 require.NoError(t, err)
95
96 // When we get the token
97 cred := authCfg.ActiveToken("github.com")
98 token, source := cred.Token, cred.Source
99
100 // Then the token is successfully fetched
101 // and the source is set to oauth_token but this isn't great:
102 // https://github.com/cli/go-gh/issues/94
103 require.Equal(t, "test-token", token)
104 require.Equal(t, oauthTokenKey, source)
105}
106
107func TestTokenStoredInEnv(t *testing.T) {
108 // When the user is authenticated via env var

Callers

nothing calls this directly

Calls 4

newTestAuthConfigFunction · 0.85
EqualMethod · 0.80
LoginMethod · 0.65
ActiveTokenMethod · 0.65

Tested by

no test coverage detected