|
|
@ -155,9 +155,8 @@ func TestHTTPGetter(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
|
|
func TestDownload(t *testing.T) {
|
|
|
|
func TestDownload(t *testing.T) {
|
|
|
|
expect := "Call me Ishmael"
|
|
|
|
expect := "Call me Ishmael"
|
|
|
|
expectedUserAgent := "I am Groot"
|
|
|
|
|
|
|
|
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
defaultUserAgent := "Helm/" + strings.TrimPrefix(version.GetVersion(), "v")
|
|
|
|
defaultUserAgent := version.GetUserAgent()
|
|
|
|
if r.UserAgent() != defaultUserAgent {
|
|
|
|
if r.UserAgent() != defaultUserAgent {
|
|
|
|
t.Errorf("Expected '%s', got '%s'", defaultUserAgent, r.UserAgent())
|
|
|
|
t.Errorf("Expected '%s', got '%s'", defaultUserAgent, r.UserAgent())
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -179,6 +178,7 @@ func TestDownload(t *testing.T) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// test with http server
|
|
|
|
// test with http server
|
|
|
|
|
|
|
|
const expectedUserAgent = "I am Groot"
|
|
|
|
basicAuthSrv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
basicAuthSrv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
username, password, ok := r.BasicAuth()
|
|
|
|
username, password, ok := r.BasicAuth()
|
|
|
|
if !ok || username != "username" || password != "password" {
|
|
|
|
if !ok || username != "username" || password != "password" {
|
|
|
|