diff --git a/pkg/http/http.go b/pkg/http/http.go index 5b2e4db71..34ddc62ca 100644 --- a/pkg/http/http.go +++ b/pkg/http/http.go @@ -311,7 +311,7 @@ func (c *Client) createRequest(method, url string, body io.Reader, header *http. } } - if len(c.username) > 0 && len(c.password) > 0 { + if len(c.username) > 0 { request.SetBasicAuth(c.username, c.password) c.logger.Debug("Using Basic Authentication ****/****") } diff --git a/pkg/http/http_test.go b/pkg/http/http_test.go index 622501141..dd2aa1287 100644 --- a/pkg/http/http_test.go +++ b/pkg/http/http_test.go @@ -169,6 +169,7 @@ func TestUploadRequest(t *testing.T) { {clientOptions: ClientOptions{}, method: "POST", header: map[string][]string{"Testheader": {"Test1", "Test2"}}, expected: "OK"}, {clientOptions: ClientOptions{}, cookies: []*http.Cookie{{Name: "TestCookie1", Value: "TestValue1"}, {Name: "TestCookie2", Value: "TestValue2"}}, method: "POST", expected: "OK"}, {clientOptions: ClientOptions{Username: "TestUser", Password: "TestPwd"}, method: "POST", expected: "OK"}, + {clientOptions: ClientOptions{Username: "UserOnly", Password: ""}, method: "POST", expected: "OK"}, } client := Client{logger: log.Entry().WithField("package", "SAP/jenkins-library/pkg/http")}