diff options
author | David Svantesson <davidsvantesson@gmail.com> | 2019-10-01 07:32:28 +0200 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2019-10-01 13:32:28 +0800 |
commit | 36bcd4cd6b6d1131e3f812a825558fbfe5dcca20 (patch) | |
tree | 1606d302648ca6f2f6633d21aeb5d06a568b14d8 /integrations/api_team_test.go | |
parent | d3bc3dd4d16aef053699d5bfc45039db060d373e (diff) | |
download | gitea-36bcd4cd6b6d1131e3f812a825558fbfe5dcca20.tar.gz gitea-36bcd4cd6b6d1131e3f812a825558fbfe5dcca20.zip |
API endpoint for searching teams. (#8108)
* Api endpoint for searching teams.
Signed-off-by: dasv <david.svantesson@qrtech.se>
* Move API to /orgs/:org/teams/search
Signed-off-by: David Svantesson <davidsvantesson@gmail.com>
* Regenerate swagger
Signed-off-by: David Svantesson <davidsvantesson@gmail.com>
* Fix search is Get
Signed-off-by: David Svantesson <davidsvantesson@gmail.com>
* Add test for search team API.
Signed-off-by: David Svantesson <davidsvantesson@gmail.com>
* Update routers/api/v1/org/team.go
grammar
Co-Authored-By: Richard Mahn <richmahn@users.noreply.github.com>
* Fix review comments
Signed-off-by: David Svantesson <davidsvantesson@gmail.com>
* Fix some issues in repo collaboration team search, after changes in this PR.
Signed-off-by: David Svantesson <davidsvantesson@gmail.com>
* Remove teamUser which is not used and replace with actual user id.
Signed-off-by: David Svantesson <davidsvantesson@gmail.com>
* Remove unused search variable UserIsAdmin.
* Add paging to team search.
* Re-genereate swagger
Signed-off-by: David Svantesson <davidsvantesson@gmail.com>
* Fix review comments
Signed-off-by: David Svantesson <davidsvantesson@gmail.com>
* fix
* Regenerate swagger
Diffstat (limited to 'integrations/api_team_test.go')
-rw-r--r-- | integrations/api_team_test.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/integrations/api_team_test.go b/integrations/api_team_test.go index a7c22d6ba1..38e202f239 100644 --- a/integrations/api_team_test.go +++ b/integrations/api_team_test.go @@ -107,3 +107,32 @@ func checkTeamBean(t *testing.T, id int64, name, description string, permission assert.NoError(t, team.GetUnits(), "GetUnits") checkTeamResponse(t, convert.ToTeam(team), name, description, permission, units) } + +type TeamSearchResults struct { + OK bool `json:"ok"` + Data []*api.Team `json:"data"` +} + +func TestAPITeamSearch(t *testing.T) { + prepareTestEnv(t) + + user := models.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User) + org := models.AssertExistsAndLoadBean(t, &models.User{ID: 3}).(*models.User) + + var results TeamSearchResults + + session := loginUser(t, user.Name) + req := NewRequestf(t, "GET", "/api/v1/orgs/%s/teams/search?q=%s", org.Name, "_team") + resp := session.MakeRequest(t, req, http.StatusOK) + DecodeJSON(t, resp, &results) + assert.NotEmpty(t, results.Data) + assert.Equal(t, 1, len(results.Data)) + assert.Equal(t, "test_team", results.Data[0].Name) + + // no access if not organization member + user5 := models.AssertExistsAndLoadBean(t, &models.User{ID: 5}).(*models.User) + session = loginUser(t, user5.Name) + req = NewRequestf(t, "GET", "/api/v1/orgs/%s/teams/search?q=%s", org.Name, "team") + resp = session.MakeRequest(t, req, http.StatusForbidden) + +} |