diff options
author | KN4CK3R <admin@oldschoolhack.me> | 2023-12-22 00:59:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-21 23:59:59 +0000 |
commit | 838db2f8911690fa2115c6827ed73687db71bef1 (patch) | |
tree | 6c364eca7570962619d0e416dcc8b175331bbf2b /tests/integration/api_packages_cran_test.go | |
parent | 04b235d094218b780b62f024b7ae9716ad2e633f (diff) | |
download | gitea-838db2f8911690fa2115c6827ed73687db71bef1.tar.gz gitea-838db2f8911690fa2115c6827ed73687db71bef1.zip |
Convert to url auth to header auth in tests (#28484)
Related #28390
Diffstat (limited to 'tests/integration/api_packages_cran_test.go')
-rw-r--r-- | tests/integration/api_packages_cran_test.go | 45 |
1 files changed, 19 insertions, 26 deletions
diff --git a/tests/integration/api_packages_cran_test.go b/tests/integration/api_packages_cran_test.go index 9ef23226db..d307e87d4e 100644 --- a/tests/integration/api_packages_cran_test.go +++ b/tests/integration/api_packages_cran_test.go @@ -74,15 +74,13 @@ func TestPackageCran(t *testing.T) { req = NewRequestWithBody(t, "PUT", uploadURL, createArchive( "dummy.txt", []byte{}, - )) - req = AddBasicAuthHeader(req, user.Name) + )).AddBasicAuth(user.Name) MakeRequest(t, req, http.StatusBadRequest) req = NewRequestWithBody(t, "PUT", uploadURL, createArchive( "package/DESCRIPTION", createDescription(packageName, packageVersion), - )) - req = AddBasicAuthHeader(req, user.Name) + )).AddBasicAuth(user.Name) MakeRequest(t, req, http.StatusCreated) pvs, err := packages.GetVersionsByPackageType(db.DefaultContext, user.ID, packages.TypeCran) @@ -105,24 +103,23 @@ func TestPackageCran(t *testing.T) { req = NewRequestWithBody(t, "PUT", uploadURL, createArchive( "package/DESCRIPTION", createDescription(packageName, packageVersion), - )) - req = AddBasicAuthHeader(req, user.Name) + )).AddBasicAuth(user.Name) MakeRequest(t, req, http.StatusConflict) }) t.Run("Download", func(t *testing.T) { defer tests.PrintCurrentTest(t)() - req := NewRequest(t, "GET", fmt.Sprintf("%s/src/contrib/%s_%s.tar.gz", url, packageName, packageVersion)) - req = AddBasicAuthHeader(req, user.Name) + req := NewRequest(t, "GET", fmt.Sprintf("%s/src/contrib/%s_%s.tar.gz", url, packageName, packageVersion)). + AddBasicAuth(user.Name) MakeRequest(t, req, http.StatusOK) }) t.Run("Enumerate", func(t *testing.T) { defer tests.PrintCurrentTest(t)() - req := NewRequest(t, "GET", url+"/src/contrib/PACKAGES") - req = AddBasicAuthHeader(req, user.Name) + req := NewRequest(t, "GET", url+"/src/contrib/PACKAGES"). + AddBasicAuth(user.Name) resp := MakeRequest(t, req, http.StatusOK) assert.Contains(t, resp.Header().Get("Content-Type"), "text/plain") @@ -131,8 +128,8 @@ func TestPackageCran(t *testing.T) { assert.Contains(t, body, fmt.Sprintf("Package: %s", packageName)) assert.Contains(t, body, fmt.Sprintf("Version: %s", packageVersion)) - req = NewRequest(t, "GET", url+"/src/contrib/PACKAGES.gz") - req = AddBasicAuthHeader(req, user.Name) + req = NewRequest(t, "GET", url+"/src/contrib/PACKAGES.gz"). + AddBasicAuth(user.Name) resp = MakeRequest(t, req, http.StatusOK) assert.Contains(t, resp.Header().Get("Content-Type"), "application/x-gzip") @@ -160,15 +157,13 @@ func TestPackageCran(t *testing.T) { req = NewRequestWithBody(t, "PUT", uploadURL, createArchive( "dummy.txt", []byte{}, - )) - req = AddBasicAuthHeader(req, user.Name) + )).AddBasicAuth(user.Name) MakeRequest(t, req, http.StatusBadRequest) req = NewRequestWithBody(t, "PUT", uploadURL+"?platform=&rversion=", createArchive( "package/DESCRIPTION", createDescription(packageName, packageVersion), - )) - req = AddBasicAuthHeader(req, user.Name) + )).AddBasicAuth(user.Name) MakeRequest(t, req, http.StatusBadRequest) uploadURL += "?platform=windows&rversion=4.2" @@ -176,8 +171,7 @@ func TestPackageCran(t *testing.T) { req = NewRequestWithBody(t, "PUT", uploadURL, createArchive( "package/DESCRIPTION", createDescription(packageName, packageVersion), - )) - req = AddBasicAuthHeader(req, user.Name) + )).AddBasicAuth(user.Name) MakeRequest(t, req, http.StatusCreated) pvs, err := packages.GetVersionsByPackageType(db.DefaultContext, user.ID, packages.TypeCran) @@ -191,8 +185,7 @@ func TestPackageCran(t *testing.T) { req = NewRequestWithBody(t, "PUT", uploadURL, createArchive( "package/DESCRIPTION", createDescription(packageName, packageVersion), - )) - req = AddBasicAuthHeader(req, user.Name) + )).AddBasicAuth(user.Name) MakeRequest(t, req, http.StatusConflict) }) @@ -210,8 +203,8 @@ func TestPackageCran(t *testing.T) { } for _, c := range cases { - req := NewRequest(t, "GET", fmt.Sprintf("%s/bin/%s/contrib/%s/%s_%s.zip", url, c.Platform, c.RVersion, packageName, packageVersion)) - req = AddBasicAuthHeader(req, user.Name) + req := NewRequest(t, "GET", fmt.Sprintf("%s/bin/%s/contrib/%s/%s_%s.zip", url, c.Platform, c.RVersion, packageName, packageVersion)). + AddBasicAuth(user.Name) MakeRequest(t, req, c.ExpectedStatus) } }) @@ -222,8 +215,8 @@ func TestPackageCran(t *testing.T) { req := NewRequest(t, "GET", url+"/bin/windows/contrib/4.1/PACKAGES") MakeRequest(t, req, http.StatusNotFound) - req = NewRequest(t, "GET", url+"/bin/windows/contrib/4.2/PACKAGES") - req = AddBasicAuthHeader(req, user.Name) + req = NewRequest(t, "GET", url+"/bin/windows/contrib/4.2/PACKAGES"). + AddBasicAuth(user.Name) resp := MakeRequest(t, req, http.StatusOK) assert.Contains(t, resp.Header().Get("Content-Type"), "text/plain") @@ -232,8 +225,8 @@ func TestPackageCran(t *testing.T) { assert.Contains(t, body, fmt.Sprintf("Package: %s", packageName)) assert.Contains(t, body, fmt.Sprintf("Version: %s", packageVersion)) - req = NewRequest(t, "GET", url+"/bin/windows/contrib/4.2/PACKAGES.gz") - req = AddBasicAuthHeader(req, user.Name) + req = NewRequest(t, "GET", url+"/bin/windows/contrib/4.2/PACKAGES.gz"). + AddBasicAuth(user.Name) resp = MakeRequest(t, req, http.StatusOK) assert.Contains(t, resp.Header().Get("Content-Type"), "application/x-gzip") |