diff options
author | Carlos Tadeu Panato Junior <ctadeu@gmail.com> | 2018-01-12 15:01:45 +0100 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2018-01-12 09:01:45 -0500 |
commit | 3d3a234fca1d2ee43f5c4fc8961d44fde2512c82 (patch) | |
tree | af962fff2db3c4c412268600adf270eec3ecff46 /api4 | |
parent | 4acc2238e9088fbdc0a1e288987d5b9d349dd2eb (diff) | |
download | chat-3d3a234fca1d2ee43f5c4fc8961d44fde2512c82.tar.gz chat-3d3a234fca1d2ee43f5c4fc8961d44fde2512c82.tar.bz2 chat-3d3a234fca1d2ee43f5c4fc8961d44fde2512c82.zip |
[PLT-8430] Auto lowercase team and channel names in API requests (#7992)
Diffstat (limited to 'api4')
-rw-r--r-- | api4/channel_test.go | 4 | ||||
-rw-r--r-- | api4/params.go | 5 | ||||
-rw-r--r-- | api4/team_test.go | 3 |
3 files changed, 10 insertions, 2 deletions
diff --git a/api4/channel_test.go b/api4/channel_test.go index 79cbb8331..724b0d84b 100644 --- a/api4/channel_test.go +++ b/api4/channel_test.go @@ -9,6 +9,7 @@ import ( "reflect" "sort" "strconv" + "strings" "testing" "github.com/mattermost/mattermost-server/model" @@ -1136,6 +1137,9 @@ func TestGetChannelByName(t *testing.T) { 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) _, resp = Client.GetChannelByName(th.BasicChannel.Name, th.BasicTeam.Id, "") CheckNoError(t, resp) diff --git a/api4/params.go b/api4/params.go index 64ee43771..30638578b 100644 --- a/api4/params.go +++ b/api4/params.go @@ -6,6 +6,7 @@ package api4 import ( "net/http" "strconv" + "strings" "github.com/gorilla/mux" ) @@ -115,11 +116,11 @@ func ApiParamsFromRequest(r *http.Request) *ApiParams { } if val, ok := props["team_name"]; ok { - params.TeamName = val + params.TeamName = strings.ToLower(val) } if val, ok := props["channel_name"]; ok { - params.ChannelName = val + params.ChannelName = strings.ToLower(val) } if val, ok := props["category"]; ok { diff --git a/api4/team_test.go b/api4/team_test.go index ebae18f7a..5d416c04d 100644 --- a/api4/team_test.go +++ b/api4/team_test.go @@ -710,6 +710,9 @@ func TestGetTeamByName(t *testing.T) { _, resp = Client.GetTeamByName("", "") CheckNotFoundStatus(t, resp) + _, resp = th.SystemAdminClient.GetTeamByName(strings.ToUpper(team.Name), "") + CheckNoError(t, resp) + Client.Logout() _, resp = Client.GetTeamByName(team.Name, "") CheckUnauthorizedStatus(t, resp) |