Sanitize teamsWithCount Teams (#19280)

Automatic Merge
This commit is contained in:
Anurag Shivarathri
2022-01-17 14:59:52 +02:00
committed by GitHub
parent 770f7a8e5a
commit 0a06b3e808
2 changed files with 15 additions and 2 deletions
+2 -2
View File
@@ -1055,13 +1055,13 @@ func getAllTeams(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
c.App.SanitizeTeams(*c.AppContext.Session(), teams)
var js []byte
var jsonErr error
if c.Params.IncludeTotalCount {
c.App.SanitizeTeams(*c.AppContext.Session(), teamsWithCount.Teams)
js, jsonErr = json.Marshal(teamsWithCount)
} else {
c.App.SanitizeTeams(*c.AppContext.Session(), teams)
js, jsonErr = json.Marshal(teams)
}
if jsonErr != nil {
+13
View File
@@ -1123,6 +1123,19 @@ func TestGetAllTeams(t *testing.T) {
require.Error(t, err)
CheckUnauthorizedStatus(t, resp)
})
t.Run("Sanitize the teams in the response with total count", func(t *testing.T) {
otherUser := th.CreateUser()
client.Login(otherUser.Email, otherUser.Password)
teams, _, _, err := client.GetAllTeamsWithTotalCount("", 0, 10)
require.NoError(t, err)
for _, team := range teams {
if team.Email != "" {
require.Nil(t, team.Email)
break
}
}
})
}
func TestGetAllTeamsSanitization(t *testing.T) {