aboutsummaryrefslogtreecommitdiffstats
path: root/integrations
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2022-08-09 16:36:49 +0200
committerGitHub <noreply@github.com>2022-08-09 17:36:49 +0300
commit7009eb9a24a800b7fb884b54f81885815ea4d286 (patch)
tree430bba7d00e8b92719646537413db06004fae0c7 /integrations
parent920481340b3d3c384c16296be52ca187ee8b0e0b (diff)
downloadgitea-7009eb9a24a800b7fb884b54f81885815ea4d286.tar.gz
gitea-7009eb9a24a800b7fb884b54f81885815ea4d286.zip
Add support for NuGet API keys (#20721)
* Add support for NuGet API key. * lint * Apply suggestions from code review Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'integrations')
-rw-r--r--integrations/api_packages_nuget_test.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/integrations/api_packages_nuget_test.go b/integrations/api_packages_nuget_test.go
index 346f391f82..06eb485541 100644
--- a/integrations/api_packages_nuget_test.go
+++ b/integrations/api_packages_nuget_test.go
@@ -24,9 +24,16 @@ import (
"github.com/stretchr/testify/assert"
)
+func addNuGetAPIKeyHeader(request *http.Request, token string) *http.Request {
+ request.Header.Set("X-NuGet-ApiKey", token)
+ return request
+}
+
func TestPackageNuGet(t *testing.T) {
defer prepareTestEnv(t)()
+
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}).(*user_model.User)
+ token := getUserToken(t, user.Name)
packageName := "test.package"
packageVersion := "1.0.3"
@@ -60,6 +67,10 @@ func TestPackageNuGet(t *testing.T) {
req := NewRequest(t, "GET", fmt.Sprintf("%s/index.json", url))
req = AddBasicAuthHeader(req, user.Name)
+ MakeRequest(t, req, http.StatusOK)
+
+ req = NewRequest(t, "GET", fmt.Sprintf("%s/index.json", url))
+ req = addNuGetAPIKeyHeader(req, token)
resp := MakeRequest(t, req, http.StatusOK)
var result nuget.ServiceIndexResponse