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