From 7fd58c3910e9accabfa1856949ea04726c966df7 Mon Sep 17 00:00:00 2001 From: Petu Eusebiu Date: Fri, 18 Jun 2021 21:29:55 +0300 Subject: [PATCH] fix lint --- pkg/api/controller_test.go | 316 ++++++++++++++++++------------------- 1 file changed, 158 insertions(+), 158 deletions(-) diff --git a/pkg/api/controller_test.go b/pkg/api/controller_test.go index 58825b310..cc517b789 100644 --- a/pkg/api/controller_test.go +++ b/pkg/api/controller_test.go @@ -40,7 +40,7 @@ import ( const ( BaseURL = "http://127.0.0.1:%s" - BaseSecurelUrl = "https://127.0.0.1:%s" + BaseSecureURL = "https://127.0.0.1:%s" username = "test" passphrase = "test" ServerCert = "../../test/data/server.cert" @@ -72,12 +72,12 @@ func getFreePort() string { return fmt.Sprint(port) } -func getBaseUrl(port string, secure bool) string { +func getBaseURL(port string, secure bool) string { if secure { - return fmt.Sprintf(BaseSecurelUrl, port) - } else { - return fmt.Sprintf(BaseURL, port) + return fmt.Sprintf(BaseSecureURL, port) } + + return fmt.Sprintf(BaseURL, port) } func makeHtpasswdFile() string { @@ -132,7 +132,7 @@ func TestNew(t *testing.T) { func TestHtpasswdSingleCred(t *testing.T) { Convey("Single cred", t, func() { port := getFreePort() - baseUrl := getBaseUrl(port, false) + baseURL := getBaseURL(port, false) singleCredtests := []string{} user := ALICE password := ALICE @@ -166,7 +166,7 @@ func TestHtpasswdSingleCred(t *testing.T) { }(c) // wait till ready for { - _, err := resty.R().Get(baseUrl) + _, err := resty.R().Get(baseURL) if err == nil { break } @@ -177,12 +177,12 @@ func TestHtpasswdSingleCred(t *testing.T) { _ = controller.Server.Shutdown(ctx) }(c) // with creds, should get expected status code - resp, _ := resty.R().SetBasicAuth(user, password).Get(baseUrl + "/v2/") + resp, _ := resty.R().SetBasicAuth(user, password).Get(baseURL + "/v2/") So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 200) //with invalid creds, it should fail - resp, _ = resty.R().SetBasicAuth("chuck", "chuck").Get(baseUrl + "/v2/") + resp, _ = resty.R().SetBasicAuth("chuck", "chuck").Get(baseURL + "/v2/") So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 401) }() @@ -209,7 +209,7 @@ func TestHtpasswdTwoCreds(t *testing.T) { for _, testString := range twoCredTests { func() { port := getFreePort() - baseUrl := getBaseUrl(port, false) + baseURL := getBaseURL(port, false) config := api.NewConfig() config.HTTP.Port = port htpasswdPath := makeHtpasswdFileFromString(testString) @@ -234,7 +234,7 @@ func TestHtpasswdTwoCreds(t *testing.T) { }(c) // wait till ready for { - _, err := resty.R().Get(baseUrl) + _, err := resty.R().Get(baseURL) if err == nil { break } @@ -246,16 +246,16 @@ func TestHtpasswdTwoCreds(t *testing.T) { _ = controller.Server.Shutdown(ctx) }(c) // with creds, should get expected status code - resp, _ := resty.R().SetBasicAuth(user1, password1).Get(baseUrl + "/v2/") + resp, _ := resty.R().SetBasicAuth(user1, password1).Get(baseURL + "/v2/") So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 200) - resp, _ = resty.R().SetBasicAuth(user2, password2).Get(baseUrl + "/v2/") + resp, _ = resty.R().SetBasicAuth(user2, password2).Get(baseURL + "/v2/") So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 200) //with invalid creds, it should fail - resp, _ = resty.R().SetBasicAuth("chuck", "chuck").Get(baseUrl + "/v2/") + resp, _ = resty.R().SetBasicAuth("chuck", "chuck").Get(baseURL + "/v2/") So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 401) }() @@ -278,7 +278,7 @@ func TestHtpasswdFiveCreds(t *testing.T) { func() { port := getFreePort() - baseUrl := getBaseUrl(port, false) + baseURL := getBaseURL(port, false) config := api.NewConfig() config.HTTP.Port = port htpasswdPath := makeHtpasswdFileFromString(credString.String()) @@ -303,7 +303,7 @@ func TestHtpasswdFiveCreds(t *testing.T) { }(c) // wait till ready for { - _, err := resty.R().Get(baseUrl) + _, err := resty.R().Get(baseURL) if err == nil { break } @@ -316,13 +316,13 @@ func TestHtpasswdFiveCreds(t *testing.T) { }(c) // with creds, should get expected status code for key, val := range tests { - resp, _ := resty.R().SetBasicAuth(key, val).Get(baseUrl + "/v2/") + resp, _ := resty.R().SetBasicAuth(key, val).Get(baseURL + "/v2/") So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 200) } //with invalid creds, it should fail - resp, _ := resty.R().SetBasicAuth("chuck", "chuck").Get(baseUrl + "/v2/") + resp, _ := resty.R().SetBasicAuth("chuck", "chuck").Get(baseURL + "/v2/") So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 401) }() @@ -331,7 +331,7 @@ func TestHtpasswdFiveCreds(t *testing.T) { func TestBasicAuth(t *testing.T) { Convey("Make a new controller", t, func() { port := getFreePort() - baseUrl := getBaseUrl(port, false) + baseURL := getBaseURL(port, false) config := api.NewConfig() config.HTTP.Port = port htpasswdPath := makeHtpasswdFile() @@ -358,7 +358,7 @@ func TestBasicAuth(t *testing.T) { // wait till ready for { - _, err := resty.R().Get(baseUrl) + _, err := resty.R().Get(baseURL) if err == nil { break } @@ -371,7 +371,7 @@ func TestBasicAuth(t *testing.T) { }() // without creds, should get access error - resp, err := resty.R().Get(baseUrl + "/v2/") + resp, err := resty.R().Get(baseURL + "/v2/") So(err, ShouldBeNil) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 401) @@ -380,11 +380,11 @@ func TestBasicAuth(t *testing.T) { So(err, ShouldBeNil) // with creds, should get expected status code - resp, _ = resty.R().SetBasicAuth(username, passphrase).Get(baseUrl) + resp, _ = resty.R().SetBasicAuth(username, passphrase).Get(baseURL) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 404) - resp, _ = resty.R().SetBasicAuth(username, passphrase).Get(baseUrl + "/v2/") + resp, _ = resty.R().SetBasicAuth(username, passphrase).Get(baseURL + "/v2/") So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 200) }) @@ -393,7 +393,7 @@ func TestBasicAuth(t *testing.T) { func TestMultipleInstance(t *testing.T) { Convey("Negative test zot multiple instance", t, func() { port := getFreePort() - baseUrl := getBaseUrl(port, false) + baseURL := getBaseURL(port, false) config := api.NewConfig() config.HTTP.Port = port htpasswdPath := makeHtpasswdFile() @@ -433,7 +433,7 @@ func TestMultipleInstance(t *testing.T) { // wait till ready for { - _, err := resty.R().Get(baseUrl) + _, err := resty.R().Get(baseURL) if err == nil { break } @@ -448,14 +448,14 @@ func TestMultipleInstance(t *testing.T) { client := resty.New() tagResponse, err := client.R().SetBasicAuth(username, passphrase). - Get(baseUrl + "/v2/zot-test/tags/list") + Get(baseURL + "/v2/zot-test/tags/list") So(err, ShouldBeNil) So(tagResponse.StatusCode(), ShouldEqual, 404) }) Convey("Test zot multiple instance", t, func() { port := getFreePort() - baseUrl := getBaseUrl(port, false) + baseURL := getBaseURL(port, false) config := api.NewConfig() config.HTTP.Port = port htpasswdPath := makeHtpasswdFile() @@ -492,7 +492,7 @@ func TestMultipleInstance(t *testing.T) { // wait till ready for { - _, err := resty.R().Get(baseUrl) + _, err := resty.R().Get(baseURL) if err == nil { break } @@ -505,7 +505,7 @@ func TestMultipleInstance(t *testing.T) { }() // without creds, should get access error - resp, err := resty.R().Get(baseUrl + "/v2/") + resp, err := resty.R().Get(baseURL + "/v2/") So(err, ShouldBeNil) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 401) @@ -514,11 +514,11 @@ func TestMultipleInstance(t *testing.T) { So(err, ShouldBeNil) // with creds, should get expected status code - resp, _ = resty.R().SetBasicAuth(username, passphrase).Get(baseUrl) + resp, _ = resty.R().SetBasicAuth(username, passphrase).Get(baseURL) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 404) - resp, _ = resty.R().SetBasicAuth(username, passphrase).Get(baseUrl + "/v2/") + resp, _ = resty.R().SetBasicAuth(username, passphrase).Get(baseURL + "/v2/") So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 200) }) @@ -534,8 +534,8 @@ func TestTLSWithBasicAuth(t *testing.T) { defer os.Remove(htpasswdPath) port := getFreePort() - baseUrl := getBaseUrl(port, false) - secureBaseUrl := getBaseUrl(port, true) + baseURL := getBaseURL(port, false) + secureBaseURL := getBaseURL(port, true) resty.SetTLSClientConfig(&tls.Config{RootCAs: caCertPool}) defer func() { resty.SetTLSClientConfig(nil) }() @@ -567,7 +567,7 @@ func TestTLSWithBasicAuth(t *testing.T) { // wait till ready for { - _, err := resty.R().Get(baseUrl) + _, err := resty.R().Get(baseURL) if err == nil { break } @@ -580,13 +580,13 @@ func TestTLSWithBasicAuth(t *testing.T) { }() // accessing insecure HTTP site should fail - resp, err := resty.R().Get(baseUrl) + resp, err := resty.R().Get(baseURL) So(err, ShouldBeNil) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 400) // without creds, should get access error - resp, err = resty.R().Get(secureBaseUrl + "/v2/") + resp, err = resty.R().Get(secureBaseURL + "/v2/") So(err, ShouldBeNil) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 401) @@ -595,11 +595,11 @@ func TestTLSWithBasicAuth(t *testing.T) { So(err, ShouldBeNil) // with creds, should get expected status code - resp, _ = resty.R().SetBasicAuth(username, passphrase).Get(secureBaseUrl) + resp, _ = resty.R().SetBasicAuth(username, passphrase).Get(secureBaseURL) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 404) - resp, _ = resty.R().SetBasicAuth(username, passphrase).Get(secureBaseUrl + "/v2/") + resp, _ = resty.R().SetBasicAuth(username, passphrase).Get(secureBaseURL + "/v2/") So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 200) }) @@ -615,8 +615,8 @@ func TestTLSWithBasicAuthAllowReadAccess(t *testing.T) { defer os.Remove(htpasswdPath) port := getFreePort() - baseUrl := getBaseUrl(port, false) - secureBaseUrl := getBaseUrl(port, true) + baseURL := getBaseURL(port, false) + secureBaseURL := getBaseURL(port, true) resty.SetTLSClientConfig(&tls.Config{RootCAs: caCertPool}) defer func() { resty.SetTLSClientConfig(nil) }() @@ -649,7 +649,7 @@ func TestTLSWithBasicAuthAllowReadAccess(t *testing.T) { // wait till ready for { - _, err := resty.R().Get(baseUrl) + _, err := resty.R().Get(baseURL) if err == nil { break } @@ -662,27 +662,27 @@ func TestTLSWithBasicAuthAllowReadAccess(t *testing.T) { }() // accessing insecure HTTP site should fail - resp, err := resty.R().Get(baseUrl) + resp, err := resty.R().Get(baseURL) So(err, ShouldBeNil) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 400) // without creds, should still be allowed to access - resp, err = resty.R().Get(secureBaseUrl + "/v2/") + resp, err = resty.R().Get(secureBaseURL + "/v2/") So(err, ShouldBeNil) So(resp.StatusCode(), ShouldEqual, 200) // with creds, should get expected status code - resp, _ = resty.R().SetBasicAuth(username, passphrase).Get(secureBaseUrl) + resp, _ = resty.R().SetBasicAuth(username, passphrase).Get(secureBaseURL) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 404) - resp, _ = resty.R().SetBasicAuth(username, passphrase).Get(secureBaseUrl + "/v2/") + resp, _ = resty.R().SetBasicAuth(username, passphrase).Get(secureBaseURL + "/v2/") So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 200) // without creds, writes should fail - resp, err = resty.R().Post(secureBaseUrl + "/v2/repo/blobs/uploads/") + resp, err = resty.R().Post(secureBaseURL + "/v2/repo/blobs/uploads/") So(err, ShouldBeNil) So(resp.StatusCode(), ShouldEqual, 401) }) @@ -696,8 +696,8 @@ func TestTLSMutualAuth(t *testing.T) { caCertPool.AppendCertsFromPEM(caCert) port := getFreePort() - baseUrl := getBaseUrl(port, false) - secureBaseUrl := getBaseUrl(port, true) + baseURL := getBaseURL(port, false) + secureBaseURL := getBaseURL(port, true) resty.SetTLSClientConfig(&tls.Config{RootCAs: caCertPool}) defer func() { resty.SetTLSClientConfig(nil) }() @@ -725,7 +725,7 @@ func TestTLSMutualAuth(t *testing.T) { // wait till ready for { - _, err := resty.R().Get(baseUrl) + _, err := resty.R().Get(baseURL) if err == nil { break } @@ -738,17 +738,17 @@ func TestTLSMutualAuth(t *testing.T) { }() // accessing insecure HTTP site should fail - resp, err := resty.R().Get(baseUrl) + resp, err := resty.R().Get(baseURL) So(err, ShouldBeNil) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 400) // without client certs and creds, should get conn error - _, err = resty.R().Get(secureBaseUrl) + _, err = resty.R().Get(secureBaseURL) So(err, ShouldNotBeNil) // with creds but without certs, should get conn error - _, err = resty.R().SetBasicAuth(username, passphrase).Get(secureBaseUrl) + _, err = resty.R().SetBasicAuth(username, passphrase).Get(secureBaseURL) So(err, ShouldNotBeNil) // setup TLS mutual auth @@ -759,18 +759,18 @@ func TestTLSMutualAuth(t *testing.T) { defer func() { resty.SetCertificates(tls.Certificate{}) }() // with client certs but without creds, should succeed - resp, err = resty.R().Get(secureBaseUrl + "/v2/") + resp, err = resty.R().Get(secureBaseURL + "/v2/") So(err, ShouldBeNil) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 200) // with client certs and creds, should get expected status code - resp, _ = resty.R().SetBasicAuth(username, passphrase).Get(secureBaseUrl) + resp, _ = resty.R().SetBasicAuth(username, passphrase).Get(secureBaseURL) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 404) // with client certs, creds shouldn't matter - resp, _ = resty.R().SetBasicAuth(username, passphrase).Get(secureBaseUrl + "/v2/") + resp, _ = resty.R().SetBasicAuth(username, passphrase).Get(secureBaseURL + "/v2/") So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 200) }) @@ -784,8 +784,8 @@ func TestTLSMutualAuthAllowReadAccess(t *testing.T) { caCertPool.AppendCertsFromPEM(caCert) port := getFreePort() - baseUrl := getBaseUrl(port, false) - secureBaseUrl := getBaseUrl(port, true) + baseURL := getBaseURL(port, false) + secureBaseURL := getBaseURL(port, true) resty.SetTLSClientConfig(&tls.Config{RootCAs: caCertPool}) defer func() { resty.SetTLSClientConfig(nil) }() @@ -814,7 +814,7 @@ func TestTLSMutualAuthAllowReadAccess(t *testing.T) { // wait till ready for { - _, err := resty.R().Get(baseUrl) + _, err := resty.R().Get(baseURL) if err == nil { break } @@ -827,23 +827,23 @@ func TestTLSMutualAuthAllowReadAccess(t *testing.T) { }() // accessing insecure HTTP site should fail - resp, err := resty.R().Get(baseUrl) + resp, err := resty.R().Get(baseURL) So(err, ShouldBeNil) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 400) // without client certs and creds, reads are allowed - resp, err = resty.R().Get(secureBaseUrl + "/v2/") + resp, err = resty.R().Get(secureBaseURL + "/v2/") So(err, ShouldBeNil) So(resp.StatusCode(), ShouldEqual, 200) // with creds but without certs, reads are allowed - resp, err = resty.R().SetBasicAuth(username, passphrase).Get(secureBaseUrl + "/v2/") + resp, err = resty.R().SetBasicAuth(username, passphrase).Get(secureBaseURL + "/v2/") So(err, ShouldBeNil) So(resp.StatusCode(), ShouldEqual, 200) // without creds, writes should fail - resp, err = resty.R().Post(secureBaseUrl + "/v2/repo/blobs/uploads/") + resp, err = resty.R().Post(secureBaseURL + "/v2/repo/blobs/uploads/") So(err, ShouldBeNil) So(resp.StatusCode(), ShouldEqual, 401) @@ -855,18 +855,18 @@ func TestTLSMutualAuthAllowReadAccess(t *testing.T) { defer func() { resty.SetCertificates(tls.Certificate{}) }() // with client certs but without creds, should succeed - resp, err = resty.R().Get(secureBaseUrl + "/v2/") + resp, err = resty.R().Get(secureBaseURL + "/v2/") So(err, ShouldBeNil) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 200) // with client certs and creds, should get expected status code - resp, _ = resty.R().SetBasicAuth(username, passphrase).Get(secureBaseUrl) + resp, _ = resty.R().SetBasicAuth(username, passphrase).Get(secureBaseURL) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 404) // with client certs, creds shouldn't matter - resp, _ = resty.R().SetBasicAuth(username, passphrase).Get(secureBaseUrl + "/v2/") + resp, _ = resty.R().SetBasicAuth(username, passphrase).Get(secureBaseURL + "/v2/") So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 200) }) @@ -882,8 +882,8 @@ func TestTLSMutualAndBasicAuth(t *testing.T) { defer os.Remove(htpasswdPath) port := getFreePort() - baseUrl := getBaseUrl(port, false) - secureBaseUrl := getBaseUrl(port, true) + baseURL := getBaseURL(port, false) + secureBaseURL := getBaseURL(port, true) resty.SetTLSClientConfig(&tls.Config{RootCAs: caCertPool}) defer func() { resty.SetTLSClientConfig(nil) }() @@ -916,7 +916,7 @@ func TestTLSMutualAndBasicAuth(t *testing.T) { // wait till ready for { - _, err := resty.R().Get(baseUrl) + _, err := resty.R().Get(baseURL) if err == nil { break } @@ -929,19 +929,19 @@ func TestTLSMutualAndBasicAuth(t *testing.T) { }() // accessing insecure HTTP site should fail - resp, err := resty.R().Get(baseUrl) + resp, err := resty.R().Get(baseURL) So(err, ShouldBeNil) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 400) // without client certs and creds, should fail - _, err = resty.R().Get(secureBaseUrl) + _, err = resty.R().Get(secureBaseURL) So(err, ShouldBeNil) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 400) // with creds but without certs, should succeed - _, err = resty.R().SetBasicAuth(username, passphrase).Get(secureBaseUrl) + _, err = resty.R().SetBasicAuth(username, passphrase).Get(secureBaseURL) So(err, ShouldBeNil) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 400) @@ -954,17 +954,17 @@ func TestTLSMutualAndBasicAuth(t *testing.T) { defer func() { resty.SetCertificates(tls.Certificate{}) }() // with client certs but without creds, should get access error - resp, err = resty.R().Get(secureBaseUrl + "/v2/") + resp, err = resty.R().Get(secureBaseURL + "/v2/") So(err, ShouldBeNil) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 401) // with client certs and creds, should get expected status code - resp, _ = resty.R().SetBasicAuth(username, passphrase).Get(secureBaseUrl) + resp, _ = resty.R().SetBasicAuth(username, passphrase).Get(secureBaseURL) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 404) - resp, _ = resty.R().SetBasicAuth(username, passphrase).Get(secureBaseUrl + "/v2/") + resp, _ = resty.R().SetBasicAuth(username, passphrase).Get(secureBaseURL + "/v2/") So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 200) }) @@ -980,8 +980,8 @@ func TestTLSMutualAndBasicAuthAllowReadAccess(t *testing.T) { defer os.Remove(htpasswdPath) port := getFreePort() - baseUrl := getBaseUrl(port, false) - secureBaseUrl := getBaseUrl(port, true) + baseURL := getBaseURL(port, false) + secureBaseURL := getBaseURL(port, true) resty.SetTLSClientConfig(&tls.Config{RootCAs: caCertPool}) defer func() { resty.SetTLSClientConfig(nil) }() @@ -1015,7 +1015,7 @@ func TestTLSMutualAndBasicAuthAllowReadAccess(t *testing.T) { // wait till ready for { - _, err := resty.R().Get(baseUrl) + _, err := resty.R().Get(baseURL) if err == nil { break } @@ -1028,19 +1028,19 @@ func TestTLSMutualAndBasicAuthAllowReadAccess(t *testing.T) { }() // accessing insecure HTTP site should fail - resp, err := resty.R().Get(baseUrl) + resp, err := resty.R().Get(baseURL) So(err, ShouldBeNil) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 400) // without client certs and creds, should fail - _, err = resty.R().Get(secureBaseUrl) + _, err = resty.R().Get(secureBaseURL) So(err, ShouldBeNil) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 400) // with creds but without certs, should succeed - _, err = resty.R().SetBasicAuth(username, passphrase).Get(secureBaseUrl) + _, err = resty.R().SetBasicAuth(username, passphrase).Get(secureBaseURL) So(err, ShouldBeNil) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 400) @@ -1053,21 +1053,21 @@ func TestTLSMutualAndBasicAuthAllowReadAccess(t *testing.T) { defer func() { resty.SetCertificates(tls.Certificate{}) }() // with client certs but without creds, reads should succeed - resp, err = resty.R().Get(secureBaseUrl + "/v2/") + resp, err = resty.R().Get(secureBaseURL + "/v2/") So(err, ShouldBeNil) So(resp.StatusCode(), ShouldEqual, 200) // with only client certs, writes should fail - resp, err = resty.R().Post(secureBaseUrl + "/v2/repo/blobs/uploads/") + resp, err = resty.R().Post(secureBaseURL + "/v2/repo/blobs/uploads/") So(err, ShouldBeNil) So(resp.StatusCode(), ShouldEqual, 401) // with client certs and creds, should get expected status code - resp, _ = resty.R().SetBasicAuth(username, passphrase).Get(secureBaseUrl) + resp, _ = resty.R().SetBasicAuth(username, passphrase).Get(secureBaseURL) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 404) - resp, _ = resty.R().SetBasicAuth(username, passphrase).Get(secureBaseUrl + "/v2/") + resp, _ = resty.R().SetBasicAuth(username, passphrase).Get(secureBaseURL + "/v2/") So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 200) }) @@ -1157,7 +1157,7 @@ func TestBasicAuthWithLDAP(t *testing.T) { defer l.Stop() port := getFreePort() - baseUrl := getBaseUrl(port, false) + baseURL := getBaseURL(port, false) config := api.NewConfig() config.HTTP.Port = port @@ -1188,7 +1188,7 @@ func TestBasicAuthWithLDAP(t *testing.T) { // wait till ready for { - _, err := resty.R().Get(baseUrl) + _, err := resty.R().Get(baseURL) if err == nil { break } @@ -1201,7 +1201,7 @@ func TestBasicAuthWithLDAP(t *testing.T) { }() // without creds, should get access error - resp, err := resty.R().Get(baseUrl + "/v2/") + resp, err := resty.R().Get(baseURL + "/v2/") So(err, ShouldBeNil) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 401) @@ -1210,11 +1210,11 @@ func TestBasicAuthWithLDAP(t *testing.T) { So(err, ShouldBeNil) // with creds, should get expected status code - resp, _ = resty.R().SetBasicAuth(username, passphrase).Get(baseUrl) + resp, _ = resty.R().SetBasicAuth(username, passphrase).Get(baseURL) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 404) - resp, _ = resty.R().SetBasicAuth(username, passphrase).Get(baseUrl + "/v2/") + resp, _ = resty.R().SetBasicAuth(username, passphrase).Get(baseURL + "/v2/") So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 200) }) @@ -1226,7 +1226,7 @@ func TestBearerAuth(t *testing.T) { defer authTestServer.Close() port := getFreePort() - baseUrl := getBaseUrl(port, false) + baseURL := getBaseURL(port, false) config := api.NewConfig() config.HTTP.Port = port @@ -1255,7 +1255,7 @@ func TestBearerAuth(t *testing.T) { // wait till ready for { - _, err := resty.R().Get(baseUrl) + _, err := resty.R().Get(baseURL) if err == nil { break } @@ -1270,7 +1270,7 @@ func TestBearerAuth(t *testing.T) { blob := []byte("hello, blob!") digest := godigest.FromBytes(blob).String() - resp, err := resty.R().Get(baseUrl + "/v2/") + resp, err := resty.R().Get(baseURL + "/v2/") So(err, ShouldBeNil) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 401) @@ -1289,12 +1289,12 @@ func TestBearerAuth(t *testing.T) { resp, err = resty.R(). SetHeader("Authorization", fmt.Sprintf("Bearer %s", goodToken.AccessToken)). - Get(baseUrl + "/v2/") + Get(baseURL + "/v2/") So(err, ShouldBeNil) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 200) - resp, err = resty.R().Post(baseUrl + "/v2/" + AuthorizedNamespace + "/blobs/uploads/") + resp, err = resty.R().Post(baseURL + "/v2/" + AuthorizedNamespace + "/blobs/uploads/") So(err, ShouldBeNil) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 401) @@ -1312,7 +1312,7 @@ func TestBearerAuth(t *testing.T) { resp, err = resty.R(). SetHeader("Authorization", fmt.Sprintf("Bearer %s", goodToken.AccessToken)). - Post(baseUrl + "/v2/" + AuthorizedNamespace + "/blobs/uploads/") + Post(baseURL + "/v2/" + AuthorizedNamespace + "/blobs/uploads/") So(err, ShouldBeNil) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 202) @@ -1323,7 +1323,7 @@ func TestBearerAuth(t *testing.T) { SetHeader("Content-Type", "application/octet-stream"). SetQueryParam("digest", digest). SetBody(blob). - Put(baseUrl + loc) + Put(baseURL + loc) So(err, ShouldBeNil) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 401) @@ -1345,14 +1345,14 @@ func TestBearerAuth(t *testing.T) { SetHeader("Authorization", fmt.Sprintf("Bearer %s", goodToken.AccessToken)). SetQueryParam("digest", digest). SetBody(blob). - Put(baseUrl + loc) + Put(baseURL + loc) So(err, ShouldBeNil) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 201) resp, err = resty.R(). SetHeader("Authorization", fmt.Sprintf("Bearer %s", goodToken.AccessToken)). - Get(baseUrl + "/v2/" + AuthorizedNamespace + "/tags/list") + Get(baseURL + "/v2/" + AuthorizedNamespace + "/tags/list") So(err, ShouldBeNil) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 401) @@ -1370,13 +1370,13 @@ func TestBearerAuth(t *testing.T) { resp, err = resty.R(). SetHeader("Authorization", fmt.Sprintf("Bearer %s", goodToken.AccessToken)). - Get(baseUrl + "/v2/" + AuthorizedNamespace + "/tags/list") + Get(baseURL + "/v2/" + AuthorizedNamespace + "/tags/list") So(err, ShouldBeNil) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 200) resp, err = resty.R(). - Post(baseUrl + "/v2/" + UnauthorizedNamespace + "/blobs/uploads/") + Post(baseURL + "/v2/" + UnauthorizedNamespace + "/blobs/uploads/") So(err, ShouldBeNil) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 401) @@ -1395,7 +1395,7 @@ func TestBearerAuth(t *testing.T) { resp, err = resty.R(). SetHeader("Authorization", fmt.Sprintf("Bearer %s", badToken.AccessToken)). - Post(baseUrl + "/v2/" + UnauthorizedNamespace + "/blobs/uploads/") + Post(baseURL + "/v2/" + UnauthorizedNamespace + "/blobs/uploads/") So(err, ShouldBeNil) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 401) @@ -1408,7 +1408,7 @@ func TestBearerAuthWithAllowReadAccess(t *testing.T) { defer authTestServer.Close() port := getFreePort() - baseUrl := getBaseUrl(port, false) + baseURL := getBaseURL(port, false) config := api.NewConfig() config.HTTP.Port = port @@ -1438,7 +1438,7 @@ func TestBearerAuthWithAllowReadAccess(t *testing.T) { // wait till ready for { - _, err := resty.R().Get(baseUrl) + _, err := resty.R().Get(baseURL) if err == nil { break } @@ -1453,7 +1453,7 @@ func TestBearerAuthWithAllowReadAccess(t *testing.T) { blob := []byte("hello, blob!") digest := godigest.FromBytes(blob).String() - resp, err := resty.R().Get(baseUrl + "/v2/") + resp, err := resty.R().Get(baseURL + "/v2/") So(err, ShouldBeNil) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 401) @@ -1472,12 +1472,12 @@ func TestBearerAuthWithAllowReadAccess(t *testing.T) { resp, err = resty.R(). SetHeader("Authorization", fmt.Sprintf("Bearer %s", goodToken.AccessToken)). - Get(baseUrl + "/v2/") + Get(baseURL + "/v2/") So(err, ShouldBeNil) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 200) - resp, err = resty.R().Post(baseUrl + "/v2/" + AuthorizedNamespace + "/blobs/uploads/") + resp, err = resty.R().Post(baseURL + "/v2/" + AuthorizedNamespace + "/blobs/uploads/") So(err, ShouldBeNil) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 401) @@ -1495,7 +1495,7 @@ func TestBearerAuthWithAllowReadAccess(t *testing.T) { resp, err = resty.R(). SetHeader("Authorization", fmt.Sprintf("Bearer %s", goodToken.AccessToken)). - Post(baseUrl + "/v2/" + AuthorizedNamespace + "/blobs/uploads/") + Post(baseURL + "/v2/" + AuthorizedNamespace + "/blobs/uploads/") So(err, ShouldBeNil) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 202) @@ -1506,7 +1506,7 @@ func TestBearerAuthWithAllowReadAccess(t *testing.T) { SetHeader("Content-Type", "application/octet-stream"). SetQueryParam("digest", digest). SetBody(blob). - Put(baseUrl + loc) + Put(baseURL + loc) So(err, ShouldBeNil) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 401) @@ -1528,14 +1528,14 @@ func TestBearerAuthWithAllowReadAccess(t *testing.T) { SetHeader("Authorization", fmt.Sprintf("Bearer %s", goodToken.AccessToken)). SetQueryParam("digest", digest). SetBody(blob). - Put(baseUrl + loc) + Put(baseURL + loc) So(err, ShouldBeNil) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 201) resp, err = resty.R(). SetHeader("Authorization", fmt.Sprintf("Bearer %s", goodToken.AccessToken)). - Get(baseUrl + "/v2/" + AuthorizedNamespace + "/tags/list") + Get(baseURL + "/v2/" + AuthorizedNamespace + "/tags/list") So(err, ShouldBeNil) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 401) @@ -1553,13 +1553,13 @@ func TestBearerAuthWithAllowReadAccess(t *testing.T) { resp, err = resty.R(). SetHeader("Authorization", fmt.Sprintf("Bearer %s", goodToken.AccessToken)). - Get(baseUrl + "/v2/" + AuthorizedNamespace + "/tags/list") + Get(baseURL + "/v2/" + AuthorizedNamespace + "/tags/list") So(err, ShouldBeNil) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 200) resp, err = resty.R(). - Post(baseUrl + "/v2/" + UnauthorizedNamespace + "/blobs/uploads/") + Post(baseURL + "/v2/" + UnauthorizedNamespace + "/blobs/uploads/") So(err, ShouldBeNil) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 401) @@ -1578,7 +1578,7 @@ func TestBearerAuthWithAllowReadAccess(t *testing.T) { resp, err = resty.R(). SetHeader("Authorization", fmt.Sprintf("Bearer %s", badToken.AccessToken)). - Post(baseUrl + "/v2/" + UnauthorizedNamespace + "/blobs/uploads/") + Post(baseURL + "/v2/" + UnauthorizedNamespace + "/blobs/uploads/") So(err, ShouldBeNil) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 401) @@ -1642,7 +1642,7 @@ func parseBearerAuthHeader(authHeaderRaw string) *authHeader { func TestInvalidCases(t *testing.T) { Convey("Invalid repo dir", t, func() { port := getFreePort() - baseUrl := getBaseUrl(port, false) + baseURL := getBaseURL(port, false) config := api.NewConfig() config.HTTP.Port = port @@ -1676,7 +1676,7 @@ func TestInvalidCases(t *testing.T) { // wait till ready for { - _, err := resty.R().Get(baseUrl) + _, err := resty.R().Get(baseURL) if err == nil { break } @@ -1695,7 +1695,7 @@ func TestInvalidCases(t *testing.T) { postResponse, err := client.R(). SetBasicAuth(username, passphrase).SetQueryParams(params). - Post(fmt.Sprintf("%s/v2/%s/blobs/uploads/", baseUrl, name)) + Post(fmt.Sprintf("%s/v2/%s/blobs/uploads/", baseURL, name)) So(err, ShouldBeNil) So(postResponse.StatusCode(), ShouldEqual, 500) }) @@ -1709,7 +1709,7 @@ func TestHTTPReadOnly(t *testing.T) { singleCredtests = append(singleCredtests, getCredString(user, password)+"\n") port := getFreePort() - baseUrl := getBaseUrl(port, false) + baseURL := getBaseURL(port, false) for _, testString := range singleCredtests { func() { @@ -1740,7 +1740,7 @@ func TestHTTPReadOnly(t *testing.T) { }(c) // wait till ready for { - _, err := resty.R().Get(baseUrl) + _, err := resty.R().Get(baseURL) if err == nil { break } @@ -1748,7 +1748,7 @@ func TestHTTPReadOnly(t *testing.T) { } // with creds, should get expected status code - resp, _ := resty.R().SetBasicAuth(user, password).Get(baseUrl + "/v2/") + resp, _ := resty.R().SetBasicAuth(user, password).Get(baseURL + "/v2/") t.Log("Response Info:") t.Logf(" Error : %v", err) t.Logf(" Status Code: %v", resp.StatusCode()) @@ -1764,13 +1764,13 @@ func TestHTTPReadOnly(t *testing.T) { // with creds, any modifications should still fail on read-only mode resp, err = resty.R().SetBasicAuth(user, password). - Post(baseUrl + "/v2/" + AuthorizedNamespace + "/blobs/uploads/") + Post(baseURL + "/v2/" + AuthorizedNamespace + "/blobs/uploads/") So(err, ShouldBeNil) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 405) //with invalid creds, it should fail - resp, _ = resty.R().SetBasicAuth("chuck", "chuck").Get(baseUrl + "/v2/") + resp, _ = resty.R().SetBasicAuth("chuck", "chuck").Get(baseURL + "/v2/") So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, 401) @@ -1786,7 +1786,7 @@ func TestHTTPReadOnly(t *testing.T) { func TestCrossRepoMount(t *testing.T) { Convey("Cross Repo Mount", t, func() { port := getFreePort() - baseUrl := getBaseUrl(port, false) + baseURL := getBaseURL(port, false) config := api.NewConfig() config.HTTP.Port = port @@ -1824,7 +1824,7 @@ func TestCrossRepoMount(t *testing.T) { // wait till ready for { - _, err := resty.R().Get(baseUrl) + _, err := resty.R().Get(baseURL) if err == nil { break } @@ -1842,7 +1842,7 @@ func TestCrossRepoMount(t *testing.T) { client := resty.New() headResponse, err := client.R().SetBasicAuth(username, passphrase). - Head(fmt.Sprintf("%s/v2/%s/blobs/%s", baseUrl, name, digest)) + Head(fmt.Sprintf("%s/v2/%s/blobs/%s", baseURL, name, digest)) So(err, ShouldBeNil) So(headResponse.StatusCode(), ShouldEqual, 200) @@ -1850,7 +1850,7 @@ func TestCrossRepoMount(t *testing.T) { postResponse, err := client.R(). SetBasicAuth(username, passphrase).SetQueryParams(params). - Post(baseUrl + "/v2/zot-c-test/blobs/uploads/") + Post(baseURL + "/v2/zot-c-test/blobs/uploads/") So(err, ShouldBeNil) So(postResponse.StatusCode(), ShouldEqual, 202) @@ -1860,7 +1860,7 @@ func TestCrossRepoMount(t *testing.T) { postResponse, err = client.R(). SetBasicAuth(username, passphrase).SetQueryParams(incorrectParams). - Post(baseUrl + "/v2/zot-y-test/blobs/uploads/") + Post(baseURL + "/v2/zot-y-test/blobs/uploads/") So(err, ShouldBeNil) So(postResponse.StatusCode(), ShouldEqual, 202) @@ -1868,37 +1868,37 @@ func TestCrossRepoMount(t *testing.T) { params["mount"] = digest postResponse, err = client.R(). SetBasicAuth(username, passphrase).SetQueryParams(params). - Post(baseUrl + "/v2/zot-c-test/blobs/uploads/") + Post(baseURL + "/v2/zot-c-test/blobs/uploads/") So(err, ShouldBeNil) So(postResponse.StatusCode(), ShouldEqual, 201) // Send same request again postResponse, err = client.R(). SetBasicAuth(username, passphrase).SetQueryParams(params). - Post(baseUrl + "/v2/zot-c-test/blobs/uploads/") + Post(baseURL + "/v2/zot-c-test/blobs/uploads/") So(err, ShouldBeNil) So(postResponse.StatusCode(), ShouldEqual, 202) // Valid requests postResponse, err = client.R(). SetBasicAuth(username, passphrase).SetQueryParams(params). - Post(baseUrl + "/v2/zot-d-test/blobs/uploads/") + Post(baseURL + "/v2/zot-d-test/blobs/uploads/") So(err, ShouldBeNil) So(postResponse.StatusCode(), ShouldEqual, 201) headResponse, err = client.R().SetBasicAuth(username, passphrase). - Head(fmt.Sprintf("%s/v2/zot-cv-test/blobs/%s", baseUrl, digest)) + Head(fmt.Sprintf("%s/v2/zot-cv-test/blobs/%s", baseURL, digest)) So(err, ShouldBeNil) So(headResponse.StatusCode(), ShouldEqual, 404) postResponse, err = client.R(). - SetBasicAuth(username, passphrase).SetQueryParams(params).Post(baseUrl + "/v2/zot-c-test/blobs/uploads/") + SetBasicAuth(username, passphrase).SetQueryParams(params).Post(baseURL + "/v2/zot-c-test/blobs/uploads/") So(err, ShouldBeNil) So(postResponse.StatusCode(), ShouldEqual, 202) postResponse, err = client.R(). SetBasicAuth(username, passphrase).SetQueryParams(params). - Post(baseUrl + "/v2/ /blobs/uploads/") + Post(baseURL + "/v2/ /blobs/uploads/") So(err, ShouldBeNil) So(postResponse.StatusCode(), ShouldEqual, 404) @@ -1913,12 +1913,12 @@ func TestCrossRepoMount(t *testing.T) { postResponse, err = client.R().SetHeader("Content-type", "application/octet-stream"). SetBasicAuth(username, passphrase).SetQueryParam("digest", "sha256:"+blob). - SetBody(buf).Post(baseUrl + "/v2/zot-d-test/blobs/uploads/") + SetBody(buf).Post(baseURL + "/v2/zot-d-test/blobs/uploads/") So(err, ShouldBeNil) So(postResponse.StatusCode(), ShouldEqual, 201) headResponse, err = client.R().SetBasicAuth(username, passphrase). - Head(fmt.Sprintf("%s/v2/zot-cv-test/blobs/%s", baseUrl, digest)) + Head(fmt.Sprintf("%s/v2/zot-cv-test/blobs/%s", baseURL, digest)) So(err, ShouldBeNil) So(headResponse.StatusCode(), ShouldEqual, 200) @@ -1927,7 +1927,7 @@ func TestCrossRepoMount(t *testing.T) { params["mount"] = "sha256:" postResponse, err = client.R(). SetBasicAuth(username, passphrase).SetQueryParams(params). - Post(baseUrl + "/v2/zot-mount-test/blobs/uploads/") + Post(baseURL + "/v2/zot-mount-test/blobs/uploads/") So(err, ShouldBeNil) So(postResponse.StatusCode(), ShouldEqual, 405) @@ -1935,14 +1935,14 @@ func TestCrossRepoMount(t *testing.T) { params["from"] = "zot-cve-test" postResponse, err = client.R(). SetBasicAuth(username, passphrase).SetQueryParams(params). - Post(baseUrl + "/v2/zot-mount-test/blobs/uploads/") + Post(baseURL + "/v2/zot-mount-test/blobs/uploads/") So(err, ShouldBeNil) So(postResponse.StatusCode(), ShouldEqual, 405) }) Convey("Disable dedupe and cache", t, func() { port := getFreePort() - baseUrl := getBaseUrl(port, false) + baseURL := getBaseURL(port, false) config := api.NewConfig() config.HTTP.Port = port @@ -1984,7 +1984,7 @@ func TestCrossRepoMount(t *testing.T) { // wait till ready for { - _, err := resty.R().Get(baseUrl) + _, err := resty.R().Get(baseURL) if err == nil { break } @@ -1997,7 +1997,7 @@ func TestCrossRepoMount(t *testing.T) { client := resty.New() headResponse, err := client.R().SetBasicAuth(username, passphrase). - Head(fmt.Sprintf("%s/v2/%s/blobs/%s", baseUrl, name, digest)) + Head(fmt.Sprintf("%s/v2/%s/blobs/%s", baseURL, name, digest)) So(err, ShouldBeNil) So(headResponse.StatusCode(), ShouldEqual, 404) }) @@ -2099,7 +2099,7 @@ func TestParallelRequests(t *testing.T) { } port := getFreePort() - baseUrl := getBaseUrl(port, false) + baseURL := getBaseURL(port, false) config := api.NewConfig() config.HTTP.Port = port @@ -2146,7 +2146,7 @@ func TestParallelRequests(t *testing.T) { // wait till ready for { - _, err := resty.R().Get(baseUrl) + _, err := resty.R().Get(baseURL) if err == nil { break } @@ -2164,7 +2164,7 @@ func TestParallelRequests(t *testing.T) { client := resty.New() tagResponse, err := client.R().SetBasicAuth(username, passphrase). - Get(baseUrl + "/v2/" + testcase.destImageName + "/tags/list") + Get(baseURL + "/v2/" + testcase.destImageName + "/tags/list") assert.Equal(t, err, nil, "Error should be nil") assert.NotEqual(t, tagResponse.StatusCode(), 400, "bad request") @@ -2172,12 +2172,12 @@ func TestParallelRequests(t *testing.T) { for _, manifest := range manifestList { headResponse, err := client.R().SetBasicAuth(username, passphrase). - Head(baseUrl + "/v2/" + testcase.destImageName + "/manifests/" + manifest) + Head(baseURL + "/v2/" + testcase.destImageName + "/manifests/" + manifest) assert.Equal(t, err, nil, "Error should be nil") assert.Equal(t, headResponse.StatusCode(), 404, "response status code should return 404") getResponse, err := client.R().SetBasicAuth(username, passphrase). - Get(baseUrl + "/v2/" + testcase.destImageName + "/manifests/" + manifest) + Get(baseURL + "/v2/" + testcase.destImageName + "/manifests/" + manifest) assert.Equal(t, err, nil, "Error should be nil") assert.Equal(t, getResponse.StatusCode(), 404, "response status code should return 404") } @@ -2188,14 +2188,14 @@ func TestParallelRequests(t *testing.T) { // Get request of blob headResponse, err := client.R(). SetBasicAuth(username, passphrase). - Head(baseUrl + "/v2/" + testcase.destImageName + "/blobs/sha256:" + blob) + Head(baseURL + "/v2/" + testcase.destImageName + "/blobs/sha256:" + blob) assert.Equal(t, err, nil, "Should not be nil") assert.NotEqual(t, headResponse.StatusCode(), 500, "internal server error should not occurred") getResponse, err := client.R(). SetBasicAuth(username, passphrase). - Get(baseUrl + "/v2/" + testcase.destImageName + "/blobs/sha256:" + blob) + Get(baseURL + "/v2/" + testcase.destImageName + "/blobs/sha256:" + blob) assert.Equal(t, err, nil, "Should not be nil") assert.NotEqual(t, getResponse.StatusCode(), 500, "internal server error should not occurred") @@ -2211,7 +2211,7 @@ func TestParallelRequests(t *testing.T) { postResponse, err := client.R(). SetHeader("Content-type", "application/octet-stream"). SetBasicAuth(username, passphrase). - SetBody(buf).Post(baseUrl + "/v2/" + testcase.destImageName + "/blobs/uploads/") + SetBody(buf).Post(baseURL + "/v2/" + testcase.destImageName + "/blobs/uploads/") assert.Equal(t, err, nil, "Error should be nil") assert.NotEqual(t, postResponse.StatusCode(), 500, "response status code should not return 500") @@ -2223,7 +2223,7 @@ func TestParallelRequests(t *testing.T) { SetHeader("Content-type", "application/octet-stream"). SetBasicAuth(username, passphrase). SetBody(buf). - Post(baseUrl + "/v2/" + testcase.destImageName + "/blobs/uploads/") + Post(baseURL + "/v2/" + testcase.destImageName + "/blobs/uploads/") assert.Equal(t, err, nil, "Error should be nil") assert.NotEqual(t, postResponse.StatusCode(), 500, "response status code should not return 500") @@ -2268,7 +2268,7 @@ func TestParallelRequests(t *testing.T) { SetHeader("Content-Length", fmt.Sprintf("%d", n)). SetHeader("Content-Range", fmt.Sprintf("%d", readContent)+"-"+fmt.Sprintf("%d", readContent+n-1)). SetBasicAuth(username, passphrase). - Patch(baseUrl + "/v2/" + testcase.destImageName + "/blobs/uploads/" + sessionID) + Patch(baseURL + "/v2/" + testcase.destImageName + "/blobs/uploads/" + sessionID) assert.Equal(t, err, nil, "Error should be nil") assert.NotEqual(t, patchResponse.StatusCode(), 500, "response status code should not return 500") @@ -2288,7 +2288,7 @@ func TestParallelRequests(t *testing.T) { patchResponse, err := client.R().SetBody(b[0:n]).SetHeader("Content-type", "application/octet-stream"). SetBasicAuth(username, passphrase). - Patch(baseUrl + "/v2/" + testcase.destImageName + "/blobs/uploads/" + sessionID) + Patch(baseURL + "/v2/" + testcase.destImageName + "/blobs/uploads/" + sessionID) if err != nil { panic(err) @@ -2303,7 +2303,7 @@ func TestParallelRequests(t *testing.T) { SetHeader("Content-type", "application/octet-stream"). SetBasicAuth(username, passphrase). SetBody(buf).SetQueryParam("digest", "sha256:"+blob). - Post(baseUrl + "/v2/" + testcase.destImageName + "/blobs/uploads/") + Post(baseURL + "/v2/" + testcase.destImageName + "/blobs/uploads/") assert.Equal(t, err, nil, "Error should be nil") assert.NotEqual(t, postResponse.StatusCode(), 500, "response status code should not return 500") @@ -2311,14 +2311,14 @@ func TestParallelRequests(t *testing.T) { headResponse, err = client.R(). SetBasicAuth(username, passphrase). - Head(baseUrl + "/v2/" + testcase.destImageName + "/blobs/sha256:" + blob) + Head(baseURL + "/v2/" + testcase.destImageName + "/blobs/sha256:" + blob) assert.Equal(t, err, nil, "Should not be nil") assert.NotEqual(t, headResponse.StatusCode(), 500, "response should return success code") getResponse, err = client.R(). SetBasicAuth(username, passphrase). - Get(baseUrl + "/v2/" + testcase.destImageName + "/blobs/sha256:" + blob) + Get(baseURL + "/v2/" + testcase.destImageName + "/blobs/sha256:" + blob) assert.Equal(t, err, nil, "Should not be nil") assert.NotEqual(t, getResponse.StatusCode(), 500, "response should return success code") @@ -2326,7 +2326,7 @@ func TestParallelRequests(t *testing.T) { if i < 5 { // nolint: scopelint deleteResponse, err := client.R(). SetBasicAuth(username, passphrase). - Delete(baseUrl + "/v2/" + testcase.destImageName + "/blobs/sha256:" + blob) + Delete(baseURL + "/v2/" + testcase.destImageName + "/blobs/sha256:" + blob) assert.Equal(t, err, nil, "Should not be nil") assert.Equal(t, deleteResponse.StatusCode(), 202, "response should return success code") @@ -2334,12 +2334,12 @@ func TestParallelRequests(t *testing.T) { } tagResponse, err = client.R().SetBasicAuth(username, passphrase). - Get(baseUrl + "/v2/" + testcase.destImageName + "/tags/list") + Get(baseURL + "/v2/" + testcase.destImageName + "/tags/list") assert.Equal(t, err, nil, "Error should be nil") assert.Equal(t, tagResponse.StatusCode(), 200, "response status code should return success code") repoResponse, err := client.R().SetBasicAuth(username, passphrase). - Get(baseUrl + "/v2/_catalog") + Get(baseURL + "/v2/_catalog") assert.Equal(t, err, nil, "Error should be nil") assert.Equal(t, repoResponse.StatusCode(), 200, "response status code should return success code") }) @@ -2493,7 +2493,7 @@ func stopServer(ctrl *api.Controller) { func TestHardLink(t *testing.T) { Convey("Validate hard link", t, func() { port := getFreePort() - baseUrl := getBaseUrl(port, false) + baseURL := getBaseURL(port, false) config := api.NewConfig() config.HTTP.Port = port @@ -2547,7 +2547,7 @@ func TestHardLink(t *testing.T) { // wait till ready for { - _, err := resty.R().Get(baseUrl) + _, err := resty.R().Get(baseURL) if err == nil { break }