diff options
author | 6543 <6543@obermui.de> | 2022-09-19 14:02:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-19 20:02:29 +0800 |
commit | c5e88fb03d01b929cfcf17c0a817d75572d44023 (patch) | |
tree | cab1d3ef10068716a833e6f36f830a34350155df /tests | |
parent | c87e6a89da05bcf57cc0b60359915efd008f744f (diff) | |
download | gitea-c5e88fb03d01b929cfcf17c0a817d75572d44023.tar.gz gitea-c5e88fb03d01b929cfcf17c0a817d75572d44023.zip |
[API] teamSearch show teams with no members if user is admin (#21204)
close #21176
Diffstat (limited to 'tests')
-rw-r--r-- | tests/integration/api_org_test.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/integration/api_org_test.go b/tests/integration/api_org_test.go index 70bb17bee2..4b8c5c97a8 100644 --- a/tests/integration/api_org_test.go +++ b/tests/integration/api_org_test.go @@ -5,6 +5,7 @@ package integration import ( + "fmt" "net/http" "net/url" "strings" @@ -151,3 +152,38 @@ func TestAPIGetAll(t *testing.T) { assert.Equal(t, "org25", apiOrgList[0].FullName) assert.Equal(t, "public", apiOrgList[0].Visibility) } + +func TestAPIOrgSearchEmptyTeam(t *testing.T) { + onGiteaRun(t, func(*testing.T, *url.URL) { + token := getUserToken(t, "user1") + orgName := "org_with_empty_team" + + // create org + req := NewRequestWithJSON(t, "POST", "/api/v1/orgs?token="+token, &api.CreateOrgOption{ + UserName: orgName, + }) + MakeRequest(t, req, http.StatusCreated) + + // create team with no member + req = NewRequestWithJSON(t, "POST", fmt.Sprintf("/api/v1/orgs/%s/teams?token=%s", orgName, token), &api.CreateTeamOption{ + Name: "Empty", + IncludesAllRepositories: true, + Permission: "read", + Units: []string{"repo.code", "repo.issues", "repo.ext_issues", "repo.wiki", "repo.pulls"}, + }) + MakeRequest(t, req, http.StatusCreated) + + // case-insensitive search for teams that have no members + req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/orgs/%s/teams/search?q=%s&token=%s", orgName, "empty", token)) + resp := MakeRequest(t, req, http.StatusOK) + data := struct { + Ok bool + Data []*api.Team + }{} + DecodeJSON(t, resp, &data) + assert.True(t, data.Ok) + if assert.Len(t, data.Data, 1) { + assert.EqualValues(t, "Empty", data.Data[0].Name) + } + }) +} |