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

Function preMigrationLogin

internal/config/auth_config_test.go:976–996  ·  view source on GitHub ↗

Copied and pasted directly from the trunk branch before doing any work on login, plus the addition of AuthConfig as the first arg since it is a method receiver in the real implementation.

(c *AuthConfig, hostname, username, token, gitProtocol string, secureStorage bool)

Source from the content-addressed store, hash-verified

974// login, plus the addition of AuthConfig as the first arg since it is a method
975// receiver in the real implementation.
976func preMigrationLogin(c *AuthConfig, hostname, username, token, gitProtocol string, secureStorage bool) (bool, error) {
977 var setErr error
978 if secureStorage {
979 if setErr = keyring.Set(keyringServiceName(hostname), "", token); setErr == nil {
980 // Clean up the previous oauth_token from the config file.
981 _ = c.cfg.Remove([]string{hostsKey, hostname, oauthTokenKey})
982 }
983 }
984 insecureStorageUsed := false
985 if !secureStorage || setErr != nil {
986 c.cfg.Set([]string{hostsKey, hostname, oauthTokenKey}, token)
987 insecureStorageUsed = true
988 }
989
990 c.cfg.Set([]string{hostsKey, hostname, userKey}, username)
991
992 if gitProtocol != "" {
993 c.cfg.Set([]string{hostsKey, hostname, gitProtocolKey}, gitProtocol)
994 }
995 return insecureStorageUsed, ghConfig.Write(c.cfg)
996}
997
998func TestActiveTokenType(t *testing.T) {
999 tests := []struct {

Calls 5

SetFunction · 0.92
keyringServiceNameFunction · 0.70
RemoveMethod · 0.65
SetMethod · 0.65
WriteMethod · 0.65

Tested by

no test coverage detected