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)
| 974 | // login, plus the addition of AuthConfig as the first arg since it is a method |
| 975 | // receiver in the real implementation. |
| 976 | func 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 | |
| 998 | func TestActiveTokenType(t *testing.T) { |
| 999 | tests := []struct { |
no test coverage detected