[PLT-8430] Auto lowercase team and channel names in API requests (#7992)
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
4acc2238e9
Коммит
3d3a234fca
@@ -9,6 +9,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/mattermost/mattermost-server/model"
|
"github.com/mattermost/mattermost-server/model"
|
||||||
@@ -1136,6 +1137,9 @@ func TestGetChannelByName(t *testing.T) {
|
|||||||
t.Fatal("names did not match")
|
t.Fatal("names did not match")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_, resp = Client.GetChannelByName(strings.ToUpper(th.BasicPrivateChannel.Name), th.BasicTeam.Id, "")
|
||||||
|
CheckNoError(t, resp)
|
||||||
|
|
||||||
Client.RemoveUserFromChannel(th.BasicChannel.Id, th.BasicUser.Id)
|
Client.RemoveUserFromChannel(th.BasicChannel.Id, th.BasicUser.Id)
|
||||||
_, resp = Client.GetChannelByName(th.BasicChannel.Name, th.BasicTeam.Id, "")
|
_, resp = Client.GetChannelByName(th.BasicChannel.Name, th.BasicTeam.Id, "")
|
||||||
CheckNoError(t, resp)
|
CheckNoError(t, resp)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ package api4
|
|||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
)
|
)
|
||||||
@@ -115,11 +116,11 @@ func ApiParamsFromRequest(r *http.Request) *ApiParams {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if val, ok := props["team_name"]; ok {
|
if val, ok := props["team_name"]; ok {
|
||||||
params.TeamName = val
|
params.TeamName = strings.ToLower(val)
|
||||||
}
|
}
|
||||||
|
|
||||||
if val, ok := props["channel_name"]; ok {
|
if val, ok := props["channel_name"]; ok {
|
||||||
params.ChannelName = val
|
params.ChannelName = strings.ToLower(val)
|
||||||
}
|
}
|
||||||
|
|
||||||
if val, ok := props["category"]; ok {
|
if val, ok := props["category"]; ok {
|
||||||
|
|||||||
@@ -710,6 +710,9 @@ func TestGetTeamByName(t *testing.T) {
|
|||||||
_, resp = Client.GetTeamByName("", "")
|
_, resp = Client.GetTeamByName("", "")
|
||||||
CheckNotFoundStatus(t, resp)
|
CheckNotFoundStatus(t, resp)
|
||||||
|
|
||||||
|
_, resp = th.SystemAdminClient.GetTeamByName(strings.ToUpper(team.Name), "")
|
||||||
|
CheckNoError(t, resp)
|
||||||
|
|
||||||
Client.Logout()
|
Client.Logout()
|
||||||
_, resp = Client.GetTeamByName(team.Name, "")
|
_, resp = Client.GetTeamByName(team.Name, "")
|
||||||
CheckUnauthorizedStatus(t, resp)
|
CheckUnauthorizedStatus(t, resp)
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user