summaryrefslogtreecommitdiffstats
path: root/api/channel_test.go
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2016-04-27 16:02:58 -0400
committerHarrison Healey <harrisonmhealey@gmail.com>2016-04-27 16:02:58 -0400
commitfa807d8e436e87b8c1749ea54c293a15c67f7f29 (patch)
tree9557bb5342425dffd3606cb03f1378de5f5cc032 /api/channel_test.go
parentd962e175f838817f4db060227cf8b5e2258b887c (diff)
downloadchat-fa807d8e436e87b8c1749ea54c293a15c67f7f29.tar.gz
chat-fa807d8e436e87b8c1749ea54c293a15c67f7f29.tar.bz2
chat-fa807d8e436e87b8c1749ea54c293a15c67f7f29.zip
Fixing permalinks to channels your not a memeber of (#2805)
Diffstat (limited to 'api/channel_test.go')
-rw-r--r--api/channel_test.go32
1 files changed, 31 insertions, 1 deletions
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