From 384d0eb245e2aa325fdcfe2d8ee22a40c91af589 Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Mon, 6 Jun 2016 13:03:56 -0400 Subject: PLT-2559 Always return successful when trying to join a channel that the user is already a member of (#3265) * Added unit tests for SqlChannelStore.GetMember * Fixed api routes for accessing channels by name when the name includes an underscore * Changed join channel API to always return successful when the user is already a member of the channel --- api/channel_test.go | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'api/channel_test.go') diff --git a/api/channel_test.go b/api/channel_test.go index 175b0a14a..5c51e4d93 100644 --- a/api/channel_test.go +++ b/api/channel_test.go @@ -462,11 +462,25 @@ func TestJoinChannelById(t *testing.T) { user3 := th.CreateUser(th.BasicClient) LinkUserToTeam(user3, team) - Client.Login(user3.Email, "pwd") + Client.Must(Client.Login(user3.Email, "Password1")) if _, err := Client.JoinChannel(rchannel.Id); err == nil { t.Fatal("shoudn't be able to join direct channel") } + + th.LoginBasic() + + if _, err := Client.JoinChannel(channel1.Id); err != nil { + t.Fatal("should be able to join public channel that we're a member of") + } + + if _, err := Client.JoinChannel(channel3.Id); err != nil { + t.Fatal("should be able to join private channel that we're a member of") + } + + if _, err := Client.JoinChannel(rchannel.Id); err != nil { + t.Fatal("should be able to join direct channel that we're a member of") + } } func TestJoinChannelByName(t *testing.T) { @@ -492,11 +506,25 @@ func TestJoinChannelByName(t *testing.T) { user3 := th.CreateUser(th.BasicClient) LinkUserToTeam(user3, team) - Client.Login(user3.Email, "pwd") + Client.Must(Client.Login(user3.Email, "Password1")) if _, err := Client.JoinChannelByName(rchannel.Name); err == nil { t.Fatal("shoudn't be able to join direct channel") } + + th.LoginBasic() + + if _, err := Client.JoinChannelByName(channel1.Name); err != nil { + t.Fatal("should be able to join public channel that we're a member of") + } + + if _, err := Client.JoinChannelByName(channel3.Name); err != nil { + t.Fatal("should be able to join private channel that we're a member of") + } + + if _, err := Client.JoinChannelByName(rchannel.Name); err != nil { + t.Fatal("should be able to join direct channel that we're a member of") + } } func TestLeaveChannel(t *testing.T) { -- cgit v1.2.3-1-g7c22