Automatic Merge
Этот коммит содержится в:
Anurag Shivarathri
2022-01-17 18:29:52 +05:30
коммит произвёл GitHub
родитель 770f7a8e5a
Коммит 0a06b3e808
2 изменённых файлов: 15 добавлений и 2 удалений

Просмотреть файл

@@ -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 {

Просмотреть файл

@@ -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) {