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