MCPcopy
hub / github.com/cli/cli / TestSwitchUserMakesInsecureTokenActive

Function TestSwitchUserMakesInsecureTokenActive

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

Source from the content-addressed store, hash-verified

467}
468
469func TestSwitchUserMakesInsecureTokenActive(t *testing.T) {
470 // Given we have a user with an insecure token
471 authCfg := newTestAuthConfig(t)
472 _, err := authCfg.Login("github.com", "test-user-1", "test-token-1", "ssh", false)
473 require.NoError(t, err)
474 _, err = authCfg.Login("github.com", "test-user-2", "test-token-2", "ssh", false)
475 require.NoError(t, err)
476
477 // When we switch to that user
478 require.NoError(t, authCfg.SwitchUser("github.com", "test-user-1"))
479
480 // Their insecure token is now active
481 token, source := authCfg.ActiveToken("github.com")
482 require.Equal(t, "test-token-1", token)
483 require.Equal(t, oauthTokenKey, source)
484}
485
486func TestSwitchUserUpdatesTheActiveUser(t *testing.T) {
487 // 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