mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
MM-15784: Prevents non-private channels from being group-constrained … (#10950)
* MM-15784: Prevents non-private channels from being group-constrained via CLI. * MM-15786: Fixes tests.
This commit is contained in:
@@ -128,6 +128,10 @@ func channelGroupEnableCmdF(command *cobra.Command, args []string) error {
|
||||
return errors.New("Unable to find channel '" + args[0] + "'")
|
||||
}
|
||||
|
||||
if channel.Type != model.CHANNEL_PRIVATE {
|
||||
return errors.New("Channel '" + args[0] + "' is not private. It cannot be group-constrained")
|
||||
}
|
||||
|
||||
groups, _, appErr := a.GetGroupsByChannel(channel.Id, model.GroupSearchOpts{})
|
||||
if appErr != nil {
|
||||
return appErr
|
||||
|
||||
@@ -17,6 +17,11 @@ func TestChannelGroupEnable(t *testing.T) {
|
||||
// create public channel
|
||||
channel := th.CreatePublicChannel()
|
||||
|
||||
// try to enable, should fail it is private
|
||||
require.Error(t, th.RunCommand(t, "group", "channel", "enable", th.BasicTeam.Name+":"+channel.Name))
|
||||
|
||||
channel = th.CreatePrivateChannel()
|
||||
|
||||
// try to enable, should fail because channel has no groups
|
||||
require.Error(t, th.RunCommand(t, "group", "channel", "enable", th.BasicTeam.Name+":"+channel.Name))
|
||||
|
||||
@@ -54,8 +59,8 @@ func TestChannelGroupDisable(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
// create public channel
|
||||
channel := th.CreatePublicChannel()
|
||||
// create private channel
|
||||
channel := th.CreatePrivateChannel()
|
||||
|
||||
// try to disable, should work
|
||||
th.CheckCommand(t, "group", "channel", "disable", th.BasicTeam.Name+":"+channel.Name)
|
||||
@@ -104,8 +109,8 @@ func TestChannelGroupStatus(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
// create public channel
|
||||
channel := th.CreatePublicChannel()
|
||||
// create private channel
|
||||
channel := th.CreatePrivateChannel()
|
||||
|
||||
// get status, should be Disabled
|
||||
output := th.CheckCommand(t, "group", "channel", "status", th.BasicTeam.Name+":"+channel.Name)
|
||||
@@ -148,8 +153,8 @@ func TestChannelGroupList(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
// create public channel
|
||||
channel := th.CreatePublicChannel()
|
||||
// create private channel
|
||||
channel := th.CreatePrivateChannel()
|
||||
|
||||
// list groups for a channel with none, should work
|
||||
th.CheckCommand(t, "group", "channel", "list", th.BasicTeam.Name+":"+channel.Name)
|
||||
|
||||
Reference in New Issue
Block a user