Files
mostlymatter/server/channels/app/shared_channel_test.go
Miguel de la Cruz d5e9aa9fb3 Adds ConnectedWorkspacesSettings configuration block (#27820)
* Adds ServerFederationSettings configuration block

The Server Federation related configuration properties were located in
the `ExperimentalSettings` config block. Now that the feature is going
to get out of beta, and foreseeing more configuration properties being
added to it, we're moving them to a block of its own.

If the properties were set in the old location, their values should be
carried over to the new ones. The old properties are left in place and
marked as deprecated not to cause issues with the model.

* Update System Console to include Server Federation section

* Remove system console section

* Move the configuration properties to ConnectedWorkspaces

* Add ConnectedWorkspacesSettings to the telemetry

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2024-09-10 22:33:00 +02:00

97 строки
3.1 KiB
Go

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package app
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/mattermost/mattermost/server/public/model"
)
func setupSharedChannels(tb testing.TB) *TestHelper {
return SetupConfig(tb, func(cfg *model.Config) {
*cfg.ConnectedWorkspacesSettings.EnableRemoteClusterService = true
*cfg.ConnectedWorkspacesSettings.EnableSharedChannels = true
})
}
func TestApp_CheckCanInviteToSharedChannel(t *testing.T) {
th := setupSharedChannels(t).InitBasic()
channel1 := th.CreateChannel(th.Context, th.BasicTeam)
channel2 := th.CreateChannel(th.Context, th.BasicTeam)
channel3 := th.CreateChannel(th.Context, th.BasicTeam)
data := []struct {
channelID string
home bool
name string
remoteID string
}{
{channelID: channel1.Id, home: true, name: "test_home", remoteID: ""},
{channelID: channel2.Id, home: false, name: "test_remote", remoteID: model.NewId()},
}
for _, d := range data {
sc := &model.SharedChannel{
ChannelId: d.channelID,
TeamId: th.BasicTeam.Id,
Home: d.home,
ShareName: d.name,
CreatorId: th.BasicUser.Id,
RemoteId: d.remoteID,
}
_, err := th.App.ShareChannel(th.Context, sc)
require.NoError(t, err)
}
t.Run("Test checkChannelNotShared: not yet shared channel", func(t *testing.T) {
err := th.App.checkChannelNotShared(th.Context, channel3.Id)
assert.NoError(t, err, "unshared channel should not error")
})
t.Run("Test checkChannelNotShared: already shared channel", func(t *testing.T) {
err := th.App.checkChannelNotShared(th.Context, channel1.Id)
assert.Error(t, err, "already shared channel should error")
})
t.Run("Test checkChannelNotShared: invalid channel", func(t *testing.T) {
err := th.App.checkChannelNotShared(th.Context, model.NewId())
assert.Error(t, err, "invalid channel should error")
})
t.Run("Test checkChannelIsShared: not yet shared channel", func(t *testing.T) {
err := th.App.checkChannelIsShared(channel3.Id)
assert.Error(t, err, "unshared channel should error")
})
t.Run("Test checkChannelIsShared: already shared channel", func(t *testing.T) {
err := th.App.checkChannelIsShared(channel1.Id)
assert.NoError(t, err, "already channel should not error")
})
t.Run("Test checkChannelIsShared: invalid channel", func(t *testing.T) {
err := th.App.checkChannelIsShared(model.NewId())
assert.Error(t, err, "invalid channel should error")
})
t.Run("Test CheckCanInviteToSharedChannel: Home shared channel", func(t *testing.T) {
err := th.App.CheckCanInviteToSharedChannel(data[0].channelID)
assert.NoError(t, err, "home channel should allow invites")
})
t.Run("Test CheckCanInviteToSharedChannel: Remote shared channel", func(t *testing.T) {
err := th.App.CheckCanInviteToSharedChannel(data[1].channelID)
assert.Error(t, err, "home channel should not allow invites")
})
t.Run("Test CheckCanInviteToSharedChannel: Invalid shared channel", func(t *testing.T) {
err := th.App.CheckCanInviteToSharedChannel(model.NewId())
assert.Error(t, err, "invalid channel should not allow invites")
})
}