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

Function preMigrationLogin

internal/config/auth_config_test.go:930–950  ·  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

928// login, plus the addition of AuthConfig as the first arg since it is a method
929// receiver in the real implementation.
930func preMigrationLogin(c *AuthConfig, hostname, username, token, gitProtocol string, secureStorage bool) (bool, error) {
931 var setErr error
932 if secureStorage {
933 if setErr = keyring.Set(keyringServiceName(hostname), "", token); setErr == nil {
934 // Clean up the previous oauth_token from the config file.
935 _ = c.cfg.Remove([]string{hostsKey, hostname, oauthTokenKey})
936 }
937 }
938 insecureStorageUsed := false
939 if !secureStorage || setErr != nil {
940 c.cfg.Set([]string{hostsKey, hostname, oauthTokenKey}, token)
941 insecureStorageUsed = true
942 }
943
944 c.cfg.Set([]string{hostsKey, hostname, userKey}, username)
945
946 if gitProtocol != "" {
947 c.cfg.Set([]string{hostsKey, hostname, gitProtocolKey}, gitProtocol)
948 }
949 return insecureStorageUsed, ghConfig.Write(c.cfg)
950}
951
952func TestActiveTokenType(t *testing.T) {
953 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