diff options
author | cpanato <ctadeu@gmail.com> | 2018-07-10 19:27:14 +0200 |
---|---|---|
committer | cpanato <ctadeu@gmail.com> | 2018-07-10 19:27:14 +0200 |
commit | c042ffa460296587579aff54b157a5109e022f7e (patch) | |
tree | 9e7f77fbc83b6d06204db099066be8999dbb22d9 /app/command_groupmsg_test.go | |
parent | 9470564d355c201155f6fcb123152b8ac954f812 (diff) | |
parent | dccd95bc67779a5b83a2660aec0cf4622cd56550 (diff) | |
download | chat-c042ffa460296587579aff54b157a5109e022f7e.tar.gz chat-c042ffa460296587579aff54b157a5109e022f7e.tar.bz2 chat-c042ffa460296587579aff54b157a5109e022f7e.zip |
Merge remote-tracking branch 'upstream/release-5.1' into release-5.1-daily-merge-20180710
Diffstat (limited to 'app/command_groupmsg_test.go')
-rw-r--r-- | app/command_groupmsg_test.go | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/app/command_groupmsg_test.go b/app/command_groupmsg_test.go index 610d2e446..422679525 100644 --- a/app/command_groupmsg_test.go +++ b/app/command_groupmsg_test.go @@ -2,6 +2,11 @@ package app import ( "testing" + + "github.com/nicksnyder/go-i18n/i18n" + "github.com/stretchr/testify/assert" + + "github.com/mattermost/mattermost-server/model" ) func TestGroupMsgUsernames(t *testing.T) { @@ -35,3 +40,58 @@ func TestGroupMsgUsernames(t *testing.T) { t.Fatal("error parsing different types of users") } } + +func TestGroupMsgProvider(t *testing.T) { + th := Setup().InitBasic() + defer th.TearDown() + + user3 := th.CreateUser() + targetUsers := "@" + th.BasicUser2.Username + ",@" + user3.Username + " " + + team := th.CreateTeam() + th.LinkUserToTeam(th.BasicUser, team) + cmd := &groupmsgProvider{} + + // Check without permission to create a GM channel. + resp := cmd.DoCommand(th.App, &model.CommandArgs{ + T: i18n.IdentityTfunc(), + SiteURL: "http://test.url", + TeamId: team.Id, + UserId: th.BasicUser.Id, + Session: model.Session{ + Roles: "", + }, + }, targetUsers+"hello") + + channelName := model.GetGroupNameFromUserIds([]string{th.BasicUser.Id, th.BasicUser2.Id, user3.Id}) + assert.Equal(t, "api.command_groupmsg.permission.app_error", resp.Text) + assert.Equal(t, "", resp.GotoLocation) + + // Check with permission to create a GM channel. + resp = cmd.DoCommand(th.App, &model.CommandArgs{ + T: i18n.IdentityTfunc(), + SiteURL: "http://test.url", + TeamId: team.Id, + UserId: th.BasicUser.Id, + Session: model.Session{ + Roles: model.SYSTEM_USER_ROLE_ID, + }, + }, targetUsers+"hello") + + assert.Equal(t, "", resp.Text) + assert.Equal(t, "http://test.url/"+team.Name+"/channels/"+channelName, resp.GotoLocation) + + // Check without permission to post to an existing GM channel. + resp = cmd.DoCommand(th.App, &model.CommandArgs{ + T: i18n.IdentityTfunc(), + SiteURL: "http://test.url", + TeamId: team.Id, + UserId: th.BasicUser.Id, + Session: model.Session{ + Roles: "", + }, + }, targetUsers+"hello") + + assert.Equal(t, "", resp.Text) + assert.Equal(t, "http://test.url/"+team.Name+"/channels/"+channelName, resp.GotoLocation) +} |