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

Function TestTokenStoredInConfig

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

Source from the content-addressed store, hash-verified

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