-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. fix bug where `invoke` command was ignoring the --tls-no-verify command line argument 2. add --tls-no-verify command line argument to the `remove` command 3. fix bug where `login` does not respect environment proxy variable `http_proxy` 4. add better error message if login fails, useful to explain certificate errors etc... 5. `deploy` command not respecting environment proxy variable `http_proxy` during a replace 6. add default time out const for majority of functions 7. make func `makeHTTPClientWithDisableKeepAlives` private not used outside of proxy package 8. version supports basic auth Signed-off-by: Edward Wilde <[email protected]>
- Loading branch information
Showing
12 changed files
with
129 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// Copyright (c) Alex Ellis 2017. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
package proxy | ||
|
||
import ( | ||
"net/http" | ||
"testing" | ||
"time" | ||
) | ||
|
||
func Test_MakeHTTPClientWithDisableKeepAlives_(t *testing.T) { | ||
cases := []struct { | ||
name string | ||
timeout *time.Duration | ||
tlsInsecure bool | ||
disableKeepAlives bool | ||
match func(http.Client, *http.Transport) bool | ||
}{ | ||
{name: "no timeout, secure, keep-alive", timeout: nil, tlsInsecure: false, disableKeepAlives: false, match: func(client http.Client, transport *http.Transport) bool { | ||
return transport == nil | ||
}}, | ||
{name: "no timeout, insecure, keep-alive", timeout: nil, tlsInsecure: true, disableKeepAlives: false, match: func(client http.Client, transport *http.Transport) bool { | ||
return transport != nil && | ||
transport.TLSClientConfig.InsecureSkipVerify && | ||
transport.DisableKeepAlives == false && | ||
transport.Proxy != nil | ||
}}, | ||
{name: "no timeout, insecure, disable keep-alive", timeout: nil, tlsInsecure: true, disableKeepAlives: true, match: func(client http.Client, transport *http.Transport) bool { | ||
return transport != nil && | ||
transport.TLSClientConfig.InsecureSkipVerify && | ||
transport.DisableKeepAlives == true && | ||
transport.Proxy != nil | ||
}}, | ||
{name: "timeout, secure, keep-alive", timeout: durationPtr(time.Second * 30), tlsInsecure: false, disableKeepAlives: false, match: func(client http.Client, transport *http.Transport) bool { | ||
return client.Timeout == time.Second*30 && | ||
transport != nil && | ||
transport.DialContext != nil && | ||
transport.TLSClientConfig == nil && | ||
transport.DisableKeepAlives == false && | ||
transport.Proxy != nil | ||
}}, | ||
{name: "timeout, secure, disable keep-alive", timeout: durationPtr(time.Second * 30), tlsInsecure: false, disableKeepAlives: true, match: func(client http.Client, transport *http.Transport) bool { | ||
return client.Timeout == time.Second*30 && | ||
transport != nil && | ||
transport.DialContext != nil && | ||
transport.TLSClientConfig == nil && | ||
transport.DisableKeepAlives == true && | ||
transport.Proxy != nil | ||
}}, | ||
{name: "timeout, insecure, disable keep-alive", timeout: durationPtr(time.Second * 30), tlsInsecure: true, disableKeepAlives: true, match: func(client http.Client, transport *http.Transport) bool { | ||
return client.Timeout == time.Second*30 && | ||
transport != nil && | ||
transport.DialContext != nil && | ||
transport.TLSClientConfig.InsecureSkipVerify && | ||
transport.DisableKeepAlives == true && | ||
transport.Proxy != nil | ||
}}, | ||
} | ||
|
||
for _, v := range cases { | ||
t.Run(v.name, func(t *testing.T) { | ||
client := makeHTTPClientWithDisableKeepAlives(v.timeout, v.tlsInsecure, v.disableKeepAlives) | ||
var transport *http.Transport | ||
if client.Transport != nil { | ||
transport = client.Transport.(*http.Transport) | ||
} | ||
if !v.match(client, transport) { | ||
t.Logf("%s did not match", v.name) | ||
t.Fail() | ||
} | ||
}) | ||
} | ||
} | ||
|
||
func durationPtr(duration time.Duration) *time.Duration { | ||
return &duration | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters