1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-12 10:55:20 +02:00

feat(http): support empty passwords (#2206)

* add test case

* allow zero-length passwords

Co-authored-by: Oliver Nocon <33484802+OliverNocon@users.noreply.github.com>
This commit is contained in:
Christopher Fenner 2020-11-03 19:36:52 +01:00 committed by GitHub
parent 04599e97da
commit b7afe8bbf5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

View File

@ -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) request.SetBasicAuth(c.username, c.password)
c.logger.Debug("Using Basic Authentication ****/****") c.logger.Debug("Using Basic Authentication ****/****")
} }

View File

@ -169,6 +169,7 @@ func TestUploadRequest(t *testing.T) {
{clientOptions: ClientOptions{}, method: "POST", header: map[string][]string{"Testheader": {"Test1", "Test2"}}, expected: "OK"}, {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{}, 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: "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")} client := Client{logger: log.Entry().WithField("package", "SAP/jenkins-library/pkg/http")}