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.
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
bb2e52ee68
Коммит
b7fcddb0fc
@@ -128,6 +128,10 @@ func channelGroupEnableCmdF(command *cobra.Command, args []string) error {
|
|||||||
return errors.New("Unable to find channel '" + args[0] + "'")
|
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{})
|
groups, _, appErr := a.GetGroupsByChannel(channel.Id, model.GroupSearchOpts{})
|
||||||
if appErr != nil {
|
if appErr != nil {
|
||||||
return appErr
|
return appErr
|
||||||
|
|||||||
@@ -17,6 +17,11 @@ func TestChannelGroupEnable(t *testing.T) {
|
|||||||
// create public channel
|
// create public channel
|
||||||
channel := th.CreatePublicChannel()
|
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
|
// try to enable, should fail because channel has no groups
|
||||||
require.Error(t, th.RunCommand(t, "group", "channel", "enable", th.BasicTeam.Name+":"+channel.Name))
|
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()
|
th := Setup().InitBasic()
|
||||||
defer th.TearDown()
|
defer th.TearDown()
|
||||||
|
|
||||||
// create public channel
|
// create private channel
|
||||||
channel := th.CreatePublicChannel()
|
channel := th.CreatePrivateChannel()
|
||||||
|
|
||||||
// try to disable, should work
|
// try to disable, should work
|
||||||
th.CheckCommand(t, "group", "channel", "disable", th.BasicTeam.Name+":"+channel.Name)
|
th.CheckCommand(t, "group", "channel", "disable", th.BasicTeam.Name+":"+channel.Name)
|
||||||
@@ -104,8 +109,8 @@ func TestChannelGroupStatus(t *testing.T) {
|
|||||||
th := Setup().InitBasic()
|
th := Setup().InitBasic()
|
||||||
defer th.TearDown()
|
defer th.TearDown()
|
||||||
|
|
||||||
// create public channel
|
// create private channel
|
||||||
channel := th.CreatePublicChannel()
|
channel := th.CreatePrivateChannel()
|
||||||
|
|
||||||
// get status, should be Disabled
|
// get status, should be Disabled
|
||||||
output := th.CheckCommand(t, "group", "channel", "status", th.BasicTeam.Name+":"+channel.Name)
|
output := th.CheckCommand(t, "group", "channel", "status", th.BasicTeam.Name+":"+channel.Name)
|
||||||
@@ -148,8 +153,8 @@ func TestChannelGroupList(t *testing.T) {
|
|||||||
th := Setup().InitBasic()
|
th := Setup().InitBasic()
|
||||||
defer th.TearDown()
|
defer th.TearDown()
|
||||||
|
|
||||||
// create public channel
|
// create private channel
|
||||||
channel := th.CreatePublicChannel()
|
channel := th.CreatePrivateChannel()
|
||||||
|
|
||||||
// list groups for a channel with none, should work
|
// list groups for a channel with none, should work
|
||||||
th.CheckCommand(t, "group", "channel", "list", th.BasicTeam.Name+":"+channel.Name)
|
th.CheckCommand(t, "group", "channel", "list", th.BasicTeam.Name+":"+channel.Name)
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user