From fa807d8e436e87b8c1749ea54c293a15c67f7f29 Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Wed, 27 Apr 2016 16:02:58 -0400 Subject: Fixing permalinks to channels your not a memeber of (#2805) --- api/channel_test.go | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'api/channel_test.go') diff --git a/api/channel_test.go b/api/channel_test.go index 23dd77698..8ac785f77 100644 --- a/api/channel_test.go +++ b/api/channel_test.go @@ -395,7 +395,7 @@ func TestGetChannelCounts(t *testing.T) { } -func TestJoinChannel(t *testing.T) { +func TestJoinChannelById(t *testing.T) { th := Setup().InitBasic() Client := th.BasicClient team := th.BasicTeam @@ -425,6 +425,36 @@ func TestJoinChannel(t *testing.T) { } } +func TestJoinChannelByName(t *testing.T) { + th := Setup().InitBasic() + Client := th.BasicClient + team := th.BasicTeam + + channel1 := &model.Channel{DisplayName: "A Test API Name", Name: "a" + model.NewId() + "a", Type: model.CHANNEL_OPEN, TeamId: team.Id} + channel1 = Client.Must(Client.CreateChannel(channel1)).Data.(*model.Channel) + + channel3 := &model.Channel{DisplayName: "B Test API Name", Name: "a" + model.NewId() + "a", Type: model.CHANNEL_PRIVATE, TeamId: team.Id} + channel3 = Client.Must(Client.CreateChannel(channel3)).Data.(*model.Channel) + + th.LoginBasic2() + + Client.Must(Client.JoinChannelByName(channel1.Name)) + + if _, err := Client.JoinChannelByName(channel3.Name); err == nil { + t.Fatal("shouldn't be able to join secret group") + } + + rchannel := Client.Must(Client.CreateDirectChannel(th.BasicUser.Id)).Data.(*model.Channel) + + user3 := th.CreateUser(th.BasicClient) + LinkUserToTeam(user3, team) + Client.LoginByEmail(team.Name, user3.Email, "pwd") + + if _, err := Client.JoinChannelByName(rchannel.Name); err == nil { + t.Fatal("shoudn't be able to join direct channel") + } +} + func TestLeaveChannel(t *testing.T) { th := Setup().InitBasic() Client := th.BasicClient -- cgit v1.2.3-1-g7c22