summaryrefslogtreecommitdiffstats
path: root/tests/integration/api_packages_composer_test.go
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2023-12-22 00:59:59 +0100
committerGitHub <noreply@github.com>2023-12-21 23:59:59 +0000
commit838db2f8911690fa2115c6827ed73687db71bef1 (patch)
tree6c364eca7570962619d0e416dcc8b175331bbf2b /tests/integration/api_packages_composer_test.go
parent04b235d094218b780b62f024b7ae9716ad2e633f (diff)
downloadgitea-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_composer_test.go')
-rw-r--r--tests/integration/api_packages_composer_test.go32
1 files changed, 16 insertions, 16 deletions
diff --git a/tests/integration/api_packages_composer_test.go b/tests/integration/api_packages_composer_test.go
index 896462d9a9..6e0d2eee1b 100644
--- a/tests/integration/api_packages_composer_test.go
+++ b/tests/integration/api_packages_composer_test.go
@@ -59,8 +59,8 @@ func TestPackageComposer(t *testing.T) {
t.Run("ServiceIndex", func(t *testing.T) {
defer tests.PrintCurrentTest(t)()
- req := NewRequest(t, "GET", fmt.Sprintf("%s/packages.json", url))
- req = AddBasicAuthHeader(req, user.Name)
+ req := NewRequest(t, "GET", fmt.Sprintf("%s/packages.json", url)).
+ AddBasicAuth(user.Name)
resp := MakeRequest(t, req, http.StatusOK)
var result composer.ServiceIndexResponse
@@ -75,8 +75,8 @@ func TestPackageComposer(t *testing.T) {
t.Run("MissingVersion", func(t *testing.T) {
defer tests.PrintCurrentTest(t)()
- req := NewRequestWithBody(t, "PUT", url, bytes.NewReader(content))
- req = AddBasicAuthHeader(req, user.Name)
+ req := NewRequestWithBody(t, "PUT", url, bytes.NewReader(content)).
+ AddBasicAuth(user.Name)
MakeRequest(t, req, http.StatusBadRequest)
})
@@ -85,8 +85,8 @@ func TestPackageComposer(t *testing.T) {
uploadURL := url + "?version=" + packageVersion
- req := NewRequestWithBody(t, "PUT", uploadURL, bytes.NewReader(content))
- req = AddBasicAuthHeader(req, user.Name)
+ req := NewRequestWithBody(t, "PUT", uploadURL, bytes.NewReader(content)).
+ AddBasicAuth(user.Name)
MakeRequest(t, req, http.StatusCreated)
pvs, err := packages.GetVersionsByPackageType(db.DefaultContext, user.ID, packages.TypeComposer)
@@ -110,8 +110,8 @@ func TestPackageComposer(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, int64(len(content)), pb.Size)
- req = NewRequestWithBody(t, "PUT", uploadURL, bytes.NewReader(content))
- req = AddBasicAuthHeader(req, user.Name)
+ req = NewRequestWithBody(t, "PUT", uploadURL, bytes.NewReader(content)).
+ AddBasicAuth(user.Name)
MakeRequest(t, req, http.StatusConflict)
})
})
@@ -128,8 +128,8 @@ func TestPackageComposer(t *testing.T) {
assert.NoError(t, err)
assert.Len(t, pfs, 1)
- req := NewRequest(t, "GET", fmt.Sprintf("%s/files/%s/%s/%s", url, neturl.PathEscape(packageName), neturl.PathEscape(pvs[0].LowerVersion), neturl.PathEscape(pfs[0].LowerName)))
- req = AddBasicAuthHeader(req, user.Name)
+ req := NewRequest(t, "GET", fmt.Sprintf("%s/files/%s/%s/%s", url, neturl.PathEscape(packageName), neturl.PathEscape(pvs[0].LowerVersion), neturl.PathEscape(pfs[0].LowerName))).
+ AddBasicAuth(user.Name)
resp := MakeRequest(t, req, http.StatusOK)
assert.Equal(t, content, resp.Body.Bytes())
@@ -162,8 +162,8 @@ func TestPackageComposer(t *testing.T) {
}
for i, c := range cases {
- req := NewRequest(t, "GET", fmt.Sprintf("%s/search.json?q=%s&type=%s&page=%d&per_page=%d", url, c.Query, c.Type, c.Page, c.PerPage))
- req = AddBasicAuthHeader(req, user.Name)
+ req := NewRequest(t, "GET", fmt.Sprintf("%s/search.json?q=%s&type=%s&page=%d&per_page=%d", url, c.Query, c.Type, c.Page, c.PerPage)).
+ AddBasicAuth(user.Name)
resp := MakeRequest(t, req, http.StatusOK)
var result composer.SearchResultResponse
@@ -177,8 +177,8 @@ func TestPackageComposer(t *testing.T) {
t.Run("EnumeratePackages", func(t *testing.T) {
defer tests.PrintCurrentTest(t)()
- req := NewRequest(t, "GET", url+"/list.json")
- req = AddBasicAuthHeader(req, user.Name)
+ req := NewRequest(t, "GET", url+"/list.json").
+ AddBasicAuth(user.Name)
resp := MakeRequest(t, req, http.StatusOK)
var result map[string][]string
@@ -193,8 +193,8 @@ func TestPackageComposer(t *testing.T) {
t.Run("PackageMetadata", func(t *testing.T) {
defer tests.PrintCurrentTest(t)()
- req := NewRequest(t, "GET", fmt.Sprintf("%s/p2/%s/%s.json", url, vendorName, projectName))
- req = AddBasicAuthHeader(req, user.Name)
+ req := NewRequest(t, "GET", fmt.Sprintf("%s/p2/%s/%s.json", url, vendorName, projectName)).
+ AddBasicAuth(user.Name)
resp := MakeRequest(t, req, http.StatusOK)
var result composer.PackageMetadataResponse