коммит произвёл
GitHub
родитель
f290745496
Коммит
c3ed07e679
@@ -492,7 +492,7 @@ func TestSessionHasPermissionToGroup(t *testing.T) {
|
||||
require.Nil(t, err)
|
||||
|
||||
group, err := th.App.CreateGroup(&model.Group{
|
||||
Name: model.NewString(model.NewId()),
|
||||
Name: model.NewPointer(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Source: model.GroupSourceCustom,
|
||||
AllowReference: true,
|
||||
@@ -699,7 +699,7 @@ func TestSessionHasPermissionToChannelByPost(t *testing.T) {
|
||||
|
||||
t.Run("read archived channel - setting off", func(t *testing.T) {
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
cfg.TeamSettings.ExperimentalViewArchivedChannels = model.NewBool(false)
|
||||
cfg.TeamSettings.ExperimentalViewArchivedChannels = model.NewPointer(false)
|
||||
})
|
||||
require.Equal(t, false, th.App.SessionHasPermissionToChannelByPost(*session, archivedPost.Id, model.PermissionReadChannel))
|
||||
require.Equal(t, false, th.App.SessionHasPermissionToChannelByPost(*session2, archivedPost.Id, model.PermissionReadChannel))
|
||||
@@ -707,7 +707,7 @@ func TestSessionHasPermissionToChannelByPost(t *testing.T) {
|
||||
|
||||
t.Run("read archived channel - setting on", func(t *testing.T) {
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
cfg.TeamSettings.ExperimentalViewArchivedChannels = model.NewBool(true)
|
||||
cfg.TeamSettings.ExperimentalViewArchivedChannels = model.NewPointer(true)
|
||||
})
|
||||
require.Equal(t, true, th.App.SessionHasPermissionToChannelByPost(*session, archivedPost.Id, model.PermissionReadChannel))
|
||||
require.Equal(t, false, th.App.SessionHasPermissionToChannelByPost(*session2, archivedPost.Id, model.PermissionReadChannel))
|
||||
@@ -748,7 +748,7 @@ func TestHasPermissionToChannelByPost(t *testing.T) {
|
||||
|
||||
t.Run("read archived channel - setting off", func(t *testing.T) {
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
cfg.TeamSettings.ExperimentalViewArchivedChannels = model.NewBool(false)
|
||||
cfg.TeamSettings.ExperimentalViewArchivedChannels = model.NewPointer(false)
|
||||
})
|
||||
require.Equal(t, false, th.App.HasPermissionToChannelByPost(th.Context, th.BasicUser.Id, archivedPost.Id, model.PermissionReadChannel))
|
||||
require.Equal(t, false, th.App.HasPermissionToChannelByPost(th.Context, th.BasicUser2.Id, archivedPost.Id, model.PermissionReadChannel))
|
||||
@@ -756,7 +756,7 @@ func TestHasPermissionToChannelByPost(t *testing.T) {
|
||||
|
||||
t.Run("read archived channel - setting on", func(t *testing.T) {
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
cfg.TeamSettings.ExperimentalViewArchivedChannels = model.NewBool(true)
|
||||
cfg.TeamSettings.ExperimentalViewArchivedChannels = model.NewPointer(true)
|
||||
})
|
||||
require.Equal(t, true, th.App.HasPermissionToChannelByPost(th.Context, th.BasicUser.Id, archivedPost.Id, model.PermissionReadChannel))
|
||||
require.Equal(t, false, th.App.HasPermissionToChannelByPost(th.Context, th.BasicUser2.Id, archivedPost.Id, model.PermissionReadChannel))
|
||||
|
||||
@@ -785,7 +785,7 @@ func TestAppUpdateChannelScheme(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
|
||||
channel := th.BasicChannel
|
||||
mockID := model.NewString("x")
|
||||
mockID := model.NewPointer("x")
|
||||
channel.SchemeId = mockID
|
||||
|
||||
updatedChannel, err := th.App.UpdateChannelScheme(th.Context, channel)
|
||||
@@ -1632,7 +1632,7 @@ func TestAddUserToChannel(t *testing.T) {
|
||||
require.True(t, cm2.SchemeAdmin)
|
||||
|
||||
privateChannel := th.CreatePrivateChannel(th.Context, th.BasicTeam)
|
||||
privateChannel.GroupConstrained = model.NewBool(true)
|
||||
privateChannel.GroupConstrained = model.NewPointer(true)
|
||||
_, err = th.App.UpdateChannel(th.Context, privateChannel)
|
||||
require.Nil(t, err)
|
||||
|
||||
@@ -1685,7 +1685,7 @@ func TestRemoveUserFromChannel(t *testing.T) {
|
||||
})
|
||||
require.Nil(t, err)
|
||||
|
||||
privateChannel.GroupConstrained = model.NewBool(true)
|
||||
privateChannel.GroupConstrained = model.NewPointer(true)
|
||||
_, err = th.App.UpdateChannel(th.Context, privateChannel)
|
||||
require.Nil(t, err)
|
||||
|
||||
@@ -1735,7 +1735,7 @@ func TestPatchChannelModerationsForChannel(t *testing.T) {
|
||||
ChannelModerationsPatch: []*model.ChannelModerationPatch{
|
||||
{
|
||||
Name: &createPosts,
|
||||
Roles: &model.ChannelModeratedRolesPatch{Members: model.NewBool(false)},
|
||||
Roles: &model.ChannelModeratedRolesPatch{Members: model.NewPointer(false)},
|
||||
},
|
||||
},
|
||||
PermissionsModeratedByPatch: map[string]*model.ChannelModeratedRoles{
|
||||
@@ -1746,7 +1746,7 @@ func TestPatchChannelModerationsForChannel(t *testing.T) {
|
||||
RevertChannelModerationsPatch: []*model.ChannelModerationPatch{
|
||||
{
|
||||
Name: &createPosts,
|
||||
Roles: &model.ChannelModeratedRolesPatch{Members: model.NewBool(true)},
|
||||
Roles: &model.ChannelModeratedRolesPatch{Members: model.NewPointer(true)},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1755,7 +1755,7 @@ func TestPatchChannelModerationsForChannel(t *testing.T) {
|
||||
ChannelModerationsPatch: []*model.ChannelModerationPatch{
|
||||
{
|
||||
Name: &createReactions,
|
||||
Roles: &model.ChannelModeratedRolesPatch{Members: model.NewBool(false)},
|
||||
Roles: &model.ChannelModeratedRolesPatch{Members: model.NewPointer(false)},
|
||||
},
|
||||
},
|
||||
PermissionsModeratedByPatch: map[string]*model.ChannelModeratedRoles{
|
||||
@@ -1766,7 +1766,7 @@ func TestPatchChannelModerationsForChannel(t *testing.T) {
|
||||
RevertChannelModerationsPatch: []*model.ChannelModerationPatch{
|
||||
{
|
||||
Name: &createReactions,
|
||||
Roles: &model.ChannelModeratedRolesPatch{Members: model.NewBool(true)},
|
||||
Roles: &model.ChannelModeratedRolesPatch{Members: model.NewPointer(true)},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1775,7 +1775,7 @@ func TestPatchChannelModerationsForChannel(t *testing.T) {
|
||||
ChannelModerationsPatch: []*model.ChannelModerationPatch{
|
||||
{
|
||||
Name: &channelMentions,
|
||||
Roles: &model.ChannelModeratedRolesPatch{Members: model.NewBool(false)},
|
||||
Roles: &model.ChannelModeratedRolesPatch{Members: model.NewPointer(false)},
|
||||
},
|
||||
},
|
||||
PermissionsModeratedByPatch: map[string]*model.ChannelModeratedRoles{
|
||||
@@ -1786,7 +1786,7 @@ func TestPatchChannelModerationsForChannel(t *testing.T) {
|
||||
RevertChannelModerationsPatch: []*model.ChannelModerationPatch{
|
||||
{
|
||||
Name: &channelMentions,
|
||||
Roles: &model.ChannelModeratedRolesPatch{Members: model.NewBool(true)},
|
||||
Roles: &model.ChannelModeratedRolesPatch{Members: model.NewPointer(true)},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1795,7 +1795,7 @@ func TestPatchChannelModerationsForChannel(t *testing.T) {
|
||||
ChannelModerationsPatch: []*model.ChannelModerationPatch{
|
||||
{
|
||||
Name: &manageMembers,
|
||||
Roles: &model.ChannelModeratedRolesPatch{Members: model.NewBool(false)},
|
||||
Roles: &model.ChannelModeratedRolesPatch{Members: model.NewPointer(false)},
|
||||
},
|
||||
},
|
||||
PermissionsModeratedByPatch: map[string]*model.ChannelModeratedRoles{
|
||||
@@ -1806,7 +1806,7 @@ func TestPatchChannelModerationsForChannel(t *testing.T) {
|
||||
RevertChannelModerationsPatch: []*model.ChannelModerationPatch{
|
||||
{
|
||||
Name: &manageMembers,
|
||||
Roles: &model.ChannelModeratedRolesPatch{Members: model.NewBool(true)},
|
||||
Roles: &model.ChannelModeratedRolesPatch{Members: model.NewPointer(true)},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1815,7 +1815,7 @@ func TestPatchChannelModerationsForChannel(t *testing.T) {
|
||||
ChannelModerationsPatch: []*model.ChannelModerationPatch{
|
||||
{
|
||||
Name: &manageBookmarks,
|
||||
Roles: &model.ChannelModeratedRolesPatch{Members: model.NewBool(false)},
|
||||
Roles: &model.ChannelModeratedRolesPatch{Members: model.NewPointer(false)},
|
||||
},
|
||||
},
|
||||
PermissionsModeratedByPatch: map[string]*model.ChannelModeratedRoles{
|
||||
@@ -1826,7 +1826,7 @@ func TestPatchChannelModerationsForChannel(t *testing.T) {
|
||||
RevertChannelModerationsPatch: []*model.ChannelModerationPatch{
|
||||
{
|
||||
Name: &manageBookmarks,
|
||||
Roles: &model.ChannelModeratedRolesPatch{Members: model.NewBool(true)},
|
||||
Roles: &model.ChannelModeratedRolesPatch{Members: model.NewPointer(true)},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1835,7 +1835,7 @@ func TestPatchChannelModerationsForChannel(t *testing.T) {
|
||||
ChannelModerationsPatch: []*model.ChannelModerationPatch{
|
||||
{
|
||||
Name: &createPosts,
|
||||
Roles: &model.ChannelModeratedRolesPatch{Guests: model.NewBool(false)},
|
||||
Roles: &model.ChannelModeratedRolesPatch{Guests: model.NewPointer(false)},
|
||||
},
|
||||
},
|
||||
PermissionsModeratedByPatch: map[string]*model.ChannelModeratedRoles{
|
||||
@@ -1846,7 +1846,7 @@ func TestPatchChannelModerationsForChannel(t *testing.T) {
|
||||
RevertChannelModerationsPatch: []*model.ChannelModerationPatch{
|
||||
{
|
||||
Name: &createPosts,
|
||||
Roles: &model.ChannelModeratedRolesPatch{Guests: model.NewBool(true)},
|
||||
Roles: &model.ChannelModeratedRolesPatch{Guests: model.NewPointer(true)},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1855,7 +1855,7 @@ func TestPatchChannelModerationsForChannel(t *testing.T) {
|
||||
ChannelModerationsPatch: []*model.ChannelModerationPatch{
|
||||
{
|
||||
Name: &createReactions,
|
||||
Roles: &model.ChannelModeratedRolesPatch{Guests: model.NewBool(false)},
|
||||
Roles: &model.ChannelModeratedRolesPatch{Guests: model.NewPointer(false)},
|
||||
},
|
||||
},
|
||||
PermissionsModeratedByPatch: map[string]*model.ChannelModeratedRoles{
|
||||
@@ -1866,7 +1866,7 @@ func TestPatchChannelModerationsForChannel(t *testing.T) {
|
||||
RevertChannelModerationsPatch: []*model.ChannelModerationPatch{
|
||||
{
|
||||
Name: &createReactions,
|
||||
Roles: &model.ChannelModeratedRolesPatch{Guests: model.NewBool(true)},
|
||||
Roles: &model.ChannelModeratedRolesPatch{Guests: model.NewPointer(true)},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1875,7 +1875,7 @@ func TestPatchChannelModerationsForChannel(t *testing.T) {
|
||||
ChannelModerationsPatch: []*model.ChannelModerationPatch{
|
||||
{
|
||||
Name: &channelMentions,
|
||||
Roles: &model.ChannelModeratedRolesPatch{Guests: model.NewBool(false)},
|
||||
Roles: &model.ChannelModeratedRolesPatch{Guests: model.NewPointer(false)},
|
||||
},
|
||||
},
|
||||
PermissionsModeratedByPatch: map[string]*model.ChannelModeratedRoles{
|
||||
@@ -1886,7 +1886,7 @@ func TestPatchChannelModerationsForChannel(t *testing.T) {
|
||||
RevertChannelModerationsPatch: []*model.ChannelModerationPatch{
|
||||
{
|
||||
Name: &channelMentions,
|
||||
Roles: &model.ChannelModeratedRolesPatch{Guests: model.NewBool(true)},
|
||||
Roles: &model.ChannelModeratedRolesPatch{Guests: model.NewPointer(true)},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1895,7 +1895,7 @@ func TestPatchChannelModerationsForChannel(t *testing.T) {
|
||||
ChannelModerationsPatch: []*model.ChannelModerationPatch{
|
||||
{
|
||||
Name: &manageMembers,
|
||||
Roles: &model.ChannelModeratedRolesPatch{Guests: model.NewBool(false)},
|
||||
Roles: &model.ChannelModeratedRolesPatch{Guests: model.NewPointer(false)},
|
||||
},
|
||||
},
|
||||
PermissionsModeratedByPatch: map[string]*model.ChannelModeratedRoles{},
|
||||
@@ -1907,7 +1907,7 @@ func TestPatchChannelModerationsForChannel(t *testing.T) {
|
||||
ChannelModerationsPatch: []*model.ChannelModerationPatch{
|
||||
{
|
||||
Name: &manageBookmarks,
|
||||
Roles: &model.ChannelModeratedRolesPatch{Guests: model.NewBool(false)},
|
||||
Roles: &model.ChannelModeratedRolesPatch{Guests: model.NewPointer(false)},
|
||||
},
|
||||
},
|
||||
PermissionsModeratedByPatch: map[string]*model.ChannelModeratedRoles{},
|
||||
@@ -1920,8 +1920,8 @@ func TestPatchChannelModerationsForChannel(t *testing.T) {
|
||||
{
|
||||
Name: &nonChannelModeratedPermission,
|
||||
Roles: &model.ChannelModeratedRolesPatch{
|
||||
Members: model.NewBool(false),
|
||||
Guests: model.NewBool(false),
|
||||
Members: model.NewPointer(false),
|
||||
Guests: model.NewPointer(false),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1935,8 +1935,8 @@ func TestPatchChannelModerationsForChannel(t *testing.T) {
|
||||
{
|
||||
Name: &createPosts,
|
||||
Roles: &model.ChannelModeratedRolesPatch{
|
||||
Members: model.NewBool(true),
|
||||
Guests: model.NewBool(false),
|
||||
Members: model.NewPointer(true),
|
||||
Guests: model.NewPointer(false),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1950,8 +1950,8 @@ func TestPatchChannelModerationsForChannel(t *testing.T) {
|
||||
{
|
||||
Name: &createPosts,
|
||||
Roles: &model.ChannelModeratedRolesPatch{
|
||||
Members: model.NewBool(false),
|
||||
Guests: model.NewBool(true),
|
||||
Members: model.NewPointer(false),
|
||||
Guests: model.NewPointer(true),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1965,7 +1965,7 @@ func TestPatchChannelModerationsForChannel(t *testing.T) {
|
||||
{
|
||||
Name: &createPosts,
|
||||
Roles: &model.ChannelModeratedRolesPatch{
|
||||
Members: model.NewBool(false),
|
||||
Members: model.NewPointer(false),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1990,34 +1990,34 @@ func TestPatchChannelModerationsForChannel(t *testing.T) {
|
||||
{
|
||||
Name: &createPosts,
|
||||
Roles: &model.ChannelModeratedRolesPatch{
|
||||
Members: model.NewBool(true),
|
||||
Guests: model.NewBool(true),
|
||||
Members: model.NewPointer(true),
|
||||
Guests: model.NewPointer(true),
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: &createReactions,
|
||||
Roles: &model.ChannelModeratedRolesPatch{
|
||||
Members: model.NewBool(true),
|
||||
Guests: model.NewBool(true),
|
||||
Members: model.NewPointer(true),
|
||||
Guests: model.NewPointer(true),
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: &channelMentions,
|
||||
Roles: &model.ChannelModeratedRolesPatch{
|
||||
Members: model.NewBool(true),
|
||||
Guests: model.NewBool(true),
|
||||
Members: model.NewPointer(true),
|
||||
Guests: model.NewPointer(true),
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: &manageMembers,
|
||||
Roles: &model.ChannelModeratedRolesPatch{
|
||||
Members: model.NewBool(true),
|
||||
Members: model.NewPointer(true),
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: &manageBookmarks,
|
||||
Roles: &model.ChannelModeratedRolesPatch{
|
||||
Members: model.NewBool(true),
|
||||
Members: model.NewPointer(true),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -2097,8 +2097,8 @@ func TestPatchChannelModerationsForChannel(t *testing.T) {
|
||||
{
|
||||
Name: &createPosts,
|
||||
Roles: &model.ChannelModeratedRolesPatch{
|
||||
Members: model.NewBool(false),
|
||||
Guests: model.NewBool(false),
|
||||
Members: model.NewPointer(false),
|
||||
Guests: model.NewPointer(false),
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -2106,8 +2106,8 @@ func TestPatchChannelModerationsForChannel(t *testing.T) {
|
||||
{
|
||||
Name: &createPosts,
|
||||
Roles: &model.ChannelModeratedRolesPatch{
|
||||
Members: model.NewBool(false),
|
||||
Guests: model.NewBool(false),
|
||||
Members: model.NewPointer(false),
|
||||
Guests: model.NewPointer(false),
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -2142,7 +2142,7 @@ func TestPatchChannelModerationsForChannel(t *testing.T) {
|
||||
{
|
||||
Name: &createPosts,
|
||||
Roles: &model.ChannelModeratedRolesPatch{
|
||||
Members: model.NewBool(true),
|
||||
Members: model.NewPointer(true),
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -2150,7 +2150,7 @@ func TestPatchChannelModerationsForChannel(t *testing.T) {
|
||||
{
|
||||
Name: &createPosts,
|
||||
Roles: &model.ChannelModeratedRolesPatch{
|
||||
Members: model.NewBool(false),
|
||||
Members: model.NewPointer(false),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -237,11 +237,11 @@ func (a *App) HandleMessageExportConfig(cfg *model.Config, appCfg *model.Config)
|
||||
if *cfg.MessageExportSettings.EnableExport != *appCfg.MessageExportSettings.EnableExport {
|
||||
if *cfg.MessageExportSettings.EnableExport && *cfg.MessageExportSettings.ExportFromTimestamp == int64(0) {
|
||||
// When the feature is toggled on, use the current timestamp as the start time for future exports.
|
||||
cfg.MessageExportSettings.ExportFromTimestamp = model.NewInt64(model.GetMillis())
|
||||
cfg.MessageExportSettings.ExportFromTimestamp = model.NewPointer(model.GetMillis())
|
||||
} else if !*cfg.MessageExportSettings.EnableExport {
|
||||
// When the feature is disabled, reset the timestamp so that the timestamp will be set if
|
||||
// the feature is re-enabled from the System Console in future.
|
||||
cfg.MessageExportSettings.ExportFromTimestamp = model.NewInt64(0)
|
||||
cfg.MessageExportSettings.ExportFromTimestamp = model.NewPointer(int64(0))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,25 +70,25 @@ func TestEnsureInstallationDate(t *testing.T) {
|
||||
Name: "New installation: no users, no installation date",
|
||||
PrevInstallationDate: nil,
|
||||
UsersCreationDates: nil,
|
||||
ExpectedInstallationDate: model.NewInt64(utils.MillisFromTime(time.Now())),
|
||||
ExpectedInstallationDate: model.NewPointer(utils.MillisFromTime(time.Now())),
|
||||
},
|
||||
{
|
||||
Name: "Old installation: users, no installation date",
|
||||
PrevInstallationDate: nil,
|
||||
UsersCreationDates: []int64{10000000000, 30000000000, 20000000000},
|
||||
ExpectedInstallationDate: model.NewInt64(10000000000),
|
||||
ExpectedInstallationDate: model.NewPointer(int64(10000000000)),
|
||||
},
|
||||
{
|
||||
Name: "New installation, second run: no users, installation date",
|
||||
PrevInstallationDate: model.NewInt64(80000000000),
|
||||
PrevInstallationDate: model.NewPointer(int64(80000000000)),
|
||||
UsersCreationDates: []int64{10000000000, 30000000000, 20000000000},
|
||||
ExpectedInstallationDate: model.NewInt64(80000000000),
|
||||
ExpectedInstallationDate: model.NewPointer(int64(80000000000)),
|
||||
},
|
||||
{
|
||||
Name: "Old installation already updated: users, installation date",
|
||||
PrevInstallationDate: model.NewInt64(90000000000),
|
||||
PrevInstallationDate: model.NewPointer(int64(90000000000)),
|
||||
UsersCreationDates: []int64{10000000000, 30000000000, 20000000000},
|
||||
ExpectedInstallationDate: model.NewInt64(90000000000),
|
||||
ExpectedInstallationDate: model.NewPointer(int64(90000000000)),
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ func TestDownloadFromURL(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
|
||||
app := th.App
|
||||
app.Config().PluginSettings.AllowInsecureDownloadURL = model.NewBool(true)
|
||||
app.Config().PluginSettings.AllowInsecureDownloadURL = model.NewPointer(true)
|
||||
|
||||
// To keep track of how many times an endpoint is retried. This needs to be reset
|
||||
// for each test run.
|
||||
|
||||
@@ -293,7 +293,7 @@ func TestMailServiceConfig(t *testing.T) {
|
||||
config: func() *model.Config {
|
||||
return &model.Config{
|
||||
ServiceSettings: model.ServiceSettings{
|
||||
SiteURL: model.NewString(""),
|
||||
SiteURL: model.NewPointer(""),
|
||||
},
|
||||
EmailSettings: model.EmailSettings{
|
||||
EnableSignUpWithEmail: new(bool),
|
||||
@@ -304,7 +304,7 @@ func TestMailServiceConfig(t *testing.T) {
|
||||
RequireEmailVerification: new(bool),
|
||||
FeedbackName: new(string),
|
||||
FeedbackEmail: new(string),
|
||||
ReplyToAddress: model.NewString(configuredReplyTo),
|
||||
ReplyToAddress: model.NewPointer(configuredReplyTo),
|
||||
FeedbackOrganization: new(string),
|
||||
EnableSMTPAuth: new(bool),
|
||||
SMTPUsername: new(string),
|
||||
|
||||
@@ -654,7 +654,7 @@ func TestComputeLastAccessibleFileTime(t *testing.T) {
|
||||
|
||||
cloud.Mock.On("GetCloudLimits", mock.Anything).Return(&model.ProductLimits{
|
||||
Files: &model.FilesLimits{
|
||||
TotalStorage: model.NewInt64(1),
|
||||
TotalStorage: model.NewPointer(int64(1)),
|
||||
},
|
||||
}, nil)
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ func (a *App) GetGroup(id string, opts *model.GetGroupOpts, viewRestrictions *mo
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetGroup", "app.member_count", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
group.MemberCount = model.NewInt(int(memberCount))
|
||||
group.MemberCount = model.NewPointer(int(memberCount))
|
||||
}
|
||||
|
||||
return group, nil
|
||||
@@ -160,7 +160,7 @@ func (a *App) CreateGroupWithUserIds(group *model.GroupWithUserIds) (*model.Grou
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("CreateGroupWithUserIds", "app.group.id.app_error", nil, "", http.StatusBadRequest).Wrap(err)
|
||||
}
|
||||
group.MemberCount = model.NewInt(int(count))
|
||||
group.MemberCount = model.NewPointer(int(count))
|
||||
groupJSON, jsonErr := json.Marshal(newGroup)
|
||||
if jsonErr != nil {
|
||||
return nil, model.NewAppError("CreateGroupWithUserIds", "api.marshal_error", nil, "", http.StatusInternalServerError).Wrap(jsonErr)
|
||||
@@ -199,7 +199,7 @@ func (a *App) UpdateGroup(group *model.Group) (*model.Group, *model.AppError) {
|
||||
return nil, model.NewAppError("UpdateGroup", "app.group.id.app_error", nil, "", http.StatusBadRequest).Wrap(err)
|
||||
}
|
||||
|
||||
updatedGroup.MemberCount = model.NewInt(int(count))
|
||||
updatedGroup.MemberCount = model.NewPointer(int(count))
|
||||
messageWs := model.NewWebSocketEvent(model.WebsocketEventReceivedGroup, "", "", "", nil, "")
|
||||
|
||||
groupJSON, err := json.Marshal(updatedGroup)
|
||||
@@ -229,7 +229,7 @@ func (a *App) DeleteGroup(groupID string) (*model.Group, *model.AppError) {
|
||||
return nil, model.NewAppError("DeleteGroup", "app.group.id.app_error", nil, "", http.StatusBadRequest).Wrap(err)
|
||||
}
|
||||
|
||||
deletedGroup.MemberCount = model.NewInt(int(count))
|
||||
deletedGroup.MemberCount = model.NewPointer(int(count))
|
||||
|
||||
messageWs := model.NewWebSocketEvent(model.WebsocketEventReceivedGroup, "", "", "", nil, "")
|
||||
|
||||
@@ -260,7 +260,7 @@ func (a *App) RestoreGroup(groupID string) (*model.Group, *model.AppError) {
|
||||
return nil, model.NewAppError("RestoreGroup", "app.group.id.app_error", nil, "", http.StatusBadRequest).Wrap(err)
|
||||
}
|
||||
|
||||
restoredGroup.MemberCount = model.NewInt(int(count))
|
||||
restoredGroup.MemberCount = model.NewPointer(int(count))
|
||||
|
||||
messageWs := model.NewWebSocketEvent(model.WebsocketEventReceivedGroup, "", "", "", nil, "")
|
||||
|
||||
|
||||
@@ -71,9 +71,9 @@ func TestCreateGroup(t *testing.T) {
|
||||
id := model.NewId()
|
||||
group := &model.Group{
|
||||
DisplayName: "dn_" + id,
|
||||
Name: model.NewString("name" + id),
|
||||
Name: model.NewPointer("name" + id),
|
||||
Source: model.GroupSourceLdap,
|
||||
RemoteId: model.NewString(model.NewId()),
|
||||
RemoteId: model.NewPointer(model.NewId()),
|
||||
}
|
||||
|
||||
g, err := th.App.CreateGroup(group)
|
||||
@@ -90,7 +90,7 @@ func TestCreateGroup(t *testing.T) {
|
||||
DisplayName: "dn_" + model.NewId(),
|
||||
Name: &user.Username,
|
||||
Source: model.GroupSourceLdap,
|
||||
RemoteId: model.NewString(model.NewId()),
|
||||
RemoteId: model.NewPointer(model.NewId()),
|
||||
}
|
||||
g, err = th.App.CreateGroup(usernameGroup)
|
||||
require.NotNil(t, err)
|
||||
@@ -213,7 +213,7 @@ func TestUpsertGroupSyncableTeamGroupConstrained(t *testing.T) {
|
||||
group2 := th.CreateGroup()
|
||||
|
||||
team := th.CreateTeam()
|
||||
team.GroupConstrained = model.NewBool(true)
|
||||
team.GroupConstrained = model.NewPointer(true)
|
||||
team, err := th.App.UpdateTeam(team)
|
||||
require.Nil(t, err)
|
||||
_, err = th.App.UpsertGroupSyncable(model.NewGroupTeam(group1.Id, team.Id, false))
|
||||
@@ -311,7 +311,7 @@ func TestGetGroupsByChannel(t *testing.T) {
|
||||
|
||||
groups, _, err := th.App.GetGroupsByChannel(th.BasicChannel.Id, opts)
|
||||
require.Nil(t, err)
|
||||
require.ElementsMatch(t, []*model.GroupWithSchemeAdmin{{Group: *group, SchemeAdmin: model.NewBool(false)}}, groups)
|
||||
require.ElementsMatch(t, []*model.GroupWithSchemeAdmin{{Group: *group, SchemeAdmin: model.NewPointer(false)}}, groups)
|
||||
require.NotNil(t, groups[0].SchemeAdmin)
|
||||
|
||||
groups, _, err = th.App.GetGroupsByChannel(model.NewId(), opts)
|
||||
@@ -348,7 +348,7 @@ func TestGetGroupsAssociatedToChannelsByTeam(t *testing.T) {
|
||||
|
||||
assert.Equal(t, map[string][]*model.GroupWithSchemeAdmin{
|
||||
th.BasicChannel.Id: {
|
||||
{Group: *group, SchemeAdmin: model.NewBool(false)},
|
||||
{Group: *group, SchemeAdmin: model.NewPointer(false)},
|
||||
},
|
||||
}, groups)
|
||||
require.NotNil(t, groups[th.BasicChannel.Id][0].SchemeAdmin)
|
||||
@@ -377,7 +377,7 @@ func TestGetGroupsByTeam(t *testing.T) {
|
||||
|
||||
groups, _, err := th.App.GetGroupsByTeam(th.BasicTeam.Id, model.GroupSearchOpts{})
|
||||
require.Nil(t, err)
|
||||
require.ElementsMatch(t, []*model.GroupWithSchemeAdmin{{Group: *group, SchemeAdmin: model.NewBool(false)}}, groups)
|
||||
require.ElementsMatch(t, []*model.GroupWithSchemeAdmin{{Group: *group, SchemeAdmin: model.NewPointer(false)}}, groups)
|
||||
require.NotNil(t, groups[0].SchemeAdmin)
|
||||
|
||||
groups, _, err = th.App.GetGroupsByTeam(model.NewId(), model.GroupSearchOpts{})
|
||||
|
||||
@@ -370,13 +370,13 @@ type ChannelOption func(*model.Channel)
|
||||
|
||||
func WithShared(v bool) ChannelOption {
|
||||
return func(channel *model.Channel) {
|
||||
channel.Shared = model.NewBool(v)
|
||||
channel.Shared = model.NewPointer(v)
|
||||
}
|
||||
}
|
||||
|
||||
func WithCreateAt(v int64) ChannelOption {
|
||||
return func(channel *model.Channel) {
|
||||
channel.CreateAt = *model.NewInt64(v)
|
||||
channel.CreateAt = *model.NewPointer(v)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -539,10 +539,10 @@ func (th *TestHelper) CreateGroup() *model.Group {
|
||||
id := model.NewId()
|
||||
group := &model.Group{
|
||||
DisplayName: "dn_" + id,
|
||||
Name: model.NewString("name" + id),
|
||||
Name: model.NewPointer("name" + id),
|
||||
Source: model.GroupSourceLdap,
|
||||
Description: "description_" + id,
|
||||
RemoteId: model.NewString(model.NewId()),
|
||||
RemoteId: model.NewPointer(model.NewId()),
|
||||
}
|
||||
|
||||
var err *model.AppError
|
||||
|
||||
@@ -85,8 +85,8 @@ func (a *App) importScheme(rctx request.CTX, data *imports.SchemeImportData, dry
|
||||
|
||||
if data.DefaultTeamGuestRole == nil {
|
||||
data.DefaultTeamGuestRole = &imports.RoleImportData{
|
||||
DisplayName: model.NewString("Team Guest Role for Scheme"),
|
||||
SchemeManaged: model.NewBool(true),
|
||||
DisplayName: model.NewPointer("Team Guest Role for Scheme"),
|
||||
SchemeManaged: model.NewPointer(true),
|
||||
}
|
||||
}
|
||||
data.DefaultTeamGuestRole.Name = &scheme.DefaultTeamGuestRole
|
||||
@@ -108,8 +108,8 @@ func (a *App) importScheme(rctx request.CTX, data *imports.SchemeImportData, dry
|
||||
|
||||
if data.DefaultChannelGuestRole == nil {
|
||||
data.DefaultChannelGuestRole = &imports.RoleImportData{
|
||||
DisplayName: model.NewString("Channel Guest Role for Scheme"),
|
||||
SchemeManaged: model.NewBool(true),
|
||||
DisplayName: model.NewPointer("Channel Guest Role for Scheme"),
|
||||
SchemeManaged: model.NewPointer(true),
|
||||
}
|
||||
}
|
||||
data.DefaultChannelGuestRole.Name = &scheme.DefaultChannelGuestRole
|
||||
@@ -889,7 +889,7 @@ func (a *App) importUserTeams(rctx request.CTX, user *model.User, data *[]import
|
||||
channels[team.Id] = append(channels[team.Id], *tdata.Channels...)
|
||||
}
|
||||
if !user.IsGuest() {
|
||||
channels[team.Id] = append(channels[team.Id], imports.UserChannelImportData{Name: model.NewString(model.DefaultChannelName)})
|
||||
channels[team.Id] = append(channels[team.Id], imports.UserChannelImportData{Name: model.NewPointer(model.DefaultChannelName)})
|
||||
}
|
||||
|
||||
teamsByID[team.Id] = team
|
||||
|
||||
@@ -461,7 +461,7 @@ func TestImportImportRole(t *testing.T) {
|
||||
data.DisplayName = ptrStr("new display name")
|
||||
data.Description = ptrStr("description")
|
||||
data.Permissions = &[]string{"manage_slash_commands"}
|
||||
data.SchemeManaged = model.NewBool(true)
|
||||
data.SchemeManaged = model.NewPointer(true)
|
||||
|
||||
err = th.App.importRole(th.Context, &data, false)
|
||||
require.Nil(t, err, "Should have succeeded. %v", err)
|
||||
@@ -1580,7 +1580,7 @@ func TestImportUserTeams(t *testing.T) {
|
||||
name: "Not existing team should fail",
|
||||
data: &[]imports.UserTeamImportData{
|
||||
{
|
||||
Name: model.NewString("not-existing-team-name"),
|
||||
Name: model.NewPointer("not-existing-team-name"),
|
||||
},
|
||||
},
|
||||
expectedError: true,
|
||||
@@ -1596,7 +1596,7 @@ func TestImportUserTeams(t *testing.T) {
|
||||
data: &[]imports.UserTeamImportData{
|
||||
{
|
||||
Name: &th.BasicTeam.Name,
|
||||
Roles: model.NewString("not-existing-role"),
|
||||
Roles: model.NewPointer("not-existing-role"),
|
||||
},
|
||||
},
|
||||
expectedError: true,
|
||||
@@ -1624,7 +1624,7 @@ func TestImportUserTeams(t *testing.T) {
|
||||
data: &[]imports.UserTeamImportData{
|
||||
{
|
||||
Name: &th.BasicTeam.Name,
|
||||
Roles: model.NewString(model.TeamAdminRoleId),
|
||||
Roles: model.NewPointer(model.TeamAdminRoleId),
|
||||
},
|
||||
},
|
||||
expectedError: false,
|
||||
@@ -1718,7 +1718,7 @@ func TestImportUserTeams(t *testing.T) {
|
||||
Name: &channel3.Name,
|
||||
},
|
||||
{
|
||||
Name: model.NewString("town-square"),
|
||||
Name: model.NewPointer("town-square"),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1785,9 +1785,9 @@ func TestImportUserChannels(t *testing.T) {
|
||||
channel2 := th.CreateChannel(th.Context, th.BasicTeam)
|
||||
customRole := th.CreateRole("test_custom_role")
|
||||
sampleNotifyProps := imports.UserChannelNotifyPropsImportData{
|
||||
Desktop: model.NewString("all"),
|
||||
Mobile: model.NewString("none"),
|
||||
MarkUnread: model.NewString("all"),
|
||||
Desktop: model.NewPointer("all"),
|
||||
Mobile: model.NewPointer("none"),
|
||||
MarkUnread: model.NewPointer("all"),
|
||||
}
|
||||
|
||||
tt := []struct {
|
||||
@@ -1803,7 +1803,7 @@ func TestImportUserChannels(t *testing.T) {
|
||||
name: "Not existing channel should fail",
|
||||
data: &[]imports.UserChannelImportData{
|
||||
{
|
||||
Name: model.NewString("not-existing-channel-name"),
|
||||
Name: model.NewPointer("not-existing-channel-name"),
|
||||
},
|
||||
},
|
||||
expectedError: true,
|
||||
@@ -1818,7 +1818,7 @@ func TestImportUserChannels(t *testing.T) {
|
||||
data: &[]imports.UserChannelImportData{
|
||||
{
|
||||
Name: &th.BasicChannel.Name,
|
||||
Roles: model.NewString("not-existing-role"),
|
||||
Roles: model.NewPointer("not-existing-role"),
|
||||
},
|
||||
},
|
||||
expectedError: true,
|
||||
@@ -1844,7 +1844,7 @@ func TestImportUserChannels(t *testing.T) {
|
||||
data: &[]imports.UserChannelImportData{
|
||||
{
|
||||
Name: &th.BasicChannel.Name,
|
||||
Roles: model.NewString(model.ChannelAdminRoleId),
|
||||
Roles: model.NewPointer(model.ChannelAdminRoleId),
|
||||
},
|
||||
},
|
||||
expectedError: false,
|
||||
@@ -4399,7 +4399,7 @@ func TestImportPostAndRepliesWithAttachments(t *testing.T) {
|
||||
|
||||
data.Post.Attachments = &[]imports.AttachmentImportData{{Path: &filePath}}
|
||||
data.Post.Replies = nil
|
||||
data.Post.Message = model.NewString("new post")
|
||||
data.Post.Message = model.NewPointer("new post")
|
||||
errLine, appErr := th.App.importMultiplePostLines(th.Context, []imports.LineImportWorkerData{data}, false, true)
|
||||
require.Nil(t, appErr)
|
||||
require.Equal(t, 0, errLine)
|
||||
@@ -4436,7 +4436,7 @@ func TestImportPostAndRepliesWithAttachments(t *testing.T) {
|
||||
|
||||
data.Post.Attachments = &[]imports.AttachmentImportData{{Path: &filePath}}
|
||||
data.Post.Replies = nil
|
||||
data.Post.Message = model.NewString("new post2")
|
||||
data.Post.Message = model.NewPointer("new post2")
|
||||
errLine, appErr := th.App.importMultiplePostLines(th.Context, []imports.LineImportWorkerData{data}, false, true)
|
||||
require.Nil(t, appErr)
|
||||
require.Equal(t, 0, errLine)
|
||||
@@ -4757,7 +4757,7 @@ func TestZippedImportPostAndRepliesWithAttachments(t *testing.T) {
|
||||
require.NotNil(t, fileB)
|
||||
|
||||
data.Post.Attachments = &[]imports.AttachmentImportData{{Path: &fileA.Name, Data: fileA}}
|
||||
data.Post.Message = model.NewString("new post")
|
||||
data.Post.Message = model.NewPointer("new post")
|
||||
data.Post.Replies = nil
|
||||
errLine, err := th.App.importMultiplePostLines(th.Context, []imports.LineImportWorkerData{data}, false, true)
|
||||
require.Nil(t, err)
|
||||
@@ -4867,15 +4867,15 @@ func BenchmarkCompareFilesContent(b *testing.B) {
|
||||
b.Run("s3", func(b *testing.B) {
|
||||
th := SetupConfig(b, func(cfg *model.Config) {
|
||||
cfg.FileSettings = model.FileSettings{
|
||||
DriverName: model.NewString(model.ImageDriverS3),
|
||||
AmazonS3AccessKeyId: model.NewString(model.MinioAccessKey),
|
||||
AmazonS3SecretAccessKey: model.NewString(model.MinioSecretKey),
|
||||
AmazonS3Bucket: model.NewString("comparefilescontentbucket"),
|
||||
AmazonS3Endpoint: model.NewString("localhost:9000"),
|
||||
AmazonS3Region: model.NewString(""),
|
||||
AmazonS3PathPrefix: model.NewString(""),
|
||||
AmazonS3SSL: model.NewBool(false),
|
||||
AmazonS3RequestTimeoutMilliseconds: model.NewInt64(300 * 1000),
|
||||
DriverName: model.NewPointer(model.ImageDriverS3),
|
||||
AmazonS3AccessKeyId: model.NewPointer(model.MinioAccessKey),
|
||||
AmazonS3SecretAccessKey: model.NewPointer(model.MinioSecretKey),
|
||||
AmazonS3Bucket: model.NewPointer("comparefilescontentbucket"),
|
||||
AmazonS3Endpoint: model.NewPointer("localhost:9000"),
|
||||
AmazonS3Region: model.NewPointer(""),
|
||||
AmazonS3PathPrefix: model.NewPointer(""),
|
||||
AmazonS3SSL: model.NewPointer(false),
|
||||
AmazonS3RequestTimeoutMilliseconds: model.NewPointer(int64(300 * 1000)),
|
||||
}
|
||||
})
|
||||
defer th.TearDown()
|
||||
@@ -5003,15 +5003,15 @@ func BenchmarkCompareFilesContent(b *testing.B) {
|
||||
b.Run("s3", func(b *testing.B) {
|
||||
th := SetupConfig(b, func(cfg *model.Config) {
|
||||
cfg.FileSettings = model.FileSettings{
|
||||
DriverName: model.NewString(model.ImageDriverS3),
|
||||
AmazonS3AccessKeyId: model.NewString(model.MinioAccessKey),
|
||||
AmazonS3SecretAccessKey: model.NewString(model.MinioSecretKey),
|
||||
AmazonS3Bucket: model.NewString("comparefilescontentbucket"),
|
||||
AmazonS3Endpoint: model.NewString("localhost:9000"),
|
||||
AmazonS3Region: model.NewString(""),
|
||||
AmazonS3PathPrefix: model.NewString(""),
|
||||
AmazonS3SSL: model.NewBool(false),
|
||||
AmazonS3RequestTimeoutMilliseconds: model.NewInt64(300 * 1000),
|
||||
DriverName: model.NewPointer(model.ImageDriverS3),
|
||||
AmazonS3AccessKeyId: model.NewPointer(model.MinioAccessKey),
|
||||
AmazonS3SecretAccessKey: model.NewPointer(model.MinioSecretKey),
|
||||
AmazonS3Bucket: model.NewPointer("comparefilescontentbucket"),
|
||||
AmazonS3Endpoint: model.NewPointer("localhost:9000"),
|
||||
AmazonS3Region: model.NewPointer(""),
|
||||
AmazonS3PathPrefix: model.NewPointer(""),
|
||||
AmazonS3SSL: model.NewPointer(false),
|
||||
AmazonS3RequestTimeoutMilliseconds: model.NewPointer(int64(300 * 1000)),
|
||||
}
|
||||
})
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -295,10 +295,10 @@ func TestProcessAttachments(t *testing.T) {
|
||||
genAttachments := func() *[]imports.AttachmentImportData {
|
||||
return &[]imports.AttachmentImportData{
|
||||
{
|
||||
Path: model.NewString("file.jpg"),
|
||||
Path: model.NewPointer("file.jpg"),
|
||||
},
|
||||
{
|
||||
Path: model.NewString("somedir/file.jpg"),
|
||||
Path: model.NewPointer("somedir/file.jpg"),
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -320,24 +320,24 @@ func TestProcessAttachments(t *testing.T) {
|
||||
userLine := imports.LineImportData{
|
||||
Type: "user",
|
||||
User: &imports.UserImportData{
|
||||
ProfileImage: model.NewString("profile.jpg"),
|
||||
ProfileImage: model.NewPointer("profile.jpg"),
|
||||
},
|
||||
}
|
||||
|
||||
emojiLine := imports.LineImportData{
|
||||
Type: "emoji",
|
||||
Emoji: &imports.EmojiImportData{
|
||||
Image: model.NewString("emoji.png"),
|
||||
Image: model.NewPointer("emoji.png"),
|
||||
},
|
||||
}
|
||||
|
||||
t.Run("empty path", func(t *testing.T) {
|
||||
expected := &[]imports.AttachmentImportData{
|
||||
{
|
||||
Path: model.NewString("file.jpg"),
|
||||
Path: model.NewPointer("file.jpg"),
|
||||
},
|
||||
{
|
||||
Path: model.NewString("somedir/file.jpg"),
|
||||
Path: model.NewPointer("somedir/file.jpg"),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -352,10 +352,10 @@ func TestProcessAttachments(t *testing.T) {
|
||||
t.Run("valid path", func(t *testing.T) {
|
||||
expected := &[]imports.AttachmentImportData{
|
||||
{
|
||||
Path: model.NewString("/tmp/file.jpg"),
|
||||
Path: model.NewPointer("/tmp/file.jpg"),
|
||||
},
|
||||
{
|
||||
Path: model.NewString("/tmp/somedir/file.jpg"),
|
||||
Path: model.NewPointer("/tmp/somedir/file.jpg"),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -499,7 +499,7 @@ func TestImportBulkImportWithAttachments(t *testing.T) {
|
||||
}
|
||||
require.NotNil(t, jsonFile)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.TeamSettings.MaxUsersPerTeam = model.NewInt(1000) })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.TeamSettings.MaxUsersPerTeam = model.NewPointer(1000) })
|
||||
|
||||
appErr, _ := th.App.BulkImportWithPath(th.Context, jsonFile, importZipReader, false, true, 1, model.ExportDataDir)
|
||||
require.Nil(t, appErr)
|
||||
|
||||
@@ -163,7 +163,7 @@ func TestPostActionEmptyResponse(t *testing.T) {
|
||||
require.True(t, ok)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
cfg.ServiceSettings.OutgoingIntegrationRequestsTimeout = model.NewInt64(1)
|
||||
cfg.ServiceSettings.OutgoingIntegrationRequestsTimeout = model.NewPointer(int64(1))
|
||||
})
|
||||
|
||||
_, err = th.App.DoPostActionWithCookie(th.Context, post.Id, attachments[0].Actions[0].Id, th.BasicUser.Id, "", nil)
|
||||
|
||||
@@ -43,7 +43,7 @@ func TestCWSLogin(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
license := model.NewTestLicense()
|
||||
license.Features.Cloud = model.NewBool(true)
|
||||
license.Features.Cloud = model.NewPointer(true)
|
||||
th.App.Srv().SetLicense(license)
|
||||
|
||||
t.Run("Should authenticate user when CWS login is enabled and tokens are equal", func(t *testing.T) {
|
||||
|
||||
@@ -229,24 +229,24 @@ func TestCheckForMentionGroups(t *testing.T) {
|
||||
"No matching groups": {
|
||||
Word: "nothing",
|
||||
Groups: map[string]*model.Group{
|
||||
groupID1: {Id: groupID1, Name: model.NewString("engineering")},
|
||||
groupID2: {Id: groupID2, Name: model.NewString("developers")},
|
||||
groupID1: {Id: groupID1, Name: model.NewPointer("engineering")},
|
||||
groupID2: {Id: groupID2, Name: model.NewPointer("developers")},
|
||||
},
|
||||
Expected: &MentionResults{},
|
||||
},
|
||||
"matching group with no @": {
|
||||
Word: "engineering",
|
||||
Groups: map[string]*model.Group{
|
||||
groupID1: {Id: groupID1, Name: model.NewString("engineering")},
|
||||
groupID2: {Id: groupID2, Name: model.NewString("developers")},
|
||||
groupID1: {Id: groupID1, Name: model.NewPointer("engineering")},
|
||||
groupID2: {Id: groupID2, Name: model.NewPointer("developers")},
|
||||
},
|
||||
Expected: &MentionResults{},
|
||||
},
|
||||
"matching group with preceding @": {
|
||||
Word: "@engineering",
|
||||
Groups: map[string]*model.Group{
|
||||
groupID1: {Id: groupID1, Name: model.NewString("engineering")},
|
||||
groupID2: {Id: groupID2, Name: model.NewString("developers")},
|
||||
groupID1: {Id: groupID1, Name: model.NewPointer("engineering")},
|
||||
groupID2: {Id: groupID2, Name: model.NewPointer("developers")},
|
||||
},
|
||||
Expected: &MentionResults{
|
||||
GroupMentions: map[string]MentionType{
|
||||
@@ -257,8 +257,8 @@ func TestCheckForMentionGroups(t *testing.T) {
|
||||
"matching upper case group with preceding @": {
|
||||
Word: "@Engineering",
|
||||
Groups: map[string]*model.Group{
|
||||
groupID1: {Id: groupID1, Name: model.NewString("engineering")},
|
||||
groupID2: {Id: groupID2, Name: model.NewString("developers")},
|
||||
groupID1: {Id: groupID1, Name: model.NewPointer("engineering")},
|
||||
groupID2: {Id: groupID2, Name: model.NewPointer("developers")},
|
||||
},
|
||||
Expected: &MentionResults{
|
||||
GroupMentions: map[string]MentionType{
|
||||
@@ -294,8 +294,8 @@ func TestProcessText(t *testing.T) {
|
||||
Text: "hello user @user1",
|
||||
Keywords: map[string][]string{"@user1": {userID1}},
|
||||
Groups: map[string]*model.Group{
|
||||
groupID1: {Id: groupID1, Name: model.NewString("engineering")},
|
||||
groupID2: {Id: groupID2, Name: model.NewString("developers")},
|
||||
groupID1: {Id: groupID1, Name: model.NewPointer("engineering")},
|
||||
groupID2: {Id: groupID2, Name: model.NewPointer("developers")},
|
||||
},
|
||||
Expected: &MentionResults{
|
||||
Mentions: map[string]MentionType{
|
||||
@@ -307,8 +307,8 @@ func TestProcessText(t *testing.T) {
|
||||
Text: "hello user.@user1",
|
||||
Keywords: map[string][]string{"@user1": {userID1}},
|
||||
Groups: map[string]*model.Group{
|
||||
groupID1: {Id: groupID1, Name: model.NewString("engineering")},
|
||||
groupID2: {Id: groupID2, Name: model.NewString("developers")},
|
||||
groupID1: {Id: groupID1, Name: model.NewPointer("engineering")},
|
||||
groupID2: {Id: groupID2, Name: model.NewPointer("developers")},
|
||||
},
|
||||
Expected: &MentionResults{
|
||||
Mentions: map[string]MentionType{
|
||||
@@ -329,8 +329,8 @@ func TestProcessText(t *testing.T) {
|
||||
Text: "hello user:@user1",
|
||||
Keywords: map[string][]string{"@user1": {userID1}},
|
||||
Groups: map[string]*model.Group{
|
||||
groupID1: {Id: groupID1, Name: model.NewString("engineering")},
|
||||
groupID2: {Id: groupID2, Name: model.NewString("developers")},
|
||||
groupID1: {Id: groupID1, Name: model.NewPointer("engineering")},
|
||||
groupID2: {Id: groupID2, Name: model.NewPointer("developers")},
|
||||
},
|
||||
Expected: &MentionResults{
|
||||
Mentions: map[string]MentionType{
|
||||
@@ -342,8 +342,8 @@ func TestProcessText(t *testing.T) {
|
||||
Text: "hello all:@here",
|
||||
Keywords: map[string][]string{},
|
||||
Groups: map[string]*model.Group{
|
||||
groupID1: {Id: groupID1, Name: model.NewString("engineering")},
|
||||
groupID2: {Id: groupID2, Name: model.NewString("developers")},
|
||||
groupID1: {Id: groupID1, Name: model.NewPointer("engineering")},
|
||||
groupID2: {Id: groupID2, Name: model.NewPointer("developers")},
|
||||
},
|
||||
Expected: &MentionResults{
|
||||
HereMentioned: true,
|
||||
@@ -353,8 +353,8 @@ func TestProcessText(t *testing.T) {
|
||||
Text: "hello all-@all",
|
||||
Keywords: map[string][]string{},
|
||||
Groups: map[string]*model.Group{
|
||||
groupID1: {Id: groupID1, Name: model.NewString("engineering")},
|
||||
groupID2: {Id: groupID2, Name: model.NewString("developers")},
|
||||
groupID1: {Id: groupID1, Name: model.NewPointer("engineering")},
|
||||
groupID2: {Id: groupID2, Name: model.NewPointer("developers")},
|
||||
},
|
||||
Expected: &MentionResults{
|
||||
AllMentioned: true,
|
||||
@@ -364,8 +364,8 @@ func TestProcessText(t *testing.T) {
|
||||
Text: "hello channel.@channel",
|
||||
Keywords: map[string][]string{},
|
||||
Groups: map[string]*model.Group{
|
||||
groupID1: {Id: groupID1, Name: model.NewString("engineering")},
|
||||
groupID2: {Id: groupID2, Name: model.NewString("developers")},
|
||||
groupID1: {Id: groupID1, Name: model.NewPointer("engineering")},
|
||||
groupID2: {Id: groupID2, Name: model.NewPointer("developers")},
|
||||
},
|
||||
Expected: &MentionResults{
|
||||
ChannelMentioned: true,
|
||||
@@ -375,8 +375,8 @@ func TestProcessText(t *testing.T) {
|
||||
Text: "hello @potentialuser and @otherpotentialuser",
|
||||
Keywords: map[string][]string{},
|
||||
Groups: map[string]*model.Group{
|
||||
groupID1: {Id: groupID1, Name: model.NewString("engineering")},
|
||||
groupID2: {Id: groupID2, Name: model.NewString("developers")},
|
||||
groupID1: {Id: groupID1, Name: model.NewPointer("engineering")},
|
||||
groupID2: {Id: groupID2, Name: model.NewPointer("developers")},
|
||||
},
|
||||
Expected: &MentionResults{
|
||||
OtherPotentialMentions: []string{"potentialuser", "otherpotentialuser"},
|
||||
@@ -386,8 +386,8 @@ func TestProcessText(t *testing.T) {
|
||||
Text: "@user1, you can use @systembot to get help",
|
||||
Keywords: map[string][]string{"@user1": {userID1}},
|
||||
Groups: map[string]*model.Group{
|
||||
groupID1: {Id: groupID1, Name: model.NewString("engineering")},
|
||||
groupID2: {Id: groupID2, Name: model.NewString("developers")},
|
||||
groupID1: {Id: groupID1, Name: model.NewPointer("engineering")},
|
||||
groupID2: {Id: groupID2, Name: model.NewPointer("developers")},
|
||||
},
|
||||
Expected: &MentionResults{
|
||||
Mentions: map[string]MentionType{
|
||||
@@ -400,8 +400,8 @@ func TestProcessText(t *testing.T) {
|
||||
Text: "@engineering",
|
||||
Keywords: map[string][]string{"@user1": {userID1}},
|
||||
Groups: map[string]*model.Group{
|
||||
groupID1: {Id: groupID1, Name: model.NewString("engineering")},
|
||||
groupID2: {Id: groupID2, Name: model.NewString("developers")},
|
||||
groupID1: {Id: groupID1, Name: model.NewPointer("engineering")},
|
||||
groupID2: {Id: groupID2, Name: model.NewPointer("developers")},
|
||||
},
|
||||
Expected: &MentionResults{
|
||||
GroupMentions: map[string]MentionType{groupID1: GroupMention},
|
||||
@@ -411,8 +411,8 @@ func TestProcessText(t *testing.T) {
|
||||
Text: "@engineering @user1, you can use @systembot to get help from",
|
||||
Keywords: map[string][]string{"@user1": {userID1}},
|
||||
Groups: map[string]*model.Group{
|
||||
groupID1: {Id: groupID1, Name: model.NewString("engineering")},
|
||||
groupID2: {Id: groupID2, Name: model.NewString("developers")},
|
||||
groupID1: {Id: groupID1, Name: model.NewPointer("engineering")},
|
||||
groupID2: {Id: groupID2, Name: model.NewPointer("developers")},
|
||||
},
|
||||
Expected: &MentionResults{
|
||||
Mentions: map[string]MentionType{
|
||||
|
||||
@@ -337,7 +337,7 @@ func (s *Server) doContentExtractionConfigDefaultTrueMigration() error {
|
||||
}
|
||||
|
||||
s.platform.UpdateConfig(func(config *model.Config) {
|
||||
config.FileSettings.ExtractContent = model.NewBool(true)
|
||||
config.FileSettings.ExtractContent = model.NewPointer(true)
|
||||
})
|
||||
|
||||
system := model.System{
|
||||
@@ -561,7 +561,7 @@ func (s *Server) doPostPriorityConfigDefaultTrueMigration() error {
|
||||
}
|
||||
|
||||
s.platform.UpdateConfig(func(config *model.Config) {
|
||||
config.ServiceSettings.PostPriority = model.NewBool(true)
|
||||
config.ServiceSettings.PostPriority = model.NewPointer(true)
|
||||
})
|
||||
|
||||
system := model.System{
|
||||
|
||||
@@ -819,7 +819,7 @@ func TestFilterOutOfChannelMentions(t *testing.T) {
|
||||
require.Nil(t, appErr)
|
||||
|
||||
constrainedChannel := th.CreateChannel(th.Context, th.BasicTeam)
|
||||
constrainedChannel.GroupConstrained = model.NewBool(true)
|
||||
constrainedChannel.GroupConstrained = model.NewPointer(true)
|
||||
constrainedChannel, appErr = th.App.UpdateChannel(th.Context, constrainedChannel)
|
||||
require.Nil(t, appErr)
|
||||
|
||||
@@ -1361,7 +1361,7 @@ func TestGetExplicitMentions(t *testing.T) {
|
||||
},
|
||||
"No matching groups": {
|
||||
Message: "@nothing",
|
||||
Groups: map[string]*model.Group{groupID1: {Id: groupID1, Name: model.NewString("engineering")}},
|
||||
Groups: map[string]*model.Group{groupID1: {Id: groupID1, Name: model.NewPointer("engineering")}},
|
||||
Expected: &MentionResults{
|
||||
Mentions: nil,
|
||||
GroupMentions: nil,
|
||||
@@ -1370,7 +1370,7 @@ func TestGetExplicitMentions(t *testing.T) {
|
||||
},
|
||||
"matching group with no @": {
|
||||
Message: "engineering",
|
||||
Groups: map[string]*model.Group{groupID1: {Id: groupID1, Name: model.NewString("engineering")}},
|
||||
Groups: map[string]*model.Group{groupID1: {Id: groupID1, Name: model.NewPointer("engineering")}},
|
||||
Expected: &MentionResults{
|
||||
Mentions: nil,
|
||||
GroupMentions: nil,
|
||||
@@ -1379,7 +1379,7 @@ func TestGetExplicitMentions(t *testing.T) {
|
||||
},
|
||||
"matching group with preceding @": {
|
||||
Message: "@engineering",
|
||||
Groups: map[string]*model.Group{groupID1: {Id: groupID1, Name: model.NewString("engineering")}},
|
||||
Groups: map[string]*model.Group{groupID1: {Id: groupID1, Name: model.NewPointer("engineering")}},
|
||||
Expected: &MentionResults{
|
||||
Mentions: nil,
|
||||
GroupMentions: map[string]MentionType{
|
||||
@@ -1389,7 +1389,7 @@ func TestGetExplicitMentions(t *testing.T) {
|
||||
},
|
||||
"matching upper case group with preceding @": {
|
||||
Message: "@Engineering",
|
||||
Groups: map[string]*model.Group{groupID1: {Id: groupID1, Name: model.NewString("engineering")}},
|
||||
Groups: map[string]*model.Group{groupID1: {Id: groupID1, Name: model.NewPointer("engineering")}},
|
||||
Expected: &MentionResults{
|
||||
Mentions: nil,
|
||||
GroupMentions: map[string]MentionType{
|
||||
@@ -2517,7 +2517,7 @@ func TestInsertGroupMentions(t *testing.T) {
|
||||
channel := th.BasicChannel
|
||||
group := th.CreateGroup()
|
||||
group.DisplayName = "engineering"
|
||||
group.Name = model.NewString("engineering")
|
||||
group.Name = model.NewPointer("engineering")
|
||||
group, err := th.App.UpdateGroup(group)
|
||||
require.Nil(t, err)
|
||||
|
||||
@@ -2544,7 +2544,7 @@ func TestInsertGroupMentions(t *testing.T) {
|
||||
|
||||
groupWithNoMembers := th.CreateGroup()
|
||||
groupWithNoMembers.DisplayName = "marketing"
|
||||
groupWithNoMembers.Name = model.NewString("marketing")
|
||||
groupWithNoMembers.Name = model.NewPointer("marketing")
|
||||
groupWithNoMembers, err = th.App.UpdateGroup(groupWithNoMembers)
|
||||
require.Nil(t, err)
|
||||
|
||||
@@ -2672,7 +2672,7 @@ func TestGetGroupsAllowedForReferenceInChannel(t *testing.T) {
|
||||
customGroupId := model.NewId()
|
||||
customGroup, err := th.App.CreateGroup(&model.Group{
|
||||
DisplayName: customGroupId,
|
||||
Name: model.NewString("name" + customGroupId),
|
||||
Name: model.NewPointer("name" + customGroupId),
|
||||
Source: model.GroupSourceCustom,
|
||||
Description: "description_" + customGroupId,
|
||||
AllowReference: true,
|
||||
@@ -2689,7 +2689,7 @@ func TestGetGroupsAllowedForReferenceInChannel(t *testing.T) {
|
||||
|
||||
// Sync first group to constrained channel
|
||||
constrainedChannel := th.CreateChannel(th.Context, th.BasicTeam)
|
||||
constrainedChannel.GroupConstrained = model.NewBool(true)
|
||||
constrainedChannel.GroupConstrained = model.NewPointer(true)
|
||||
constrainedChannel, err = th.App.UpdateChannel(th.Context, constrainedChannel)
|
||||
require.Nil(t, err)
|
||||
_, err = th.App.UpsertGroupSyncable(&model.GroupSyncable{
|
||||
@@ -2715,7 +2715,7 @@ func TestGetGroupsAllowedForReferenceInChannel(t *testing.T) {
|
||||
require.Nil(t, err)
|
||||
|
||||
// Sync group2 to the team
|
||||
team.GroupConstrained = model.NewBool(true)
|
||||
team.GroupConstrained = model.NewPointer(true)
|
||||
team, err = th.App.UpdateTeam(team)
|
||||
require.Nil(t, err)
|
||||
_, err = th.App.UpsertGroupSyncable(&model.GroupSyncable{
|
||||
@@ -2745,7 +2745,7 @@ func TestGetGroupsAllowedForReferenceInChannel(t *testing.T) {
|
||||
require.Equal(t, groupsMap[customGroup.Id], customGroup)
|
||||
})
|
||||
|
||||
team.GroupConstrained = model.NewBool(false)
|
||||
team.GroupConstrained = model.NewPointer(false)
|
||||
team, err = th.App.UpdateTeam(team)
|
||||
require.Nil(t, err)
|
||||
|
||||
@@ -2998,7 +2998,7 @@ func TestRemoveNotifications(t *testing.T) {
|
||||
|
||||
t.Run("when mentioned via a user group", func(t *testing.T) {
|
||||
group, appErr := th.App.CreateGroup(&model.Group{
|
||||
Name: model.NewString("test_group"),
|
||||
Name: model.NewPointer("test_group"),
|
||||
DisplayName: "test_group",
|
||||
Source: model.GroupSourceCustom,
|
||||
})
|
||||
|
||||
@@ -627,7 +627,7 @@ func (a *App) LoginByOAuth(c request.CTX, service string, userData io.Reader, te
|
||||
map[string]any{"Service": service}, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
user, err := a.GetUserByAuth(model.NewString(*authUser.AuthData), service)
|
||||
user, err := a.GetUserByAuth(model.NewPointer(*authUser.AuthData), service)
|
||||
if err != nil {
|
||||
if err.Id == MissingAuthAccountError {
|
||||
user, err = a.CreateOAuthUser(c, service, bytes.NewReader(buf.Bytes()), teamID, tokenUser)
|
||||
|
||||
@@ -61,7 +61,7 @@ func TestConfigSave(t *testing.T) {
|
||||
t.Run("trigger a config changed event for the cluster", func(t *testing.T) {
|
||||
oldCfg := th.Service.Config()
|
||||
newCfg := oldCfg.Clone()
|
||||
newCfg.ServiceSettings.SiteURL = model.NewString("http://newhost.me")
|
||||
newCfg.ServiceSettings.SiteURL = model.NewPointer("http://newhost.me")
|
||||
|
||||
sanitizedOldCfg := th.Service.configStore.RemoveEnvironmentOverrides(oldCfg)
|
||||
sanitizedNewCfg := th.Service.configStore.RemoveEnvironmentOverrides(newCfg)
|
||||
@@ -87,16 +87,16 @@ func TestConfigSave(t *testing.T) {
|
||||
|
||||
// Change a random config setting
|
||||
cfg := th.Service.Config().Clone()
|
||||
cfg.ThemeSettings.EnableThemeSelection = model.NewBool(!*cfg.ThemeSettings.EnableThemeSelection)
|
||||
cfg.ThemeSettings.EnableThemeSelection = model.NewPointer(!*cfg.ThemeSettings.EnableThemeSelection)
|
||||
th.Service.SaveConfig(cfg, false)
|
||||
metricsMock.AssertNumberOfCalls(t, "Register", 0)
|
||||
|
||||
// Disable metrics
|
||||
cfg.MetricsSettings.Enable = model.NewBool(false)
|
||||
cfg.MetricsSettings.Enable = model.NewPointer(false)
|
||||
th.Service.SaveConfig(cfg, false)
|
||||
|
||||
// Change the metrics setting
|
||||
cfg.MetricsSettings.Enable = model.NewBool(true)
|
||||
cfg.MetricsSettings.Enable = model.NewPointer(true)
|
||||
th.Service.SaveConfig(cfg, false)
|
||||
metricsMock.AssertNumberOfCalls(t, "Register", 1)
|
||||
})
|
||||
|
||||
@@ -264,7 +264,7 @@ type ChannelOption func(*model.Channel)
|
||||
|
||||
func WithShared(v bool) ChannelOption {
|
||||
return func(channel *model.Channel) {
|
||||
channel.Shared = model.NewBool(v)
|
||||
channel.Shared = model.NewPointer(v)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ func TestMetrics(t *testing.T) {
|
||||
// there is no config listener for the metrics
|
||||
// we handle it on config save step
|
||||
cfg := th.Service.Config().Clone()
|
||||
cfg.MetricsSettings.Enable = model.NewBool(true)
|
||||
cfg.MetricsSettings.Enable = model.NewPointer(true)
|
||||
th.Service.SaveConfig(cfg, false)
|
||||
|
||||
require.NotNil(t, th.Service.metrics)
|
||||
@@ -109,7 +109,7 @@ func TestMetrics(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, http.StatusOK, resp.StatusCode)
|
||||
|
||||
cfg.MetricsSettings.Enable = model.NewBool(false)
|
||||
cfg.MetricsSettings.Enable = model.NewPointer(false)
|
||||
th.Service.SaveConfig(cfg, false)
|
||||
|
||||
_, err = http.Get(metricsAddr)
|
||||
|
||||
@@ -81,7 +81,7 @@ func TestServerSyncSharedChannelHandler(t *testing.T) {
|
||||
mockChannelStore := &mocks.ChannelStore{}
|
||||
mockChannelStore.On("Get", "channelID", true).Return(&model.Channel{
|
||||
Id: "channelID",
|
||||
Shared: model.NewBool(true),
|
||||
Shared: model.NewPointer(true),
|
||||
}, nil)
|
||||
|
||||
mockUserStore := &mocks.UserStore{}
|
||||
|
||||
@@ -852,7 +852,7 @@ func (wc *WebConn) ShouldSendEvent(msg *model.WebSocketEvent) bool {
|
||||
// see sensitive data. Prevents admin clients from receiving events with bad data
|
||||
var hasReadPrivateDataPermission *bool
|
||||
if msg.GetBroadcast().ContainsSanitizedData {
|
||||
hasReadPrivateDataPermission = model.NewBool(wc.Suite.RolesGrantPermission(wc.GetSession().GetUserRoles(), model.PermissionManageSystem.Id))
|
||||
hasReadPrivateDataPermission = model.NewPointer(wc.Suite.RolesGrantPermission(wc.GetSession().GetUserRoles(), model.PermissionManageSystem.Id))
|
||||
|
||||
if *hasReadPrivateDataPermission {
|
||||
return false
|
||||
@@ -862,7 +862,7 @@ func (wc *WebConn) ShouldSendEvent(msg *model.WebSocketEvent) bool {
|
||||
// If the event contains sensitive data, only send to users with permission to see it
|
||||
if msg.GetBroadcast().ContainsSensitiveData {
|
||||
if hasReadPrivateDataPermission == nil {
|
||||
hasReadPrivateDataPermission = model.NewBool(wc.Suite.RolesGrantPermission(wc.GetSession().GetUserRoles(), model.PermissionManageSystem.Id))
|
||||
hasReadPrivateDataPermission = model.NewPointer(wc.Suite.RolesGrantPermission(wc.GetSession().GetUserRoles(), model.PermissionManageSystem.Id))
|
||||
}
|
||||
|
||||
if !*hasReadPrivateDataPermission {
|
||||
|
||||
@@ -2408,8 +2408,8 @@ func TestPluginServeMetrics(t *testing.T) {
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
prevEnable = cfg.MetricsSettings.Enable
|
||||
prevAddress = cfg.MetricsSettings.ListenAddress
|
||||
cfg.MetricsSettings.Enable = model.NewBool(true)
|
||||
cfg.MetricsSettings.ListenAddress = model.NewString(":30067")
|
||||
cfg.MetricsSettings.Enable = model.NewPointer(true)
|
||||
cfg.MetricsSettings.ListenAddress = model.NewPointer(":30067")
|
||||
})
|
||||
defer th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
cfg.MetricsSettings.Enable = prevEnable
|
||||
|
||||
@@ -32,7 +32,7 @@ func (p *MyPlugin) OnConfigurationChange() error {
|
||||
func (p *MyPlugin) MessageWillBePosted(_ *plugin.Context, _ *model.Post) (*model.Post, string) {
|
||||
rctx := request.TestContext(p.t)
|
||||
settings := p.API.GetUnsanitizedConfig().SqlSettings
|
||||
settings.Trace = model.NewBool(false)
|
||||
settings.Trace = model.NewPointer(false)
|
||||
store, err := sqlstore.New(settings, rctx.Logger(), nil)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
||||
@@ -56,7 +56,7 @@ func (p *MyPlugin) MessageWillBePosted(_ *plugin.Context, _ *model.Post) (*model
|
||||
// Update BasicUser to SAML
|
||||
expectedUserAuth := &model.UserAuth{
|
||||
AuthService: model.UserAuthServiceSaml,
|
||||
AuthData: model.NewString("saml_auth_data"),
|
||||
AuthData: model.NewPointer("saml_auth_data"),
|
||||
}
|
||||
_, appErr = p.API.UpdateUserAuth(p.configuration.BasicUserID, expectedUserAuth)
|
||||
if appErr != nil {
|
||||
@@ -69,7 +69,7 @@ func (p *MyPlugin) MessageWillBePosted(_ *plugin.Context, _ *model.Post) (*model
|
||||
// Update BasicUser to LDAP
|
||||
expectedUserAuth = &model.UserAuth{
|
||||
AuthService: model.UserAuthServiceLdap,
|
||||
AuthData: model.NewString("ldap_auth_data"),
|
||||
AuthData: model.NewPointer("ldap_auth_data"),
|
||||
}
|
||||
_, err := p.API.UpdateUserAuth(p.configuration.BasicUserID, expectedUserAuth)
|
||||
if err != nil {
|
||||
|
||||
@@ -479,7 +479,7 @@ func TestPluginSync(t *testing.T) {
|
||||
{
|
||||
"local",
|
||||
func(cfg *model.Config) {
|
||||
cfg.FileSettings.DriverName = model.NewString(model.ImageDriverLocal)
|
||||
cfg.FileSettings.DriverName = model.NewPointer(model.ImageDriverLocal)
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -496,14 +496,14 @@ func TestPluginSync(t *testing.T) {
|
||||
}
|
||||
|
||||
s3Endpoint := fmt.Sprintf("%s:%s", s3Host, s3Port)
|
||||
cfg.FileSettings.DriverName = model.NewString(model.ImageDriverS3)
|
||||
cfg.FileSettings.AmazonS3AccessKeyId = model.NewString(model.MinioAccessKey)
|
||||
cfg.FileSettings.AmazonS3SecretAccessKey = model.NewString(model.MinioSecretKey)
|
||||
cfg.FileSettings.AmazonS3Bucket = model.NewString(model.MinioBucket)
|
||||
cfg.FileSettings.AmazonS3PathPrefix = model.NewString("")
|
||||
cfg.FileSettings.AmazonS3Endpoint = model.NewString(s3Endpoint)
|
||||
cfg.FileSettings.AmazonS3Region = model.NewString("")
|
||||
cfg.FileSettings.AmazonS3SSL = model.NewBool(false)
|
||||
cfg.FileSettings.DriverName = model.NewPointer(model.ImageDriverS3)
|
||||
cfg.FileSettings.AmazonS3AccessKeyId = model.NewPointer(model.MinioAccessKey)
|
||||
cfg.FileSettings.AmazonS3SecretAccessKey = model.NewPointer(model.MinioSecretKey)
|
||||
cfg.FileSettings.AmazonS3Bucket = model.NewPointer(model.MinioBucket)
|
||||
cfg.FileSettings.AmazonS3PathPrefix = model.NewPointer("")
|
||||
cfg.FileSettings.AmazonS3Endpoint = model.NewPointer(s3Endpoint)
|
||||
cfg.FileSettings.AmazonS3Region = model.NewPointer("")
|
||||
cfg.FileSettings.AmazonS3SSL = model.NewPointer(false)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -693,7 +693,7 @@ func (a *App) UpdatePost(c request.CTX, receivedUpdatedPost *model.Post, safeUpd
|
||||
}
|
||||
|
||||
if receivedUpdatedPost.IsRemote() {
|
||||
oldPost.RemoteId = model.NewString(*receivedUpdatedPost.RemoteId)
|
||||
oldPost.RemoteId = model.NewPointer(*receivedUpdatedPost.RemoteId)
|
||||
}
|
||||
|
||||
var rejectionReason string
|
||||
|
||||
@@ -700,10 +700,10 @@ func TestImageProxy(t *testing.T) {
|
||||
} {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
cfg.ImageProxySettings.Enable = model.NewBool(true)
|
||||
cfg.ImageProxySettings.ImageProxyType = model.NewString(tc.ProxyType)
|
||||
cfg.ImageProxySettings.RemoteImageProxyOptions = model.NewString(tc.ProxyOptions)
|
||||
cfg.ImageProxySettings.RemoteImageProxyURL = model.NewString(tc.ProxyURL)
|
||||
cfg.ImageProxySettings.Enable = model.NewPointer(true)
|
||||
cfg.ImageProxySettings.ImageProxyType = model.NewPointer(tc.ProxyType)
|
||||
cfg.ImageProxySettings.RemoteImageProxyOptions = model.NewPointer(tc.ProxyOptions)
|
||||
cfg.ImageProxySettings.RemoteImageProxyURL = model.NewPointer(tc.ProxyURL)
|
||||
})
|
||||
|
||||
post := &model.Post{
|
||||
@@ -1131,7 +1131,7 @@ func TestPatchPost(t *testing.T) {
|
||||
assert.NotEqual(t, "", rpost.Message)
|
||||
|
||||
patch := &model.PostPatch{
|
||||
Message: model.NewString(""),
|
||||
Message: model.NewPointer(""),
|
||||
}
|
||||
|
||||
rpost, err = th.App.PatchPost(th.Context, rpost.Id, patch)
|
||||
@@ -1155,13 +1155,13 @@ func TestPatchPost(t *testing.T) {
|
||||
require.Nil(t, err)
|
||||
|
||||
t.Run("Does not set prop when user has USE_CHANNEL_MENTIONS", func(t *testing.T) {
|
||||
patchWithNoMention := &model.PostPatch{Message: model.NewString("This patch has no channel mention")}
|
||||
patchWithNoMention := &model.PostPatch{Message: model.NewPointer("This patch has no channel mention")}
|
||||
|
||||
rpost, err = th.App.PatchPost(th.Context, rpost.Id, patchWithNoMention)
|
||||
require.Nil(t, err)
|
||||
assert.Equal(t, rpost.GetProps(), model.StringInterface{})
|
||||
|
||||
patchWithMention := &model.PostPatch{Message: model.NewString("This patch has a mention now @here")}
|
||||
patchWithMention := &model.PostPatch{Message: model.NewPointer("This patch has a mention now @here")}
|
||||
|
||||
rpost, err = th.App.PatchPost(th.Context, rpost.Id, patchWithMention)
|
||||
require.Nil(t, err)
|
||||
@@ -1172,12 +1172,12 @@ func TestPatchPost(t *testing.T) {
|
||||
th.RemovePermissionFromRole(model.PermissionUseChannelMentions.Id, model.ChannelUserRoleId)
|
||||
th.RemovePermissionFromRole(model.PermissionUseChannelMentions.Id, model.ChannelAdminRoleId)
|
||||
|
||||
patchWithNoMention := &model.PostPatch{Message: model.NewString("This patch still does not have a mention")}
|
||||
patchWithNoMention := &model.PostPatch{Message: model.NewPointer("This patch still does not have a mention")}
|
||||
rpost, err = th.App.PatchPost(th.Context, rpost.Id, patchWithNoMention)
|
||||
require.Nil(t, err)
|
||||
assert.Equal(t, rpost.GetProps(), model.StringInterface{})
|
||||
|
||||
patchWithMention := &model.PostPatch{Message: model.NewString("This patch has a mention now @here")}
|
||||
patchWithMention := &model.PostPatch{Message: model.NewPointer("This patch has a mention now @here")}
|
||||
|
||||
rpost, err = th.App.PatchPost(th.Context, rpost.Id, patchWithMention)
|
||||
require.Nil(t, err)
|
||||
@@ -1373,7 +1373,7 @@ func TestPatchPostInArchivedChannel(t *testing.T) {
|
||||
post := th.CreatePost(archivedChannel)
|
||||
th.App.DeleteChannel(th.Context, archivedChannel, "")
|
||||
|
||||
_, err := th.App.PatchPost(th.Context, post.Id, &model.PostPatch{IsPinned: model.NewBool(true)})
|
||||
_, err := th.App.PatchPost(th.Context, post.Id, &model.PostPatch{IsPinned: model.NewPointer(true)})
|
||||
require.NotNil(t, err)
|
||||
require.Equal(t, "api.post.patch_post.can_not_update_post_in_deleted.error", err.Id)
|
||||
}
|
||||
@@ -2471,7 +2471,7 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
Message: fmt.Sprintf("@%s", user2.Username),
|
||||
Metadata: &model.PostMetadata{
|
||||
Priority: &model.PostPriority{
|
||||
Priority: model.NewString(model.PostPriorityUrgent),
|
||||
Priority: model.NewPointer(model.PostPriorityUrgent),
|
||||
},
|
||||
},
|
||||
}, channel, false, true)
|
||||
@@ -2490,7 +2490,7 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
Message: "apple",
|
||||
Metadata: &model.PostMetadata{
|
||||
Priority: &model.PostPriority{
|
||||
Priority: model.NewString(model.PostPriorityUrgent),
|
||||
Priority: model.NewPointer(model.PostPriorityUrgent),
|
||||
},
|
||||
},
|
||||
}, channel, false, true)
|
||||
@@ -3263,7 +3263,7 @@ func TestComputeLastAccessiblePostTime(t *testing.T) {
|
||||
// cloud-starter, limit is applicable
|
||||
cloud.Mock.On("GetCloudLimits", mock.Anything).Return(&model.ProductLimits{
|
||||
Messages: &model.MessagesLimits{
|
||||
History: model.NewInt(1),
|
||||
History: model.NewPointer(1),
|
||||
},
|
||||
}, nil)
|
||||
|
||||
@@ -3323,14 +3323,14 @@ func TestGetEditHistoryForPost(t *testing.T) {
|
||||
|
||||
// update the post message
|
||||
patch := &model.PostPatch{
|
||||
Message: model.NewString("new message edited"),
|
||||
Message: model.NewPointer("new message edited"),
|
||||
}
|
||||
_, err1 := th.App.PatchPost(th.Context, rpost.Id, patch)
|
||||
require.Nil(t, err1)
|
||||
|
||||
// update the post message again
|
||||
patch = &model.PostPatch{
|
||||
Message: model.NewString("new message edited again"),
|
||||
Message: model.NewPointer("new message edited again"),
|
||||
}
|
||||
|
||||
_, err2 := th.App.PatchPost(th.Context, rpost.Id, patch)
|
||||
@@ -3410,11 +3410,11 @@ func TestValidateMoveOrCopy(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
cfg.WranglerSettings.MoveThreadFromPrivateChannelEnable = model.NewBool(true)
|
||||
cfg.WranglerSettings.MoveThreadFromDirectMessageChannelEnable = model.NewBool(true)
|
||||
cfg.WranglerSettings.MoveThreadFromGroupMessageChannelEnable = model.NewBool(true)
|
||||
cfg.WranglerSettings.MoveThreadToAnotherTeamEnable = model.NewBool(true)
|
||||
cfg.WranglerSettings.MoveThreadMaxCount = model.NewInt64(100)
|
||||
cfg.WranglerSettings.MoveThreadFromPrivateChannelEnable = model.NewPointer(true)
|
||||
cfg.WranglerSettings.MoveThreadFromDirectMessageChannelEnable = model.NewPointer(true)
|
||||
cfg.WranglerSettings.MoveThreadFromGroupMessageChannelEnable = model.NewPointer(true)
|
||||
cfg.WranglerSettings.MoveThreadToAnotherTeamEnable = model.NewPointer(true)
|
||||
cfg.WranglerSettings.MoveThreadMaxCount = model.NewPointer(int64(100))
|
||||
})
|
||||
|
||||
t.Run("empty post list", func(t *testing.T) {
|
||||
@@ -3433,7 +3433,7 @@ func TestValidateMoveOrCopy(t *testing.T) {
|
||||
require.Nil(t, err)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
cfg.WranglerSettings.MoveThreadFromPrivateChannelEnable = model.NewBool(false)
|
||||
cfg.WranglerSettings.MoveThreadFromPrivateChannelEnable = model.NewPointer(false)
|
||||
})
|
||||
|
||||
e := th.App.ValidateMoveOrCopy(th.Context, &model.WranglerPostList{Posts: []*model.Post{{ChannelId: privateChannel.Id}}}, privateChannel, th.BasicChannel, th.BasicUser)
|
||||
@@ -3446,7 +3446,7 @@ func TestValidateMoveOrCopy(t *testing.T) {
|
||||
require.Nil(t, err)
|
||||
require.NotNil(t, directChannel)
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
cfg.WranglerSettings.MoveThreadFromDirectMessageChannelEnable = model.NewBool(false)
|
||||
cfg.WranglerSettings.MoveThreadFromDirectMessageChannelEnable = model.NewPointer(false)
|
||||
})
|
||||
|
||||
e := th.App.ValidateMoveOrCopy(th.Context, &model.WranglerPostList{Posts: []*model.Post{{ChannelId: directChannel.Id}}}, directChannel, th.BasicChannel, th.BasicUser)
|
||||
@@ -3464,7 +3464,7 @@ func TestValidateMoveOrCopy(t *testing.T) {
|
||||
require.Nil(t, err)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
cfg.WranglerSettings.MoveThreadFromGroupMessageChannelEnable = model.NewBool(false)
|
||||
cfg.WranglerSettings.MoveThreadFromGroupMessageChannelEnable = model.NewPointer(false)
|
||||
})
|
||||
|
||||
e := th.App.ValidateMoveOrCopy(th.Context, &model.WranglerPostList{Posts: []*model.Post{{ChannelId: groupChannel.Id}}}, groupChannel, th.BasicChannel, th.BasicUser)
|
||||
@@ -3493,7 +3493,7 @@ func TestValidateMoveOrCopy(t *testing.T) {
|
||||
require.Nil(t, err)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
cfg.WranglerSettings.MoveThreadToAnotherTeamEnable = model.NewBool(false)
|
||||
cfg.WranglerSettings.MoveThreadToAnotherTeamEnable = model.NewPointer(false)
|
||||
})
|
||||
|
||||
e := th.App.ValidateMoveOrCopy(th.Context, &model.WranglerPostList{Posts: []*model.Post{{ChannelId: th.BasicChannel.Id}}}, th.BasicChannel, targetChannel, th.BasicUser)
|
||||
|
||||
@@ -248,7 +248,7 @@ func TestNoticeValidation(t *testing.T) {
|
||||
userCount: 300,
|
||||
notice: &model.ProductNotice{
|
||||
Conditions: model.Conditions{
|
||||
NumberOfUsers: model.NewInt64(400),
|
||||
NumberOfUsers: model.NewPointer(int64(400)),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -262,8 +262,8 @@ func TestNoticeValidation(t *testing.T) {
|
||||
postCount: 2000,
|
||||
notice: &model.ProductNotice{
|
||||
Conditions: model.Conditions{
|
||||
NumberOfUsers: model.NewInt64(400),
|
||||
NumberOfPosts: model.NewInt64(3000),
|
||||
NumberOfUsers: model.NewPointer(int64(400)),
|
||||
NumberOfPosts: model.NewPointer(int64(3000)),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -275,7 +275,7 @@ func TestNoticeValidation(t *testing.T) {
|
||||
args: args{
|
||||
notice: &model.ProductNotice{
|
||||
Conditions: model.Conditions{
|
||||
DisplayDate: model.NewString("> 2000-03-01T00:00:00Z <= 2999-04-01T00:00:00Z"),
|
||||
DisplayDate: model.NewPointer("> 2000-03-01T00:00:00Z <= 2999-04-01T00:00:00Z"),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -287,7 +287,7 @@ func TestNoticeValidation(t *testing.T) {
|
||||
args: args{
|
||||
notice: &model.ProductNotice{
|
||||
Conditions: model.Conditions{
|
||||
DisplayDate: model.NewString(fmt.Sprintf("= %sT00:00:00Z", time.Now().UTC().Format("2006-01-02"))),
|
||||
DisplayDate: model.NewPointer(fmt.Sprintf("= %sT00:00:00Z", time.Now().UTC().Format("2006-01-02"))),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -299,7 +299,7 @@ func TestNoticeValidation(t *testing.T) {
|
||||
args: args{
|
||||
notice: &model.ProductNotice{
|
||||
Conditions: model.Conditions{
|
||||
DisplayDate: model.NewString("> 2999-03-01T00:00:00Z <= 3000-04-01T00:00:00Z"),
|
||||
DisplayDate: model.NewPointer("> 2999-03-01T00:00:00Z <= 3000-04-01T00:00:00Z"),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -311,7 +311,7 @@ func TestNoticeValidation(t *testing.T) {
|
||||
args: args{
|
||||
notice: &model.ProductNotice{
|
||||
Conditions: model.Conditions{
|
||||
DisplayDate: model.NewString("> 2000 -03-01T00:00:00Z <= 2999-04-01T00:00:00Z"),
|
||||
DisplayDate: model.NewPointer("> 2000 -03-01T00:00:00Z <= 2999-04-01T00:00:00Z"),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -618,7 +618,7 @@ func TestNoticeFetch(t *testing.T) {
|
||||
|
||||
notices2 := model.ProductNotices{model.ProductNotice{
|
||||
Conditions: model.Conditions{
|
||||
NumberOfPosts: model.NewInt64(99999),
|
||||
NumberOfPosts: model.NewPointer(int64(99999)),
|
||||
},
|
||||
ID: "333",
|
||||
LocalizedMessages: map[string]model.NoticeMessageInternal{
|
||||
|
||||
@@ -16,12 +16,12 @@ import (
|
||||
|
||||
func genRateLimitSettings(useAuth, useIP bool, header string) *model.RateLimitSettings {
|
||||
return &model.RateLimitSettings{
|
||||
Enable: model.NewBool(true),
|
||||
PerSec: model.NewInt(10),
|
||||
MaxBurst: model.NewInt(100),
|
||||
MemoryStoreSize: model.NewInt(10000),
|
||||
VaryByRemoteAddr: model.NewBool(useIP),
|
||||
VaryByUser: model.NewBool(useAuth),
|
||||
Enable: model.NewPointer(true),
|
||||
PerSec: model.NewPointer(10),
|
||||
MaxBurst: model.NewPointer(100),
|
||||
MemoryStoreSize: model.NewPointer(10000),
|
||||
VaryByRemoteAddr: model.NewPointer(useIP),
|
||||
VaryByUser: model.NewPointer(useAuth),
|
||||
VaryByHeader: header,
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,7 @@ func TestNewRateLimiterSuccess(t *testing.T) {
|
||||
|
||||
func TestNewRateLimiterFailure(t *testing.T) {
|
||||
invalidSettings := genRateLimitSettings(false, false, "")
|
||||
invalidSettings.MaxBurst = model.NewInt(-100)
|
||||
invalidSettings.MaxBurst = model.NewPointer(-100)
|
||||
rateLimiter, err := NewRateLimiter(invalidSettings, nil)
|
||||
require.Nil(t, rateLimiter)
|
||||
require.Error(t, err)
|
||||
|
||||
@@ -102,14 +102,14 @@ func TestStartServerNoS3Bucket(t *testing.T) {
|
||||
|
||||
cfg := store.Get()
|
||||
cfg.FileSettings = model.FileSettings{
|
||||
DriverName: model.NewString(model.ImageDriverS3),
|
||||
AmazonS3AccessKeyId: model.NewString(model.MinioAccessKey),
|
||||
AmazonS3SecretAccessKey: model.NewString(model.MinioSecretKey),
|
||||
AmazonS3Bucket: model.NewString("nosuchbucket"),
|
||||
AmazonS3Endpoint: model.NewString(s3Endpoint),
|
||||
AmazonS3Region: model.NewString(""),
|
||||
AmazonS3PathPrefix: model.NewString(""),
|
||||
AmazonS3SSL: model.NewBool(false),
|
||||
DriverName: model.NewPointer(model.ImageDriverS3),
|
||||
AmazonS3AccessKeyId: model.NewPointer(model.MinioAccessKey),
|
||||
AmazonS3SecretAccessKey: model.NewPointer(model.MinioSecretKey),
|
||||
AmazonS3Bucket: model.NewPointer("nosuchbucket"),
|
||||
AmazonS3Endpoint: model.NewPointer(s3Endpoint),
|
||||
AmazonS3Region: model.NewPointer(""),
|
||||
AmazonS3PathPrefix: model.NewPointer(""),
|
||||
AmazonS3SSL: model.NewPointer(false),
|
||||
}
|
||||
*cfg.ServiceSettings.ListenAddress = "localhost:0"
|
||||
*cfg.AnnouncementSettings.AdminNoticesEnabled = false
|
||||
@@ -316,9 +316,9 @@ func TestPanicLog(t *testing.T) {
|
||||
logger, _ := mlog.NewLogger()
|
||||
|
||||
logSettings := model.NewLogSettings()
|
||||
logSettings.EnableConsole = model.NewBool(true)
|
||||
logSettings.ConsoleJson = model.NewBool(true)
|
||||
logSettings.EnableFile = model.NewBool(true)
|
||||
logSettings.EnableConsole = model.NewPointer(true)
|
||||
logSettings.ConsoleJson = model.NewPointer(true)
|
||||
logSettings.EnableFile = model.NewPointer(true)
|
||||
logSettings.FileLocation = &tmpDir
|
||||
logSettings.FileLevel = &mlog.LvlInfo.Name
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ func TestInviteProvider(t *testing.T) {
|
||||
groupChannel := th.createChannel(th.BasicTeam, model.ChannelTypePrivate)
|
||||
_, err := th.App.AddChannelMember(th.Context, th.BasicUser.Id, groupChannel, app.ChannelMemberOpts{})
|
||||
require.Nil(t, err)
|
||||
groupChannel.GroupConstrained = model.NewBool(true)
|
||||
groupChannel.GroupConstrained = model.NewPointer(true)
|
||||
groupChannel, _ = th.App.UpdateChannel(th.Context, groupChannel)
|
||||
|
||||
msg := "@" + th.BasicUser2.Username + " ~" + groupChannel.Name
|
||||
@@ -213,7 +213,7 @@ func TestInviteGroup(t *testing.T) {
|
||||
th := setup(t).initBasic()
|
||||
defer th.tearDown()
|
||||
|
||||
th.BasicTeam.GroupConstrained = model.NewBool(true)
|
||||
th.BasicTeam.GroupConstrained = model.NewPointer(true)
|
||||
var err *model.AppError
|
||||
_, _ = th.App.AddTeamMember(th.Context, th.BasicTeam.Id, th.BasicUser.Id)
|
||||
_, err = th.App.AddTeamMember(th.Context, th.BasicTeam.Id, th.BasicUser2.Id)
|
||||
@@ -274,7 +274,7 @@ func TestUserGroups(t *testing.T) {
|
||||
id := model.NewId()
|
||||
teamGroup, err := th.App.CreateGroup(&model.Group{
|
||||
DisplayName: "dn_" + id,
|
||||
Name: model.NewString("name" + id),
|
||||
Name: model.NewPointer("name" + id),
|
||||
Source: model.GroupSourceCustom,
|
||||
Description: "description_" + id,
|
||||
AllowReference: true,
|
||||
@@ -293,7 +293,7 @@ func TestUserGroups(t *testing.T) {
|
||||
id2 := model.NewId()
|
||||
nonTeamGroup, err := th.App.CreateGroup(&model.Group{
|
||||
DisplayName: "dn_" + id2,
|
||||
Name: model.NewString("name" + id2),
|
||||
Name: model.NewPointer("name" + id2),
|
||||
Source: model.GroupSourceCustom,
|
||||
Description: "description_" + id2,
|
||||
AllowReference: true,
|
||||
|
||||
@@ -354,8 +354,8 @@ func TestDoCommandRequest(t *testing.T) {
|
||||
defer th.tearDown()
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
cfg.ServiceSettings.AllowedUntrustedInternalConnections = model.NewString("127.0.0.1")
|
||||
cfg.ServiceSettings.EnableCommands = model.NewBool(true)
|
||||
cfg.ServiceSettings.AllowedUntrustedInternalConnections = model.NewPointer("127.0.0.1")
|
||||
cfg.ServiceSettings.EnableCommands = model.NewPointer(true)
|
||||
})
|
||||
|
||||
t.Run("with a valid text response", func(t *testing.T) {
|
||||
@@ -434,7 +434,7 @@ func TestDoCommandRequest(t *testing.T) {
|
||||
defer server.Close()
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
cfg.ServiceSettings.OutgoingIntegrationRequestsTimeout = model.NewInt64(1)
|
||||
cfg.ServiceSettings.OutgoingIntegrationRequestsTimeout = model.NewPointer(int64(1))
|
||||
})
|
||||
|
||||
_, _, err := th.App.DoCommandRequest(th.Context, &model.Command{URL: server.URL}, url.Values{})
|
||||
@@ -452,7 +452,7 @@ func TestDoCommandRequest(t *testing.T) {
|
||||
defer server.Close()
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
cfg.ServiceSettings.OutgoingIntegrationRequestsTimeout = model.NewInt64(2)
|
||||
cfg.ServiceSettings.OutgoingIntegrationRequestsTimeout = model.NewPointer(int64(2))
|
||||
})
|
||||
|
||||
_, resp, err := th.App.DoCommandRequest(th.Context, &model.Command{URL: server.URL}, url.Values{})
|
||||
@@ -466,7 +466,7 @@ func TestDoCommandRequest(t *testing.T) {
|
||||
outgoingOauthIface := &mocks.OutgoingOAuthConnectionInterface{}
|
||||
outgoingOauthImpl := th.App.Srv().OutgoingOAuthConnection
|
||||
outgoingOAuthConnectionConfig := th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections
|
||||
th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewBool(true)
|
||||
th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewPointer(true)
|
||||
t.Cleanup(func() {
|
||||
th.App.Srv().OutgoingOAuthConnection = outgoingOauthImpl
|
||||
th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = outgoingOAuthConnectionConfig
|
||||
|
||||
@@ -261,7 +261,7 @@ type ChannelOption func(*model.Channel)
|
||||
|
||||
func WithShared(v bool) ChannelOption {
|
||||
return func(channel *model.Channel) {
|
||||
channel.Shared = model.NewBool(v)
|
||||
channel.Shared = model.NewPointer(v)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ func TestGenerateSupportPacketYaml(t *testing.T) {
|
||||
|
||||
licenseUsers := 100
|
||||
license := model.NewTestLicense("ldap")
|
||||
license.Features.Users = model.NewInt(licenseUsers)
|
||||
license.Features.Users = model.NewPointer(licenseUsers)
|
||||
th.App.Srv().SetLicense(license)
|
||||
|
||||
generateSupportPacket := func(t *testing.T) *model.SupportPacket {
|
||||
@@ -126,7 +126,7 @@ func TestGenerateSupportPacketYaml(t *testing.T) {
|
||||
|
||||
t.Run("post count should be present if number of users extends AnalyticsSettings.MaxUsersForStatistics", func(t *testing.T) {
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
cfg.AnalyticsSettings.MaxUsersForStatistics = model.NewInt(1)
|
||||
cfg.AnalyticsSettings.MaxUsersForStatistics = model.NewPointer(1)
|
||||
})
|
||||
|
||||
for i := 0; i < 5; i++ {
|
||||
|
||||
@@ -61,9 +61,9 @@ func TestCreateDefaultMemberships(t *testing.T) {
|
||||
}
|
||||
|
||||
gleeGroup, err := th.App.CreateGroup(&model.Group{
|
||||
Name: model.NewString(model.NewId()),
|
||||
Name: model.NewPointer(model.NewId()),
|
||||
DisplayName: "Glee Club",
|
||||
RemoteId: model.NewString(model.NewId()),
|
||||
RemoteId: model.NewPointer(model.NewId()),
|
||||
Source: model.GroupSourceLdap,
|
||||
})
|
||||
if err != nil {
|
||||
@@ -71,9 +71,9 @@ func TestCreateDefaultMemberships(t *testing.T) {
|
||||
}
|
||||
|
||||
scienceGroup, err := th.App.CreateGroup(&model.Group{
|
||||
Name: model.NewString(model.NewId()),
|
||||
Name: model.NewPointer(model.NewId()),
|
||||
DisplayName: "Science Club",
|
||||
RemoteId: model.NewString(model.NewId()),
|
||||
RemoteId: model.NewPointer(model.NewId()),
|
||||
Source: model.GroupSourceLdap,
|
||||
})
|
||||
if err != nil {
|
||||
@@ -403,9 +403,9 @@ func TestCreateDefaultMemberships(t *testing.T) {
|
||||
}
|
||||
|
||||
group1, err := th.App.CreateGroup(&model.Group{
|
||||
Name: model.NewString(model.NewId()),
|
||||
Name: model.NewPointer(model.NewId()),
|
||||
DisplayName: "Group 1",
|
||||
RemoteId: model.NewString(model.NewId()),
|
||||
RemoteId: model.NewPointer(model.NewId()),
|
||||
Source: model.GroupSourceLdap,
|
||||
})
|
||||
if err != nil {
|
||||
@@ -549,14 +549,14 @@ func TestDeleteGroupMemberships(t *testing.T) {
|
||||
|
||||
// make team group-constrained
|
||||
team := th.BasicTeam
|
||||
team.GroupConstrained = model.NewBool(true)
|
||||
team.GroupConstrained = model.NewPointer(true)
|
||||
team, err = th.App.UpdateTeam(team)
|
||||
require.Nil(t, err)
|
||||
require.True(t, *team.GroupConstrained)
|
||||
|
||||
// make channel group-constrained
|
||||
channel := th.BasicChannel
|
||||
channel.GroupConstrained = model.NewBool(true)
|
||||
channel.GroupConstrained = model.NewPointer(true)
|
||||
channel, err = th.App.UpdateChannel(th.Context, channel)
|
||||
require.Nil(t, err)
|
||||
require.True(t, *channel.GroupConstrained)
|
||||
@@ -603,7 +603,7 @@ func TestSyncSyncableRoles(t *testing.T) {
|
||||
team := th.CreateTeam()
|
||||
|
||||
channel := th.CreateChannel(th.Context, team)
|
||||
channel.GroupConstrained = model.NewBool(true)
|
||||
channel.GroupConstrained = model.NewPointer(true)
|
||||
channel, err := th.App.UpdateChannel(th.Context, channel)
|
||||
require.Nil(t, err)
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ func TestAddUserToTeam(t *testing.T) {
|
||||
require.NotNil(t, err, "Should not add restricted user")
|
||||
require.Equal(t, "JoinUserToTeam", err.Where, "Error should be JoinUserToTeam")
|
||||
|
||||
user = model.User{Email: strings.ToLower(model.NewId()) + "test@invalid.com", Nickname: "Darth Vader", Username: "vader" + model.NewId(), AuthService: "notnil", AuthData: model.NewString("notnil")}
|
||||
user = model.User{Email: strings.ToLower(model.NewId()) + "test@invalid.com", Nickname: "Darth Vader", Username: "vader" + model.NewId(), AuthService: "notnil", AuthData: model.NewPointer("notnil")}
|
||||
ruser, err = th.App.CreateUser(th.Context, &user)
|
||||
require.Nil(t, err, "Error creating authservice user: %s", err)
|
||||
defer th.App.PermanentDeleteUser(th.Context, &user)
|
||||
@@ -381,7 +381,7 @@ func TestAddUserToTeamByToken(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("group-constrained team", func(t *testing.T) {
|
||||
th.BasicTeam.GroupConstrained = model.NewBool(true)
|
||||
th.BasicTeam.GroupConstrained = model.NewPointer(true)
|
||||
_, err := th.App.UpdateTeam(th.BasicTeam)
|
||||
require.Nil(t, err, "Should update the team")
|
||||
|
||||
@@ -395,7 +395,7 @@ func TestAddUserToTeamByToken(t *testing.T) {
|
||||
require.NotNil(t, err, "Should return an error when trying to join a group-constrained team.")
|
||||
require.Equal(t, "app.team.invite_token.group_constrained.error", err.Id)
|
||||
|
||||
th.BasicTeam.GroupConstrained = model.NewBool(false)
|
||||
th.BasicTeam.GroupConstrained = model.NewPointer(false)
|
||||
_, err = th.App.UpdateTeam(th.BasicTeam)
|
||||
require.Nil(t, err, "Should update the team")
|
||||
})
|
||||
@@ -964,7 +964,7 @@ func TestJoinUserToTeam(t *testing.T) {
|
||||
})
|
||||
require.Nil(t, err)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.TeamSettings.MaxUsersPerTeam = model.NewInt(999) })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.TeamSettings.MaxUsersPerTeam = model.NewPointer(999) })
|
||||
|
||||
tm1, appErr := th.App.JoinUserToTeam(th.Context, team, ruser1, "")
|
||||
require.Nil(t, appErr)
|
||||
@@ -1073,7 +1073,7 @@ func TestAppUpdateTeamScheme(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
|
||||
team := th.BasicTeam
|
||||
mockID := model.NewString("x")
|
||||
mockID := model.NewPointer("x")
|
||||
team.SchemeId = mockID
|
||||
|
||||
updatedTeam, err := th.App.UpdateTeamScheme(th.BasicTeam)
|
||||
|
||||
@@ -273,7 +273,7 @@ func (a *App) UploadData(c request.CTX, us *model.UploadSession, rd io.Reader) (
|
||||
info.CreatorId = us.UserId
|
||||
info.ChannelId = us.ChannelId
|
||||
info.Path = us.Path
|
||||
info.RemoteId = model.NewString(us.RemoteId)
|
||||
info.RemoteId = model.NewPointer(us.RemoteId)
|
||||
if us.ReqFileId != "" {
|
||||
info.Id = us.ReqFileId
|
||||
}
|
||||
|
||||
@@ -58,14 +58,14 @@ func TestCreateOAuthUser(t *testing.T) {
|
||||
dbUser := th.BasicUser
|
||||
|
||||
// mock oAuth Provider, return data
|
||||
mockUser := &model.User{Id: "abcdef", AuthData: model.NewString("e7110007-64be-43d8-9840-4a7e9c26b710"), Email: dbUser.Email}
|
||||
mockUser := &model.User{Id: "abcdef", AuthData: model.NewPointer("e7110007-64be-43d8-9840-4a7e9c26b710"), Email: dbUser.Email}
|
||||
providerMock := &mocks.OAuthProvider{}
|
||||
providerMock.On("IsSameUser", mock.AnythingOfType("*request.Context"), mock.Anything, mock.Anything).Return(true)
|
||||
providerMock.On("GetUserFromJSON", mock.AnythingOfType("*request.Context"), mock.Anything, mock.Anything).Return(mockUser, nil)
|
||||
einterfaces.RegisterOAuthProvider(model.ServiceOffice365, providerMock)
|
||||
|
||||
// Update user to be OAuth, formatting to match Office365 OAuth data
|
||||
s, er2 := th.App.Srv().Store().User().UpdateAuthData(dbUser.Id, model.ServiceOffice365, model.NewString("e711000764be43d898404a7e9c26b710"), "", false)
|
||||
s, er2 := th.App.Srv().Store().User().UpdateAuthData(dbUser.Id, model.ServiceOffice365, model.NewPointer("e711000764be43d898404a7e9c26b710"), "", false)
|
||||
assert.NoError(t, er2)
|
||||
assert.Equal(t, dbUser.Id, s)
|
||||
|
||||
@@ -1903,7 +1903,7 @@ func TestPatchUser(t *testing.T) {
|
||||
|
||||
t.Run("Patch with a username already exists", func(t *testing.T) {
|
||||
_, err := th.App.PatchUser(th.Context, testUser.Id, &model.UserPatch{
|
||||
Username: model.NewString(th.BasicUser.Username),
|
||||
Username: model.NewPointer(th.BasicUser.Username),
|
||||
}, true)
|
||||
|
||||
require.NotNil(t, err)
|
||||
@@ -1912,7 +1912,7 @@ func TestPatchUser(t *testing.T) {
|
||||
|
||||
t.Run("Patch with a email already exists", func(t *testing.T) {
|
||||
_, err := th.App.PatchUser(th.Context, testUser.Id, &model.UserPatch{
|
||||
Email: model.NewString(th.BasicUser.Email),
|
||||
Email: model.NewPointer(th.BasicUser.Email),
|
||||
}, true)
|
||||
|
||||
require.NotNil(t, err)
|
||||
@@ -1921,7 +1921,7 @@ func TestPatchUser(t *testing.T) {
|
||||
|
||||
t.Run("Patch username with a new username", func(t *testing.T) {
|
||||
u, err := th.App.PatchUser(th.Context, testUser.Id, &model.UserPatch{
|
||||
Username: model.NewString(model.NewUsername()),
|
||||
Username: model.NewPointer(model.NewUsername()),
|
||||
}, true)
|
||||
|
||||
require.Nil(t, err)
|
||||
|
||||
@@ -22,100 +22,100 @@ func TestIsPasswordValidWithSettings(t *testing.T) {
|
||||
"Short": {
|
||||
Password: strings.Repeat("x", 3),
|
||||
Settings: &model.PasswordSettings{
|
||||
MinimumLength: model.NewInt(3),
|
||||
Lowercase: model.NewBool(false),
|
||||
Uppercase: model.NewBool(false),
|
||||
Number: model.NewBool(false),
|
||||
Symbol: model.NewBool(false),
|
||||
MinimumLength: model.NewPointer(3),
|
||||
Lowercase: model.NewPointer(false),
|
||||
Uppercase: model.NewPointer(false),
|
||||
Number: model.NewPointer(false),
|
||||
Symbol: model.NewPointer(false),
|
||||
},
|
||||
},
|
||||
"Long": {
|
||||
Password: strings.Repeat("x", model.PasswordMaximumLength),
|
||||
Settings: &model.PasswordSettings{
|
||||
Lowercase: model.NewBool(false),
|
||||
Uppercase: model.NewBool(false),
|
||||
Number: model.NewBool(false),
|
||||
Symbol: model.NewBool(false),
|
||||
Lowercase: model.NewPointer(false),
|
||||
Uppercase: model.NewPointer(false),
|
||||
Number: model.NewPointer(false),
|
||||
Symbol: model.NewPointer(false),
|
||||
},
|
||||
},
|
||||
"TooShort": {
|
||||
Password: strings.Repeat("x", 2),
|
||||
Settings: &model.PasswordSettings{
|
||||
MinimumLength: model.NewInt(3),
|
||||
Lowercase: model.NewBool(false),
|
||||
Uppercase: model.NewBool(false),
|
||||
Number: model.NewBool(false),
|
||||
Symbol: model.NewBool(false),
|
||||
MinimumLength: model.NewPointer(3),
|
||||
Lowercase: model.NewPointer(false),
|
||||
Uppercase: model.NewPointer(false),
|
||||
Number: model.NewPointer(false),
|
||||
Symbol: model.NewPointer(false),
|
||||
},
|
||||
ExpectedError: "model.user.is_valid.pwd_min_length.app_error",
|
||||
},
|
||||
"TooLong": {
|
||||
Password: strings.Repeat("x", model.PasswordMaximumLength+1),
|
||||
Settings: &model.PasswordSettings{
|
||||
Lowercase: model.NewBool(false),
|
||||
Uppercase: model.NewBool(false),
|
||||
Number: model.NewBool(false),
|
||||
Symbol: model.NewBool(false),
|
||||
Lowercase: model.NewPointer(false),
|
||||
Uppercase: model.NewPointer(false),
|
||||
Number: model.NewPointer(false),
|
||||
Symbol: model.NewPointer(false),
|
||||
},
|
||||
ExpectedError: "model.user.is_valid.pwd_max_length.app_error",
|
||||
},
|
||||
"MissingLower": {
|
||||
Password: "AAAAAAAAAAASD123!@#",
|
||||
Settings: &model.PasswordSettings{
|
||||
Lowercase: model.NewBool(true),
|
||||
Uppercase: model.NewBool(false),
|
||||
Number: model.NewBool(false),
|
||||
Symbol: model.NewBool(false),
|
||||
Lowercase: model.NewPointer(true),
|
||||
Uppercase: model.NewPointer(false),
|
||||
Number: model.NewPointer(false),
|
||||
Symbol: model.NewPointer(false),
|
||||
},
|
||||
ExpectedError: "model.user.is_valid.pwd_lowercase.app_error",
|
||||
},
|
||||
"MissingUpper": {
|
||||
Password: "aaaaaaaaaaaaasd123!@#",
|
||||
Settings: &model.PasswordSettings{
|
||||
Uppercase: model.NewBool(true),
|
||||
Lowercase: model.NewBool(false),
|
||||
Number: model.NewBool(false),
|
||||
Symbol: model.NewBool(false),
|
||||
Uppercase: model.NewPointer(true),
|
||||
Lowercase: model.NewPointer(false),
|
||||
Number: model.NewPointer(false),
|
||||
Symbol: model.NewPointer(false),
|
||||
},
|
||||
ExpectedError: "model.user.is_valid.pwd_uppercase.app_error",
|
||||
},
|
||||
"MissingNumber": {
|
||||
Password: "asasdasdsadASD!@#",
|
||||
Settings: &model.PasswordSettings{
|
||||
Number: model.NewBool(true),
|
||||
Lowercase: model.NewBool(false),
|
||||
Uppercase: model.NewBool(false),
|
||||
Symbol: model.NewBool(false),
|
||||
Number: model.NewPointer(true),
|
||||
Lowercase: model.NewPointer(false),
|
||||
Uppercase: model.NewPointer(false),
|
||||
Symbol: model.NewPointer(false),
|
||||
},
|
||||
ExpectedError: "model.user.is_valid.pwd_number.app_error",
|
||||
},
|
||||
"MissingSymbol": {
|
||||
Password: "asdasdasdasdasdASD123",
|
||||
Settings: &model.PasswordSettings{
|
||||
Symbol: model.NewBool(true),
|
||||
Lowercase: model.NewBool(false),
|
||||
Uppercase: model.NewBool(false),
|
||||
Number: model.NewBool(false),
|
||||
Symbol: model.NewPointer(true),
|
||||
Lowercase: model.NewPointer(false),
|
||||
Uppercase: model.NewPointer(false),
|
||||
Number: model.NewPointer(false),
|
||||
},
|
||||
ExpectedError: "model.user.is_valid.pwd_symbol.app_error",
|
||||
},
|
||||
"MissingMultiple": {
|
||||
Password: "asdasdasdasdasdasd",
|
||||
Settings: &model.PasswordSettings{
|
||||
Lowercase: model.NewBool(true),
|
||||
Uppercase: model.NewBool(true),
|
||||
Number: model.NewBool(true),
|
||||
Symbol: model.NewBool(true),
|
||||
Lowercase: model.NewPointer(true),
|
||||
Uppercase: model.NewPointer(true),
|
||||
Number: model.NewPointer(true),
|
||||
Symbol: model.NewPointer(true),
|
||||
},
|
||||
ExpectedError: "model.user.is_valid.pwd_lowercase_uppercase_number_symbol.app_error",
|
||||
},
|
||||
"Everything": {
|
||||
Password: "asdASD!@#123",
|
||||
Settings: &model.PasswordSettings{
|
||||
Lowercase: model.NewBool(true),
|
||||
Uppercase: model.NewBool(true),
|
||||
Number: model.NewBool(true),
|
||||
Symbol: model.NewBool(true),
|
||||
Lowercase: model.NewPointer(true),
|
||||
Uppercase: model.NewPointer(true),
|
||||
Number: model.NewPointer(true),
|
||||
Symbol: model.NewPointer(true),
|
||||
},
|
||||
},
|
||||
} {
|
||||
|
||||
@@ -397,19 +397,19 @@ func TestCreateWebhookPostWithPriority(t *testing.T) {
|
||||
|
||||
testConditions := []model.PostPriority{
|
||||
{
|
||||
Priority: model.NewString("high"),
|
||||
RequestedAck: model.NewBool(true),
|
||||
PersistentNotifications: model.NewBool(false),
|
||||
Priority: model.NewPointer("high"),
|
||||
RequestedAck: model.NewPointer(true),
|
||||
PersistentNotifications: model.NewPointer(false),
|
||||
},
|
||||
{
|
||||
Priority: model.NewString(""),
|
||||
RequestedAck: model.NewBool(true),
|
||||
PersistentNotifications: model.NewBool(false),
|
||||
Priority: model.NewPointer(""),
|
||||
RequestedAck: model.NewPointer(true),
|
||||
PersistentNotifications: model.NewPointer(false),
|
||||
},
|
||||
{
|
||||
Priority: model.NewString("urgent"),
|
||||
RequestedAck: model.NewBool(false),
|
||||
PersistentNotifications: model.NewBool(true),
|
||||
Priority: model.NewPointer("urgent"),
|
||||
RequestedAck: model.NewPointer(false),
|
||||
PersistentNotifications: model.NewPointer(true),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -917,7 +917,7 @@ func TestDoOutgoingWebhookRequest(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
cfg.ServiceSettings.AllowedUntrustedInternalConnections = model.NewString("127.0.0.1")
|
||||
cfg.ServiceSettings.AllowedUntrustedInternalConnections = model.NewPointer("127.0.0.1")
|
||||
*cfg.ServiceSettings.EnableOutgoingWebhooks = true
|
||||
})
|
||||
|
||||
@@ -979,7 +979,7 @@ func TestDoOutgoingWebhookRequest(t *testing.T) {
|
||||
defer close(releaseHandler)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
cfg.ServiceSettings.OutgoingIntegrationRequestsTimeout = model.NewInt64(1)
|
||||
cfg.ServiceSettings.OutgoingIntegrationRequestsTimeout = model.NewPointer(int64(1))
|
||||
})
|
||||
|
||||
_, err := th.App.doOutgoingWebhookRequest(server.URL, strings.NewReader(""), "application/json", nil)
|
||||
@@ -996,7 +996,7 @@ func TestDoOutgoingWebhookRequest(t *testing.T) {
|
||||
defer server.Close()
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
cfg.ServiceSettings.OutgoingIntegrationRequestsTimeout = model.NewInt64(2)
|
||||
cfg.ServiceSettings.OutgoingIntegrationRequestsTimeout = model.NewPointer(int64(2))
|
||||
})
|
||||
|
||||
resp, err := th.App.doOutgoingWebhookRequest(server.URL, strings.NewReader(""), "application/json", nil)
|
||||
|
||||
Ссылка в новой задаче
Block a user