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

Function TestTokenWorksRightAfterMigration

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

Source from the content-addressed store, hash-verified

772}
773
774func TestTokenWorksRightAfterMigration(t *testing.T) {
775 // Given we have logged in before migration
776 authCfg := newTestAuthConfig(t)
777 _, err := preMigrationLogin(authCfg, "github.com", "test-user", "test-token", "ssh", false)
778 require.NoError(t, err)
779
780 // When we migrate
781 var m migration.MultiAccountDeprecated
782 c := cfg{cfg: authCfg.cfg}
783 require.NoError(t, c.Migrate(m))
784
785 // Then we can still get the token correctly
786 cred := authCfg.ActiveToken("github.com")
787 token, source := cred.Token, cred.Source
788 require.Equal(t, "test-token", token)
789 require.Equal(t, oauthTokenKey, source)
790}
791
792func TestTokenPrioritizesActiveUserToken(t *testing.T) {
793 // Given a keyring where the active slot contains the token from a previous user

Callers

nothing calls this directly

Calls 5

MigrateMethod · 0.95
newTestAuthConfigFunction · 0.85
preMigrationLoginFunction · 0.85
EqualMethod · 0.80
ActiveTokenMethod · 0.65

Tested by

no test coverage detected