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

Function TestSwitchUserMakesInsecureTokenActive

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

Source from the content-addressed store, hash-verified

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