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

Function TestSwitchUserMakesInsecureTokenActive

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

Source from the content-addressed store, hash-verified

483}
484
485func TestSwitchUserMakesInsecureTokenActive(t *testing.T) {
486 // Given we have a user with an insecure token
487 authCfg := newTestAuthConfig(t)
488 _, err := authCfg.Login("github.com", "test-user-1", "test-token-1", "ssh", false)
489 require.NoError(t, err)
490 _, err = authCfg.Login("github.com", "test-user-2", "test-token-2", "ssh", false)
491 require.NoError(t, err)
492
493 // When we switch to that user
494 require.NoError(t, authCfg.SwitchUser("github.com", "test-user-1"))
495
496 // Their insecure token is now active
497 cred := authCfg.ActiveToken("github.com")
498 token, source := cred.Token, cred.Source
499 require.Equal(t, "test-token-1", token)
500 require.Equal(t, oauthTokenKey, source)
501}
502
503func TestSwitchUserUpdatesTheActiveUser(t *testing.T) {
504 // Given we have two users logged into a host

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected