aboutsummaryrefslogtreecommitdiffstats
path: root/integrations/api_team_test.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-04-08 12:22:10 +0800
committerGitHub <noreply@github.com>2022-04-08 06:22:10 +0200
commit3c3d49899f0f7206e190bdeecdc4da248cc7e686 (patch)
tree7d1f57f7655142b47b5adeb197943c74c1e6f8c9 /integrations/api_team_test.go
parent75f8534c3a8678f4b55e557960450230cf909b93 (diff)
downloadgitea-3c3d49899f0f7206e190bdeecdc4da248cc7e686.tar.gz
gitea-3c3d49899f0f7206e190bdeecdc4da248cc7e686.zip
Remove dependent on session auth for api/v1 routers (#19321)
* Remove dependent on session auth for api/v1 routers * Remove unnecessary session on API context * remove missed header * fix test * fix missed api/v1
Diffstat (limited to 'integrations/api_team_test.go')
-rw-r--r--integrations/api_team_test.go17
1 files changed, 7 insertions, 10 deletions
diff --git a/integrations/api_team_test.go b/integrations/api_team_test.go
index 7f6d1b81d4..daf1efa2be 100644
--- a/integrations/api_team_test.go
+++ b/integrations/api_team_test.go
@@ -224,11 +224,9 @@ func TestAPITeamSearch(t *testing.T) {
var results TeamSearchResults
- session := loginUser(t, user.Name)
- csrf := GetCSRF(t, session, "/"+org.Name)
- req := NewRequestf(t, "GET", "/api/v1/orgs/%s/teams/search?q=%s", org.Name, "_team")
- req.Header.Add("X-Csrf-Token", csrf)
- resp := session.MakeRequest(t, req, http.StatusOK)
+ token := getUserToken(t, user.Name)
+ req := NewRequestf(t, "GET", "/api/v1/orgs/%s/teams/search?q=%s&token=%s", org.Name, "_team", token)
+ resp := MakeRequest(t, req, http.StatusOK)
DecodeJSON(t, resp, &results)
assert.NotEmpty(t, results.Data)
assert.Len(t, results.Data, 1)
@@ -236,9 +234,8 @@ func TestAPITeamSearch(t *testing.T) {
// no access if not organization member
user5 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 5}).(*user_model.User)
- session = loginUser(t, user5.Name)
- csrf = GetCSRF(t, session, "/"+org.Name)
- req = NewRequestf(t, "GET", "/api/v1/orgs/%s/teams/search?q=%s", org.Name, "team")
- req.Header.Add("X-Csrf-Token", csrf)
- session.MakeRequest(t, req, http.StatusForbidden)
+ token5 := getUserToken(t, user5.Name)
+
+ req = NewRequestf(t, "GET", "/api/v1/orgs/%s/teams/search?q=%s&token=%s", org.Name, "team", token5)
+ MakeRequest(t, req, http.StatusForbidden)
}