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

Function TestTokenStoredInKeyring

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

Source from the content-addressed store, hash-verified

120}
121
122func TestTokenStoredInKeyring(t *testing.T) {
123 // When the user has logged in securely
124 authCfg := newTestAuthConfig(t)
125 _, err := authCfg.Login("github.com", "test-user", "test-token", "", true)
126 require.NoError(t, err)
127
128 // When we get the token
129 cred := authCfg.ActiveToken("github.com")
130 token, source := cred.Token, cred.Source
131
132 // Then the token is successfully fetched
133 // and the source is set to keyring
134 require.Equal(t, "test-token", token)
135 require.Equal(t, "keyring", source)
136}
137
138func TestTokenFromKeyringNonExistent(t *testing.T) {
139 // Given a keyring that doesn't contain any tokens

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