OSF: Used model.NewPointer everywhere (#27838)

```release-note
NONE
```
This commit is contained in:
Agniva De Sarker 2024-08-06 09:15:00 +05:30 committed by GitHub
parent f290745496
commit c3ed07e679
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
148 changed files with 2341 additions and 2338 deletions

View File

@ -95,7 +95,7 @@ func setupTestHelper(dbStore store.Store, searchEngine *searchengine.Broker, ent
memoryConfig.SetDefaults()
*memoryConfig.PluginSettings.Directory = filepath.Join(tempWorkspace, "plugins")
*memoryConfig.PluginSettings.ClientDirectory = filepath.Join(tempWorkspace, "webapp")
memoryConfig.ServiceSettings.EnableLocalMode = model.NewBool(true)
memoryConfig.ServiceSettings.EnableLocalMode = model.NewPointer(true)
*memoryConfig.ServiceSettings.LocalModeSocketLocation = filepath.Join(tempWorkspace, "mattermost_local.sock")
*memoryConfig.LogSettings.EnableSentry = false // disable error reporting during tests
*memoryConfig.LogSettings.ConsoleLevel = mlog.LvlStdLog.Name
@ -866,7 +866,7 @@ func (th *TestHelper) CreateDmChannel(user *model.User) *model.Channel {
func (th *TestHelper) PatchChannelModerationsForMembers(channelId, name string, val bool) {
patch := []*model.ChannelModerationPatch{{
Name: &name,
Roles: &model.ChannelModeratedRolesPatch{Members: model.NewBool(val)},
Roles: &model.ChannelModeratedRolesPatch{Members: model.NewPointer(val)},
}}
channel, err := th.App.GetChannel(th.Context, channelId)
@ -981,10 +981,10 @@ func (th *TestHelper) GenerateTestEmail() string {
func (th *TestHelper) CreateGroup() *model.Group {
id := model.NewId()
group := &model.Group{
Name: model.NewString("n-" + id),
Name: model.NewPointer("n-" + id),
DisplayName: "dn_" + id,
Source: model.GroupSourceLdap,
RemoteId: model.NewString("ri_" + model.NewId()),
RemoteId: model.NewPointer("ri_" + model.NewId()),
}
group, err := th.App.CreateGroup(group)

View File

@ -39,7 +39,7 @@ func TestCreateBot(t *testing.T) {
th.AddPermissionToRole(model.PermissionCreateBot.Id, model.TeamUserRoleId)
th.App.UpdateUserRoles(th.Context, th.BasicUser.Id, model.TeamUserRoleId, false)
th.App.Config().ServiceSettings.EnableBotAccountCreation = model.NewBool(false)
th.App.Config().ServiceSettings.EnableBotAccountCreation = model.NewPointer(false)
_, _, err := th.Client.CreateBot(context.Background(), &model.Bot{
Username: GenerateTestUsername(),
@ -1351,7 +1351,7 @@ func TestConvertBotToUser(t *testing.T) {
require.Error(t, err)
CheckBadRequestStatus(t, resp)
user, resp, err := th.Client.ConvertBotToUser(context.Background(), bot.UserId, &model.UserPatch{Password: model.NewString("password")}, false)
user, resp, err := th.Client.ConvertBotToUser(context.Background(), bot.UserId, &model.UserPatch{Password: model.NewPointer("password")}, false)
require.Error(t, err)
CheckForbiddenStatus(t, resp)
require.Nil(t, user)
@ -1370,7 +1370,7 @@ func TestConvertBotToUser(t *testing.T) {
CheckBadRequestStatus(t, resp)
require.Nil(t, user)
user, _, err = client.ConvertBotToUser(context.Background(), bot.UserId, &model.UserPatch{Password: model.NewString("password")}, false)
user, _, err = client.ConvertBotToUser(context.Background(), bot.UserId, &model.UserPatch{Password: model.NewPointer("password")}, false)
require.NoError(t, err)
require.NotNil(t, user)
require.Equal(t, bot.UserId, user.Id)
@ -1387,7 +1387,7 @@ func TestConvertBotToUser(t *testing.T) {
require.NoError(t, err)
CheckCreatedStatus(t, resp)
user, _, err = client.ConvertBotToUser(context.Background(), bot.UserId, &model.UserPatch{Password: model.NewString("password")}, true)
user, _, err = client.ConvertBotToUser(context.Background(), bot.UserId, &model.UserPatch{Password: model.NewPointer("password")}, true)
require.NoError(t, err)
require.NotNil(t, user)
require.Equal(t, bot.UserId, user.Id)

View File

@ -353,8 +353,8 @@ func TestEditChannelBookmark(t *testing.T) {
require.NotNil(t, cb)
patch := &model.ChannelBookmarkPatch{
DisplayName: model.NewString("Edited bookmark test"),
LinkUrl: model.NewString("http://edited.url"),
DisplayName: model.NewPointer("Edited bookmark test"),
LinkUrl: model.NewPointer("http://edited.url"),
}
ucb, resp, err := tc.userClient.UpdateChannelBookmark(context.Background(), cb.ChannelId, cb.Id, patch)
@ -394,8 +394,8 @@ func TestEditChannelBookmark(t *testing.T) {
// try to patch the channel bookmark
patch := &model.ChannelBookmarkPatch{
DisplayName: model.NewString("Edited bookmark test"),
LinkUrl: model.NewString("http://edited.url"),
DisplayName: model.NewPointer("Edited bookmark test"),
LinkUrl: model.NewPointer("http://edited.url"),
}
ucb, resp, err := th.Client.UpdateChannelBookmark(context.Background(), cb.ChannelId, cb.Id, patch)
@ -406,8 +406,8 @@ func TestEditChannelBookmark(t *testing.T) {
t.Run("trying to edit a nonexistent bookmark should fail", func(t *testing.T) {
patch := &model.ChannelBookmarkPatch{
DisplayName: model.NewString("Edited bookmark test"),
LinkUrl: model.NewString("http://edited.url"),
DisplayName: model.NewPointer("Edited bookmark test"),
LinkUrl: model.NewPointer("http://edited.url"),
}
ucb, resp, err := th.Client.UpdateChannelBookmark(context.Background(), th.BasicChannel.Id, model.NewId(), patch)
@ -434,8 +434,8 @@ func TestEditChannelBookmark(t *testing.T) {
require.Nil(t, appErr)
patch := &model.ChannelBookmarkPatch{
DisplayName: model.NewString("Edited bookmark test"),
LinkUrl: model.NewString("http://edited.url"),
DisplayName: model.NewPointer("Edited bookmark test"),
LinkUrl: model.NewPointer("http://edited.url"),
}
ucb, resp, err := th.Client.UpdateChannelBookmark(context.Background(), cb.ChannelId, cb.Id, patch)
@ -471,8 +471,8 @@ func TestEditChannelBookmark(t *testing.T) {
require.NotNil(t, cb)
patch := &model.ChannelBookmarkPatch{
DisplayName: model.NewString("Edited bookmark test"),
LinkUrl: model.NewString("http://edited.url"),
DisplayName: model.NewPointer("Edited bookmark test"),
LinkUrl: model.NewPointer("http://edited.url"),
}
ucb, resp, err := th.Client.UpdateChannelBookmark(context.Background(), cb.ChannelId, cb.Id, patch)
@ -521,8 +521,8 @@ func TestEditChannelBookmark(t *testing.T) {
require.NotNil(t, cb)
patch := &model.ChannelBookmarkPatch{
DisplayName: model.NewString("Edited bookmark test"),
LinkUrl: model.NewString("http://edited.url"),
DisplayName: model.NewPointer("Edited bookmark test"),
LinkUrl: model.NewPointer("http://edited.url"),
}
ucb, resp, err := guestClient.UpdateChannelBookmark(context.Background(), cb.ChannelId, cb.Id, patch)
@ -561,8 +561,8 @@ func TestEditChannelBookmark(t *testing.T) {
require.NotNil(t, cb)
patch := &model.ChannelBookmarkPatch{
DisplayName: model.NewString("Edited bookmark test"),
LinkUrl: model.NewString("http://edited.url"),
DisplayName: model.NewPointer("Edited bookmark test"),
LinkUrl: model.NewPointer("http://edited.url"),
}
// create a client for basic user 2
@ -611,7 +611,7 @@ func TestEditChannelBookmark(t *testing.T) {
require.Nil(t, appErr)
require.NotNil(t, cb)
patch := &model.ChannelBookmarkPatch{DisplayName: model.NewString("Edited bookmark test")}
patch := &model.ChannelBookmarkPatch{DisplayName: model.NewPointer("Edited bookmark test")}
_, resp, err := th.Client.UpdateChannelBookmark(context.Background(), cb.ChannelId, cb.Id, patch)
require.NoError(t, err)
CheckOKStatus(t, resp)

View File

@ -139,7 +139,7 @@ func TestCreateChannel(t *testing.T) {
require.Equal(t, http.StatusBadRequest, r.StatusCode, "Expected 400 Bad Request")
// Test GroupConstrained flag
groupConstrainedChannel := &model.Channel{DisplayName: "Test API Name", Name: GenerateTestChannelName(), Type: model.ChannelTypeOpen, TeamId: team.Id, GroupConstrained: model.NewBool(true)}
groupConstrainedChannel := &model.Channel{DisplayName: "Test API Name", Name: GenerateTestChannelName(), Type: model.ChannelTypeOpen, TeamId: team.Id, GroupConstrained: model.NewPointer(true)}
rchannel, _, err = client.CreateChannel(context.Background(), groupConstrainedChannel)
require.NoError(t, err)
@ -187,7 +187,7 @@ func TestUpdateChannel(t *testing.T) {
require.Equal(t, channel.Purpose, newChannel.Purpose, "Update failed for Purpose")
// Test GroupConstrained flag
channel.GroupConstrained = model.NewBool(true)
channel.GroupConstrained = model.NewPointer(true)
rchannel, resp, err := client.UpdateChannel(context.Background(), channel)
require.NoError(t, err)
CheckOKStatus(t, resp)
@ -386,7 +386,7 @@ func TestPatchChannel(t *testing.T) {
CheckBadRequestStatus(t, resp)
// Test GroupConstrained flag
patch.GroupConstrained = model.NewBool(true)
patch.GroupConstrained = model.NewPointer(true)
rchannel, resp, err := client.PatchChannel(context.Background(), th.BasicChannel.Id, patch)
require.NoError(t, err)
CheckOKStatus(t, resp)
@ -1351,7 +1351,7 @@ func TestGetAllChannels(t *testing.T) {
policy, err := th.App.Srv().Store().RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{
RetentionPolicy: model.RetentionPolicy{
DisplayName: "Policy 1",
PostDurationDays: model.NewInt64(30),
PostDurationDays: model.NewPointer(int64(30)),
},
ChannelIDs: []string{policyChannel.Id},
})
@ -1698,7 +1698,7 @@ func TestSearchAllChannels(t *testing.T) {
DisplayName: "SearchAllChannels-groupConstrained-1",
Name: "groupconstrained1",
Type: model.ChannelTypePrivate,
GroupConstrained: model.NewBool(true),
GroupConstrained: model.NewPointer(true),
TeamId: team.Id,
})
require.NoError(t, err)
@ -1853,7 +1853,7 @@ func TestSearchAllChannels(t *testing.T) {
policy, savePolicyErr := th.App.Srv().Store().RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{
RetentionPolicy: model.RetentionPolicy{
DisplayName: "Policy 1",
PostDurationDays: model.NewInt64(30),
PostDurationDays: model.NewPointer(int64(30)),
},
ChannelIDs: []string{policyChannel.Id},
})
@ -1896,8 +1896,8 @@ func TestSearchAllChannelsPaged(t *testing.T) {
search := &model.ChannelSearch{Term: th.BasicChannel.Name}
search.Term = ""
search.Page = model.NewInt(0)
search.PerPage = model.NewInt(2)
search.Page = model.NewPointer(0)
search.PerPage = model.NewPointer(2)
channelsWithCount, _, err := th.SystemAdminClient.SearchAllChannelsPaged(context.Background(), search)
require.NoError(t, err)
require.Len(t, channelsWithCount.Channels, 2)
@ -3369,7 +3369,7 @@ func TestAddChannelMember(t *testing.T) {
client.Logout(context.Background())
// Set a channel to group-constrained
privateChannel.GroupConstrained = model.NewBool(true)
privateChannel.GroupConstrained = model.NewPointer(true)
_, appErr := th.App.UpdateChannel(th.Context, privateChannel)
require.Nil(t, appErr)
@ -3780,7 +3780,7 @@ func TestRemoveChannelMember(t *testing.T) {
require.NoError(t, err)
// If the channel is group-constrained the user cannot be removed
privateChannel.GroupConstrained = model.NewBool(true)
privateChannel.GroupConstrained = model.NewPointer(true)
_, appErr := th.App.UpdateChannel(th.Context, privateChannel)
require.Nil(t, appErr)
_, err = client.RemoveUserFromChannel(context.Background(), privateChannel.Id, user2.Id)
@ -4272,7 +4272,7 @@ func TestChannelMembersMinusGroupMembers(t *testing.T) {
_, appErr = th.App.AddChannelMember(th.Context, user2.Id, channel, app.ChannelMemberOpts{})
require.Nil(t, appErr)
channel.GroupConstrained = model.NewBool(true)
channel.GroupConstrained = model.NewPointer(true)
channel, appErr = th.App.UpdateChannel(th.Context, channel)
require.Nil(t, appErr)
@ -4615,7 +4615,7 @@ func TestPatchChannelModerations(t *testing.T) {
patch := []*model.ChannelModerationPatch{
{
Name: &createPosts,
Roles: &model.ChannelModeratedRolesPatch{Members: model.NewBool(false)},
Roles: &model.ChannelModeratedRolesPatch{Members: model.NewPointer(false)},
},
}
@ -4652,7 +4652,7 @@ func TestPatchChannelModerations(t *testing.T) {
patch := []*model.ChannelModerationPatch{
{
Name: &createPosts,
Roles: &model.ChannelModeratedRolesPatch{Members: model.NewBool(true)},
Roles: &model.ChannelModeratedRolesPatch{Members: model.NewPointer(true)},
},
}
@ -4729,7 +4729,7 @@ func TestPatchChannelModerations(t *testing.T) {
patch := []*model.ChannelModerationPatch{
{
Name: &createPosts,
Roles: &model.ChannelModeratedRolesPatch{Members: model.NewBool(true)},
Roles: &model.ChannelModeratedRolesPatch{Members: model.NewPointer(true)},
},
}
@ -4814,9 +4814,9 @@ func TestGetChannelMemberCountsByGroup(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()),
}
_, appErr = th.App.CreateGroup(group)

View File

@ -1130,8 +1130,8 @@ func TestExecuteCommandReadOnly(t *testing.T) {
[]*model.ChannelModerationPatch{{
Name: &model.PermissionCreatePost.Id,
Roles: &model.ChannelModeratedRolesPatch{
Guests: model.NewBool(false),
Members: model.NewBool(false),
Guests: model.NewPointer(false),
Members: model.NewPointer(false),
},
}})
require.Nil(t, appErr)

View File

@ -178,8 +178,8 @@ func TestUpdateConfig(t *testing.T) {
t.Run("Should fail with validation error if invalid config setting is passed", func(t *testing.T) {
//Revert the change
badcfg := cfg.Clone()
badcfg.PasswordSettings.MinimumLength = model.NewInt(4)
badcfg.PasswordSettings.MinimumLength = model.NewInt(4)
badcfg.PasswordSettings.MinimumLength = model.NewPointer(4)
badcfg.PasswordSettings.MinimumLength = model.NewPointer(4)
_, resp, err = client.UpdateConfig(context.Background(), badcfg)
require.Error(t, err)
CheckBadRequestStatus(t, resp)
@ -496,11 +496,11 @@ func TestUpdateConfigDiffInAuditRecord(t *testing.T) {
require.NoError(t, err)
timeoutVal := *cfg.ServiceSettings.ReadTimeout
cfg.ServiceSettings.ReadTimeout = model.NewInt(timeoutVal + 1)
cfg.ServiceSettings.ReadTimeout = model.NewPointer(timeoutVal + 1)
cfg, _, err = th.SystemAdminClient.UpdateConfig(context.Background(), cfg)
require.NoError(t, err)
defer th.App.UpdateConfig(func(cfg *model.Config) {
cfg.ServiceSettings.ReadTimeout = model.NewInt(timeoutVal)
cfg.ServiceSettings.ReadTimeout = model.NewPointer(timeoutVal)
})
require.Equal(t, timeoutVal+1, *cfg.ServiceSettings.ReadTimeout)
@ -642,7 +642,7 @@ func TestPatchConfig(t *testing.T) {
// Ensure ConsoleLevel is set to DEBUG
config := model.Config{LogSettings: model.LogSettings{
ConsoleLevel: model.NewString("DEBUG"),
ConsoleLevel: model.NewPointer("DEBUG"),
}}
_, _, err := th.SystemAdminClient.PatchConfig(context.Background(), &config)
require.NoError(t, err)
@ -663,7 +663,7 @@ func TestPatchConfig(t *testing.T) {
*th.App.Config().ExperimentalSettings.RestrictSystemAdmin = true
config := model.Config{LogSettings: model.LogSettings{
ConsoleLevel: model.NewString("INFO"),
ConsoleLevel: model.NewPointer("INFO"),
}}
updatedConfig, _, _ := th.SystemAdminClient.PatchConfig(context.Background(), &config)
@ -675,7 +675,7 @@ func TestPatchConfig(t *testing.T) {
*th.App.Config().ExperimentalSettings.RestrictSystemAdmin = true
config := model.Config{LogSettings: model.LogSettings{
ConsoleLevel: model.NewString("INFO"),
ConsoleLevel: model.NewPointer("INFO"),
}}
oldConfig, _, _ := th.LocalClient.GetConfig(context.Background())
@ -690,7 +690,7 @@ func TestPatchConfig(t *testing.T) {
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
t.Run("check if config is valid", func(t *testing.T) {
config := model.Config{PasswordSettings: model.PasswordSettings{
MinimumLength: model.NewInt(4),
MinimumLength: model.NewPointer(4),
}}
_, response, err := client.PatchConfig(context.Background(), &config)
@ -713,12 +713,12 @@ func TestPatchConfig(t *testing.T) {
assert.True(t, oldConfig.PluginSettings.PluginStates["com.mattermost.nps"].Enable)
states := make(map[string]*model.PluginState)
states["com.mattermost.nps"] = &model.PluginState{Enable: *model.NewBool(false)}
states["com.mattermost.nps"] = &model.PluginState{Enable: *model.NewPointer(false)}
config := model.Config{PasswordSettings: model.PasswordSettings{
Lowercase: model.NewBool(true),
MinimumLength: model.NewInt(15),
Lowercase: model.NewPointer(true),
MinimumLength: model.NewPointer(15),
}, LogSettings: model.LogSettings{
ConsoleLevel: model.NewString("INFO"),
ConsoleLevel: model.NewPointer("INFO"),
},
TeamSettings: model.TeamSettings{
ExperimentalDefaultChannels: []string{"another-channel"},
@ -746,7 +746,7 @@ func TestPatchConfig(t *testing.T) {
t.Run("should sanitize config", func(t *testing.T) {
config := model.Config{PasswordSettings: model.PasswordSettings{
Symbol: model.NewBool(true),
Symbol: model.NewPointer(true),
}}
updatedConfig, _, err := client.PatchConfig(context.Background(), &config)
@ -757,7 +757,7 @@ func TestPatchConfig(t *testing.T) {
t.Run("not allowing to toggle enable uploads for plugin via api", func(t *testing.T) {
config := model.Config{PluginSettings: model.PluginSettings{
EnableUploads: model.NewBool(true),
EnableUploads: model.NewPointer(true),
}}
updatedConfig, resp, err := client.PatchConfig(context.Background(), &config)
@ -810,7 +810,7 @@ func TestPatchConfig(t *testing.T) {
nonEmptyURL := "http://localhost"
config := model.Config{
ServiceSettings: model.ServiceSettings{
SiteURL: model.NewString(nonEmptyURL),
SiteURL: model.NewPointer(nonEmptyURL),
},
}
updatedConfig, _, err := th.SystemAdminClient.PatchConfig(context.Background(), &config)
@ -820,7 +820,7 @@ func TestPatchConfig(t *testing.T) {
// Check that the Site URL can't be cleared
config = model.Config{
ServiceSettings: model.ServiceSettings{
SiteURL: model.NewString(""),
SiteURL: model.NewPointer(""),
},
}
_, resp, err := th.SystemAdminClient.PatchConfig(context.Background(), &config)

View File

@ -243,8 +243,8 @@ func searchTeamsInPolicy(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
props.PolicyID = model.NewString(c.Params.PolicyId)
props.IncludePolicyID = model.NewBool(true)
props.PolicyID = model.NewPointer(c.Params.PolicyId)
props.IncludePolicyID = model.NewPointer(true)
teams, _, appErr := c.App.SearchAllTeams(&props)
if appErr != nil {

View File

@ -30,7 +30,7 @@ func testElasticsearch(c *Context, w http.ResponseWriter, r *http.Request) {
// we set BulkIndexingTimeWindowSeconds to a random value to avoid failing on the nil check
// TODO: remove this hack once we remove BulkIndexingTimeWindowSeconds from the config.
if cfg.ElasticsearchSettings.BulkIndexingTimeWindowSeconds == nil {
cfg.ElasticsearchSettings.BulkIndexingTimeWindowSeconds = model.NewInt(0)
cfg.ElasticsearchSettings.BulkIndexingTimeWindowSeconds = model.NewPointer(0)
}
if checkHasNilFields(&cfg.ElasticsearchSettings) {
c.Err = model.NewAppError("testElasticsearch", "api.elasticsearch.test_elasticsearch_settings_nil.app_error", nil, "", http.StatusBadRequest)

View File

@ -23,10 +23,10 @@ func TestGetGroup(t *testing.T) {
id := model.NewId()
g, appErr := th.App.CreateGroup(&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()),
})
assert.Nil(t, appErr)
@ -72,7 +72,7 @@ func TestCreateGroup(t *testing.T) {
id := model.NewId()
g := &model.Group{
DisplayName: "dn_" + id,
Name: model.NewString("name" + id),
Name: model.NewPointer("name" + id),
Source: model.GroupSourceCustom,
Description: "description_" + id,
AllowReference: true,
@ -95,7 +95,7 @@ func TestCreateGroup(t *testing.T) {
gbroken := &model.Group{
DisplayName: "dn_" + id,
Name: model.NewString("name" + id),
Name: model.NewPointer("name" + id),
Source: "rrrr",
Description: "description_" + id,
}
@ -106,7 +106,7 @@ func TestCreateGroup(t *testing.T) {
validGroup := &model.Group{
DisplayName: "dn_" + model.NewId(),
Name: model.NewString("name" + model.NewId()),
Name: model.NewPointer("name" + model.NewId()),
Source: model.GroupSourceCustom,
AllowReference: true,
}
@ -135,7 +135,7 @@ func TestCreateGroup(t *testing.T) {
unReferenceableCustomGroup := &model.Group{
DisplayName: "dn_" + model.NewId(),
Name: model.NewString("name" + model.NewId()),
Name: model.NewPointer("name" + model.NewId()),
Source: model.GroupSourceCustom,
AllowReference: false,
}
@ -149,10 +149,10 @@ func TestCreateGroup(t *testing.T) {
customGroupWithRemoteID := &model.Group{
DisplayName: "dn_" + model.NewId(),
Name: model.NewString("name" + model.NewId()),
Name: model.NewPointer("name" + model.NewId()),
Source: model.GroupSourceCustom,
AllowReference: true,
RemoteId: model.NewString(model.NewId()),
RemoteId: model.NewPointer(model.NewId()),
}
_, response, err = th.SystemAdminClient.CreateGroup(context.Background(), customGroupWithRemoteID)
require.Error(t, err)
@ -160,7 +160,7 @@ func TestCreateGroup(t *testing.T) {
reservedNameGroup := &model.Group{
DisplayName: "dn_" + model.NewId(),
Name: model.NewString("here"),
Name: model.NewPointer("here"),
Source: model.GroupSourceCustom,
AllowReference: true,
}
@ -181,10 +181,10 @@ func TestDeleteGroup(t *testing.T) {
id := model.NewId()
g, appErr := th.App.CreateGroup(&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()),
})
assert.Nil(t, appErr)
@ -209,7 +209,7 @@ func TestDeleteGroup(t *testing.T) {
validGroup, appErr := th.App.CreateGroup(&model.Group{
DisplayName: "dn_" + model.NewId(),
Name: model.NewString("name" + model.NewId()),
Name: model.NewPointer("name" + model.NewId()),
Source: model.GroupSourceCustom,
})
assert.Nil(t, appErr)
@ -227,7 +227,7 @@ func TestUndeleteGroup(t *testing.T) {
validGroup, appErr := th.App.CreateGroup(&model.Group{
DisplayName: "dn_" + model.NewId(),
Name: model.NewString("name" + model.NewId()),
Name: model.NewPointer("name" + model.NewId()),
Source: model.GroupSourceCustom,
})
assert.Nil(t, appErr)
@ -258,16 +258,16 @@ func TestPatchGroup(t *testing.T) {
id := model.NewId()
g, appErr := th.App.CreateGroup(&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()),
})
assert.Nil(t, appErr)
g2, appErr := th.App.CreateGroup(&model.Group{
DisplayName: "dn_" + model.NewId(),
Name: model.NewString("name" + model.NewId()),
Name: model.NewPointer("name" + model.NewId()),
Source: model.GroupSourceCustom,
AllowReference: true,
})
@ -325,24 +325,24 @@ func TestPatchGroup(t *testing.T) {
CheckNotFoundStatus(t, response)
_, response, err = th.SystemAdminClient.PatchGroup(context.Background(), g2.Id, &model.GroupPatch{
Name: model.NewString(model.NewId()),
DisplayName: model.NewString("foo"),
AllowReference: model.NewBool(false),
Name: model.NewPointer(model.NewId()),
DisplayName: model.NewPointer("foo"),
AllowReference: model.NewPointer(false),
})
require.Error(t, err)
CheckBadRequestStatus(t, response)
// ensure that omitting the AllowReference field from the patch doesn't patch it to false
patchedG2, response, err := th.SystemAdminClient.PatchGroup(context.Background(), g2.Id, &model.GroupPatch{
Name: model.NewString(model.NewId()),
DisplayName: model.NewString("foo"),
Name: model.NewPointer(model.NewId()),
DisplayName: model.NewPointer("foo"),
})
require.NoError(t, err)
CheckOKStatus(t, response)
require.Equal(t, true, patchedG2.AllowReference)
_, response, err = th.SystemAdminClient.PatchGroup(context.Background(), g2.Id, &model.GroupPatch{
Name: model.NewString("here"),
Name: model.NewPointer("here"),
})
require.Error(t, err)
CheckBadRequestStatus(t, response)
@ -360,26 +360,26 @@ func TestLinkGroupTeam(t *testing.T) {
id := model.NewId()
g, appErr := th.App.CreateGroup(&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()),
})
assert.Nil(t, appErr)
id = model.NewId()
gRef, appErr := th.App.CreateGroup(&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()),
AllowReference: true,
})
assert.Nil(t, appErr)
patch := &model.GroupSyncablePatch{
AutoAdd: model.NewBool(true),
AutoAdd: model.NewPointer(true),
}
t.Run("Error if no license is installed", func(t *testing.T) {
@ -451,10 +451,10 @@ func TestLinkGroupTeam(t *testing.T) {
gid := model.NewId()
gCustom, appErr := th.App.CreateGroup(&model.Group{
DisplayName: "dn_" + gid,
Name: model.NewString("name" + gid),
Name: model.NewPointer("name" + gid),
Source: model.GroupSourceCustom,
Description: "description_" + gid,
RemoteId: model.NewString(model.NewId()),
RemoteId: model.NewPointer(model.NewId()),
})
assert.Nil(t, appErr)
@ -472,26 +472,26 @@ func TestLinkGroupChannel(t *testing.T) {
id := model.NewId()
g, appErr := th.App.CreateGroup(&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()),
})
assert.Nil(t, appErr)
id = model.NewId()
gRef, appErr := th.App.CreateGroup(&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()),
AllowReference: true,
})
assert.Nil(t, appErr)
patch := &model.GroupSyncablePatch{
AutoAdd: model.NewBool(true),
AutoAdd: model.NewPointer(true),
}
t.Run("Error if no license is installed", func(t *testing.T) {
@ -575,10 +575,10 @@ func TestLinkGroupChannel(t *testing.T) {
gid := model.NewId()
g2, appErr := th.App.CreateGroup(&model.Group{
DisplayName: "dn_" + gid,
Name: model.NewString("name" + gid),
Name: model.NewPointer("name" + gid),
Source: model.GroupSourceCustom,
Description: "description_" + gid,
RemoteId: model.NewString(model.NewId()),
RemoteId: model.NewPointer(model.NewId()),
})
assert.Nil(t, appErr)
@ -596,26 +596,26 @@ func TestUnlinkGroupTeam(t *testing.T) {
id := model.NewId()
g, appErr := th.App.CreateGroup(&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()),
})
assert.Nil(t, appErr)
id = model.NewId()
gRef, appErr := th.App.CreateGroup(&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()),
AllowReference: true,
})
assert.Nil(t, appErr)
patch := &model.GroupSyncablePatch{
AutoAdd: model.NewBool(true),
AutoAdd: model.NewPointer(true),
}
th.App.Srv().SetLicense(model.NewTestLicense("ldap"))
@ -694,10 +694,10 @@ func TestUnlinkGroupTeam(t *testing.T) {
gid := model.NewId()
g2, appErr := th.App.CreateGroup(&model.Group{
DisplayName: "dn_" + gid,
Name: model.NewString("name" + gid),
Name: model.NewPointer("name" + gid),
Source: model.GroupSourceCustom,
Description: "description_" + gid,
RemoteId: model.NewString(model.NewId()),
RemoteId: model.NewPointer(model.NewId()),
})
assert.Nil(t, appErr)
@ -714,26 +714,26 @@ func TestUnlinkGroupChannel(t *testing.T) {
id := model.NewId()
g, appErr := th.App.CreateGroup(&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()),
})
assert.Nil(t, appErr)
id = model.NewId()
gRef, appErr := th.App.CreateGroup(&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()),
AllowReference: true,
})
assert.Nil(t, appErr)
patch := &model.GroupSyncablePatch{
AutoAdd: model.NewBool(true),
AutoAdd: model.NewPointer(true),
}
th.App.Srv().SetLicense(model.NewTestLicense("ldap"))
@ -812,10 +812,10 @@ func TestUnlinkGroupChannel(t *testing.T) {
gid := model.NewId()
g2, appErr := th.App.CreateGroup(&model.Group{
DisplayName: "dn_" + gid,
Name: model.NewString("name" + gid),
Name: model.NewPointer("name" + gid),
Source: model.GroupSourceCustom,
Description: "description_" + gid,
RemoteId: model.NewString(model.NewId()),
RemoteId: model.NewPointer(model.NewId()),
})
assert.Nil(t, appErr)
@ -832,10 +832,10 @@ func TestGetGroupTeam(t *testing.T) {
id := model.NewId()
g, appErr := th.App.CreateGroup(&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()),
})
assert.Nil(t, appErr)
@ -850,7 +850,7 @@ func TestGetGroupTeam(t *testing.T) {
th.App.Srv().SetLicense(model.NewTestLicense("ldap"))
patch := &model.GroupSyncablePatch{
AutoAdd: model.NewBool(true),
AutoAdd: model.NewPointer(true),
}
_, response, _ = th.SystemAdminClient.LinkGroupSyncable(context.Background(), g.Id, th.BasicTeam.Id, model.GroupSyncableTypeTeam, patch)
@ -894,10 +894,10 @@ func TestGetGroupChannel(t *testing.T) {
id := model.NewId()
g, appErr := th.App.CreateGroup(&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()),
})
assert.Nil(t, appErr)
@ -912,7 +912,7 @@ func TestGetGroupChannel(t *testing.T) {
th.App.Srv().SetLicense(model.NewTestLicense("ldap"))
patch := &model.GroupSyncablePatch{
AutoAdd: model.NewBool(true),
AutoAdd: model.NewPointer(true),
}
_, response, _ = th.SystemAdminClient.LinkGroupSyncable(context.Background(), g.Id, th.BasicChannel.Id, model.GroupSyncableTypeChannel, patch)
@ -956,17 +956,17 @@ func TestGetGroupTeams(t *testing.T) {
id := model.NewId()
g, appErr := th.App.CreateGroup(&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()),
})
assert.Nil(t, appErr)
th.App.Srv().SetLicense(model.NewTestLicense("ldap"))
patch := &model.GroupSyncablePatch{
AutoAdd: model.NewBool(true),
AutoAdd: model.NewPointer(true),
}
for i := 0; i < 10; i++ {
@ -1009,17 +1009,17 @@ func TestGetGroupChannels(t *testing.T) {
id := model.NewId()
g, appErr := th.App.CreateGroup(&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()),
})
assert.Nil(t, appErr)
th.App.Srv().SetLicense(model.NewTestLicense("ldap"))
patch := &model.GroupSyncablePatch{
AutoAdd: model.NewBool(true),
AutoAdd: model.NewPointer(true),
}
for i := 0; i < 10; i++ {
@ -1061,15 +1061,15 @@ func TestPatchGroupTeam(t *testing.T) {
id := model.NewId()
g, appErr := th.App.CreateGroup(&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()),
})
assert.Nil(t, appErr)
patch := &model.GroupSyncablePatch{
AutoAdd: model.NewBool(true),
AutoAdd: model.NewPointer(true),
}
th.App.Srv().SetLicense(model.NewTestLicense("ldap"))
@ -1090,7 +1090,7 @@ func TestPatchGroupTeam(t *testing.T) {
th.App.Srv().SetLicense(model.NewTestLicense("ldap"))
patch.AutoAdd = model.NewBool(false)
patch.AutoAdd = model.NewPointer(false)
groupSyncable, response, err = th.SystemAdminClient.PatchGroupSyncable(context.Background(), g.Id, th.BasicTeam.Id, model.GroupSyncableTypeTeam, patch)
require.NoError(t, err)
CheckOKStatus(t, response)
@ -1100,7 +1100,7 @@ func TestPatchGroupTeam(t *testing.T) {
assert.Equal(t, th.BasicTeam.Id, groupSyncable.SyncableId)
assert.Equal(t, model.GroupSyncableTypeTeam, groupSyncable.Type)
patch.AutoAdd = model.NewBool(true)
patch.AutoAdd = model.NewPointer(true)
_, response, _ = th.SystemAdminClient.PatchGroupSyncable(context.Background(), g.Id, th.BasicTeam.Id, model.GroupSyncableTypeTeam, patch)
CheckOKStatus(t, response)
@ -1133,15 +1133,15 @@ func TestPatchGroupChannel(t *testing.T) {
id := model.NewId()
g, appErr := th.App.CreateGroup(&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()),
})
assert.Nil(t, appErr)
patch := &model.GroupSyncablePatch{
AutoAdd: model.NewBool(true),
AutoAdd: model.NewPointer(true),
}
th.App.Srv().SetLicense(model.NewTestLicense("ldap"))
@ -1171,7 +1171,7 @@ func TestPatchGroupChannel(t *testing.T) {
th.App.Srv().SetLicense(model.NewTestLicense("ldap"))
patch.AutoAdd = model.NewBool(false)
patch.AutoAdd = model.NewPointer(false)
groupSyncable, response, err = th.SystemAdminClient.PatchGroupSyncable(context.Background(), g.Id, th.BasicChannel.Id, model.GroupSyncableTypeChannel, patch)
require.NoError(t, err)
CheckOKStatus(t, response)
@ -1182,7 +1182,7 @@ func TestPatchGroupChannel(t *testing.T) {
assert.Equal(t, th.BasicChannel.TeamId, groupSyncable.TeamID)
assert.Equal(t, model.GroupSyncableTypeChannel, groupSyncable.Type)
patch.AutoAdd = model.NewBool(true)
patch.AutoAdd = model.NewPointer(true)
_, response, err = th.SystemAdminClient.PatchGroupSyncable(context.Background(), g.Id, th.BasicChannel.Id, model.GroupSyncableTypeChannel, patch)
require.NoError(t, err)
CheckOKStatus(t, response)
@ -1216,10 +1216,10 @@ func TestGetGroupsByChannel(t *testing.T) {
id := model.NewId()
group, appErr := th.App.CreateGroup(&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()),
})
assert.Nil(t, appErr)
@ -1270,7 +1270,7 @@ func TestGetGroupsByChannel(t *testing.T) {
var groups []*model.GroupWithSchemeAdmin
groups, _, _, err = client.GetGroupsByChannel(context.Background(), th.BasicChannel.Id, opts)
assert.NoError(t, err)
assert.ElementsMatch(t, []*model.GroupWithSchemeAdmin{{Group: *group, SchemeAdmin: model.NewBool(false)}}, groups)
assert.ElementsMatch(t, []*model.GroupWithSchemeAdmin{{Group: *group, SchemeAdmin: model.NewPointer(false)}}, groups)
require.NotNil(t, groups[0].SchemeAdmin)
require.False(t, *groups[0].SchemeAdmin)
})
@ -1284,7 +1284,7 @@ func TestGetGroupsByChannel(t *testing.T) {
groups, _, _, err := client.GetGroupsByChannel(context.Background(), th.BasicChannel.Id, opts)
assert.NoError(t, err)
// ensure that SchemeAdmin field is updated
assert.ElementsMatch(t, []*model.GroupWithSchemeAdmin{{Group: *group, SchemeAdmin: model.NewBool(true)}}, groups)
assert.ElementsMatch(t, []*model.GroupWithSchemeAdmin{{Group: *group, SchemeAdmin: model.NewPointer(true)}}, groups)
require.NotNil(t, groups[0].SchemeAdmin)
require.True(t, *groups[0].SchemeAdmin)
@ -1301,10 +1301,10 @@ func TestGetGroupsAssociatedToChannelsByTeam(t *testing.T) {
id := model.NewId()
group, appErr := th.App.CreateGroup(&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()),
})
assert.Nil(t, appErr)
@ -1342,7 +1342,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)
@ -1360,7 +1360,7 @@ func TestGetGroupsAssociatedToChannelsByTeam(t *testing.T) {
assert.Equal(t, map[string][]*model.GroupWithSchemeAdmin{
th.BasicChannel.Id: {
{Group: *group, SchemeAdmin: model.NewBool(true)},
{Group: *group, SchemeAdmin: model.NewPointer(true)},
},
}, groups)
@ -1396,10 +1396,10 @@ func TestGetGroupsByTeam(t *testing.T) {
id := model.NewId()
group, err := th.App.CreateGroup(&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()),
})
assert.Nil(t, err)
@ -1443,7 +1443,7 @@ func TestGetGroupsByTeam(t *testing.T) {
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
groups, _, _, err := client.GetGroupsByTeam(context.Background(), th.BasicTeam.Id, opts)
assert.NoError(t, err)
assert.ElementsMatch(t, []*model.GroupWithSchemeAdmin{{Group: *group, SchemeAdmin: model.NewBool(false)}}, groups)
assert.ElementsMatch(t, []*model.GroupWithSchemeAdmin{{Group: *group, SchemeAdmin: model.NewPointer(false)}}, groups)
require.NotNil(t, groups[0].SchemeAdmin)
require.False(t, *groups[0].SchemeAdmin)
})
@ -1457,7 +1457,7 @@ func TestGetGroupsByTeam(t *testing.T) {
groups, _, _, err := client.GetGroupsByTeam(context.Background(), th.BasicTeam.Id, opts)
assert.NoError(t, err)
// ensure that SchemeAdmin field is updated
assert.ElementsMatch(t, []*model.GroupWithSchemeAdmin{{Group: *group, SchemeAdmin: model.NewBool(true)}}, groups)
assert.ElementsMatch(t, []*model.GroupWithSchemeAdmin{{Group: *group, SchemeAdmin: model.NewPointer(true)}}, groups)
require.NotNil(t, groups[0].SchemeAdmin)
require.True(t, *groups[0].SchemeAdmin)
@ -1471,7 +1471,7 @@ func TestGetGroupsByTeam(t *testing.T) {
groups, _, _, err := client.GetGroupsByTeam(context.Background(), th.BasicTeam.Id, opts)
require.NoError(t, err)
require.Len(t, groups, 1)
require.ElementsMatch(t, []*model.GroupWithSchemeAdmin{{Group: *group, SchemeAdmin: model.NewBool(true)}}, groups)
require.ElementsMatch(t, []*model.GroupWithSchemeAdmin{{Group: *group, SchemeAdmin: model.NewPointer(true)}}, groups)
require.NotNil(t, groups[0].SchemeAdmin)
require.True(t, *groups[0].SchemeAdmin)
}, "groups can be fetched by system admins even if they're not part of a team")
@ -1480,7 +1480,7 @@ func TestGetGroupsByTeam(t *testing.T) {
groups, _, _, err := th.Client.GetGroupsByTeam(context.Background(), th.BasicTeam.Id, opts)
require.NoError(t, err)
require.Len(t, groups, 1)
require.ElementsMatch(t, []*model.GroupWithSchemeAdmin{{Group: *group, SchemeAdmin: model.NewBool(true)}}, groups)
require.ElementsMatch(t, []*model.GroupWithSchemeAdmin{{Group: *group, SchemeAdmin: model.NewPointer(true)}}, groups)
require.NotNil(t, groups[0].SchemeAdmin)
require.True(t, *groups[0].SchemeAdmin)
})
@ -1506,10 +1506,10 @@ func TestGetGroups(t *testing.T) {
id := model.NewId()
group, appErr := th.App.CreateGroup(&model.Group{
DisplayName: "dn-foo_" + 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()),
})
assert.Nil(t, appErr)
start := group.UpdateAt - 1
@ -1517,10 +1517,10 @@ func TestGetGroups(t *testing.T) {
id2 := model.NewId()
group2, appErr := th.App.CreateGroup(&model.Group{
DisplayName: "dn-foo_" + id2,
Name: model.NewString("name" + id2),
Name: model.NewPointer("name" + id2),
Source: model.GroupSourceCustom,
Description: "description_" + id2,
RemoteId: model.NewString(model.NewId()),
RemoteId: model.NewPointer(model.NewId()),
})
assert.Nil(t, appErr)
@ -1676,10 +1676,10 @@ func TestGetGroupsByUserId(t *testing.T) {
id := model.NewId()
group1, appErr := th.App.CreateGroup(&model.Group{
DisplayName: "dn-foo_" + 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()),
})
assert.Nil(t, appErr)
@ -1692,10 +1692,10 @@ func TestGetGroupsByUserId(t *testing.T) {
id = model.NewId()
group2, appErr := th.App.CreateGroup(&model.Group{
DisplayName: "dn-foo_" + 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()),
})
assert.Nil(t, appErr)
@ -1741,10 +1741,10 @@ func TestGetGroupMembers(t *testing.T) {
id := model.NewId()
group, appErr := th.App.CreateGroup(&model.Group{
DisplayName: "dn-foo_" + 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()),
})
assert.Nil(t, appErr)
@ -1807,10 +1807,10 @@ func TestGetGroupStats(t *testing.T) {
id := model.NewId()
group, appErr := th.App.CreateGroup(&model.Group{
DisplayName: "dn-foo_" + 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()),
})
assert.Nil(t, appErr)
@ -1859,10 +1859,10 @@ func TestGetGroupsGroupConstrainedParentTeam(t *testing.T) {
id := model.NewId()
group, err := th.App.CreateGroup(&model.Group{
DisplayName: fmt.Sprintf("dn-foo_%d", i),
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()),
})
require.Nil(t, err)
groups = append(groups, group)
@ -1876,7 +1876,7 @@ func TestGetGroupsGroupConstrainedParentTeam(t *testing.T) {
Name: "name" + id,
Type: model.ChannelTypePrivate,
TeamId: team.Id,
GroupConstrained: model.NewBool(true),
GroupConstrained: model.NewPointer(true),
}
channel, appErr := th.App.CreateChannel(th.Context, channel, false)
require.Nil(t, appErr)
@ -1888,7 +1888,7 @@ func TestGetGroupsGroupConstrainedParentTeam(t *testing.T) {
require.Contains(t, apiGroups, groups[1])
require.Contains(t, apiGroups, groups[2])
team.GroupConstrained = model.NewBool(true)
team.GroupConstrained = model.NewPointer(true)
team, appErr = th.App.UpdateTeam(team)
require.Nil(t, appErr)
@ -1939,7 +1939,7 @@ func TestAddMembersToGroup(t *testing.T) {
id := model.NewId()
group, 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,
})
@ -1991,10 +1991,10 @@ func TestAddMembersToGroup(t *testing.T) {
ldapId := model.NewId()
ldapGroup, err := th.App.CreateGroup(&model.Group{
DisplayName: "dn_" + ldapId,
Name: model.NewString("name" + ldapId),
Name: model.NewPointer("name" + ldapId),
Source: model.GroupSourceLdap,
Description: "description_" + ldapId,
RemoteId: model.NewString(model.NewId()),
RemoteId: model.NewPointer(model.NewId()),
})
assert.Nil(t, err)
@ -2018,7 +2018,7 @@ func TestDeleteMembersFromGroup(t *testing.T) {
id := model.NewId()
g := &model.Group{
DisplayName: "dn_" + id,
Name: model.NewString("name" + id),
Name: model.NewPointer("name" + id),
Source: model.GroupSourceCustom,
Description: "description_" + id,
}
@ -2069,10 +2069,10 @@ func TestDeleteMembersFromGroup(t *testing.T) {
ldapId := model.NewId()
g1 := &model.Group{
DisplayName: "dn_" + ldapId,
Name: model.NewString("name" + ldapId),
Name: model.NewPointer("name" + ldapId),
Source: model.GroupSourceLdap,
Description: "description_" + ldapId,
RemoteId: model.NewString(model.NewId()),
RemoteId: model.NewPointer(model.NewId()),
}
ldapGroup, err := th.App.CreateGroupWithUserIds(&model.GroupWithUserIds{
Group: *g1,

View File

@ -30,7 +30,7 @@ func TestGetImage(t *testing.T) {
imageURL := "http://foo.bar/baz.gif"
th.App.UpdateConfig(func(cfg *model.Config) {
cfg.ImageProxySettings.Enable = model.NewBool(false)
cfg.ImageProxySettings.Enable = model.NewPointer(false)
})
r, err := http.NewRequest("GET", th.Client.APIURL+"/image?url="+url.QueryEscape(imageURL), nil)
@ -48,10 +48,10 @@ func TestGetImage(t *testing.T) {
proxiedURL := "https://proxy.foo.bar/004afe2ef382eb5f30c4490f793f8a8c5b33d8a2/687474703a2f2f666f6f2e6261722f62617a2e676966"
th.App.UpdateConfig(func(cfg *model.Config) {
cfg.ImageProxySettings.Enable = model.NewBool(true)
cfg.ImageProxySettings.ImageProxyType = model.NewString("atmos/camo")
cfg.ImageProxySettings.RemoteImageProxyOptions = model.NewString("foo")
cfg.ImageProxySettings.RemoteImageProxyURL = model.NewString("https://proxy.foo.bar")
cfg.ImageProxySettings.Enable = model.NewPointer(true)
cfg.ImageProxySettings.ImageProxyType = model.NewPointer("atmos/camo")
cfg.ImageProxySettings.RemoteImageProxyOptions = model.NewPointer("foo")
cfg.ImageProxySettings.RemoteImageProxyURL = model.NewPointer("https://proxy.foo.bar")
})
r, err := http.NewRequest("GET", th.Client.APIURL+"/image?url="+url.QueryEscape(imageURL), nil)
@ -66,11 +66,11 @@ func TestGetImage(t *testing.T) {
t.Run("local", func(t *testing.T) {
th.App.UpdateConfig(func(cfg *model.Config) {
cfg.ImageProxySettings.Enable = model.NewBool(true)
cfg.ImageProxySettings.ImageProxyType = model.NewString("local")
cfg.ImageProxySettings.Enable = model.NewPointer(true)
cfg.ImageProxySettings.ImageProxyType = model.NewPointer("local")
// Allow requests to the "remote" image
cfg.ServiceSettings.AllowedUntrustedInternalConnections = model.NewString("127.0.0.1")
cfg.ServiceSettings.AllowedUntrustedInternalConnections = model.NewPointer("127.0.0.1")
})
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
@ -104,7 +104,7 @@ func TestGetImage(t *testing.T) {
// protocol relative URLs should be handled by proxy
th.App.UpdateConfig(func(cfg *model.Config) {
cfg.ServiceSettings.SiteURL = model.NewString("http://foo.com")
cfg.ServiceSettings.SiteURL = model.NewPointer("http://foo.com")
})
r, err = http.NewRequest("GET", th.Client.APIURL+"/image?url="+strings.TrimPrefix(imageServer.URL, "http:")+"/image.png", nil)
require.NoError(t, err)

View File

@ -272,7 +272,7 @@ func TestOpenDialog(t *testing.T) {
t.Run("Should fail if trigger timeout is extended", func(t *testing.T) {
th.App.UpdateConfig(func(cfg *model.Config) {
cfg.ServiceSettings.OutgoingIntegrationRequestsTimeout = model.NewInt64(1)
cfg.ServiceSettings.OutgoingIntegrationRequestsTimeout = model.NewPointer(int64(1))
})
time.Sleep(2 * time.Second)

View File

@ -16,8 +16,8 @@ import (
func Test_getIPFilters(t *testing.T) {
lic := &model.License{
Features: &model.Features{
CustomPermissionsSchemes: model.NewBool(false),
Cloud: model.NewBool(true),
CustomPermissionsSchemes: model.NewPointer(false),
Cloud: model.NewPointer(true),
},
Customer: &model.Customer{
Name: "TestName",
@ -247,8 +247,8 @@ func Test_applyIPFilters(t *testing.T) {
func Test_getMyIP(t *testing.T) {
lic := &model.License{
Features: &model.Features{
CustomPermissionsSchemes: model.NewBool(false),
Cloud: model.NewBool(true),
CustomPermissionsSchemes: model.NewPointer(false),
Cloud: model.NewPointer(true),
},
Customer: &model.Customer{
Name: "TestName",

View File

@ -131,7 +131,7 @@ func TestUploadLicenseFile(t *testing.T) {
license := model.License{
Id: model.NewId(),
Features: &model.Features{
Users: model.NewInt(100),
Users: model.NewPointer(100),
},
Customer: &model.Customer{
Name: "Test",
@ -259,7 +259,7 @@ func TestRequestTrialLicenseWithExtraFields(t *testing.T) {
t.Run("trial license user count less than current users", func(t *testing.T) {
license := model.NewTestLicense()
license.Features.Users = model.NewInt(nUsers)
license.Features.Users = model.NewPointer(nUsers)
licenseJSON, jsonErr := json.Marshal(license)
require.NoError(t, jsonErr)
testServer := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
@ -295,7 +295,7 @@ func TestRequestTrialLicenseWithExtraFields(t *testing.T) {
t.Run("returns status 451 when it receives status 451", func(t *testing.T) {
license := model.NewTestLicense()
license.Features.Users = model.NewInt(nUsers)
license.Features.Users = model.NewPointer(nUsers)
licenseJSON, jsonErr := json.Marshal(license)
require.NoError(t, jsonErr)
testServer := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
@ -328,7 +328,7 @@ func TestRequestTrialLicenseWithExtraFields(t *testing.T) {
validTrialRequest.Users = 100
defer func() { validTrialRequest.CompanyCountry = "US" }()
license := model.NewTestLicense()
license.Features.Users = model.NewInt(nUsers)
license.Features.Users = model.NewPointer(nUsers)
licenseJSON, jsonErr := json.Marshal(license)
require.NoError(t, jsonErr)
testServer := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
@ -389,7 +389,7 @@ func TestRequestTrialLicense(t *testing.T) {
t.Run("trial license user count less than current users", func(t *testing.T) {
nUsers := 1
license := model.NewTestLicense()
license.Features.Users = model.NewInt(nUsers)
license.Features.Users = model.NewPointer(nUsers)
licenseJSON, jsonErr := json.Marshal(license)
require.NoError(t, jsonErr)
testServer := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
@ -424,7 +424,7 @@ func TestRequestTrialLicense(t *testing.T) {
t.Run("returns status 451 when it receives status 451", func(t *testing.T) {
nUsers := 1
license := model.NewTestLicense()
license.Features.Users = model.NewInt(nUsers)
license.Features.Users = model.NewPointer(nUsers)
licenseJSON, jsonErr := json.Marshal(license)
require.NoError(t, jsonErr)
testServer := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {

View File

@ -215,7 +215,7 @@ func TestClientOutgoingOAuthConnectionGet(t *testing.T) {
outgoingOauthIface := &mocks.OutgoingOAuthConnectionInterface{}
outgoingOauthImpl := th.App.Srv().OutgoingOAuthConnection
outgoingOAuthConnectionConfig := th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections
th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewBool(false)
th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = model.NewPointer(false)
defer func() {
th.App.Srv().OutgoingOAuthConnection = outgoingOauthImpl
th.App.Config().ServiceSettings.EnableOutgoingOAuthConnections = outgoingOAuthConnectionConfig
@ -255,7 +255,7 @@ func TestClientListOutgoingOAuthConnection(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
@ -290,7 +290,7 @@ func TestClientListOutgoingOAuthConnection(t *testing.T) {
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
@ -326,7 +326,7 @@ func TestClientListOutgoingOAuthConnection(t *testing.T) {
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
@ -369,7 +369,7 @@ func TestClientListOutgoingOAuthConnection(t *testing.T) {
outgoingOauthIface.Mock.On("SanitizeConnections", mock.Anything)
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
@ -414,7 +414,7 @@ func TestClientListOutgoingOAuthConnection(t *testing.T) {
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
@ -453,7 +453,7 @@ func TestClientGetOutgoingOAuthConnection(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
@ -489,7 +489,7 @@ func TestClientGetOutgoingOAuthConnection(t *testing.T) {
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
@ -530,7 +530,7 @@ func TestClientCreateOutgoingOAuthConnection(t *testing.T) {
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
@ -563,7 +563,7 @@ func TestClientCreateOutgoingOAuthConnection(t *testing.T) {
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
@ -602,7 +602,7 @@ func TestClientUpdateOutgoingOAuthConnection(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
@ -638,7 +638,7 @@ func TestClientUpdateOutgoingOAuthConnection(t *testing.T) {
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
@ -681,7 +681,7 @@ func TestClientDeleteOutgoingOAuthConnection(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
@ -715,7 +715,7 @@ func TestClientDeleteOutgoingOAuthConnection(t *testing.T) {
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
@ -753,7 +753,7 @@ func TestEnsureOutgoingOAuthConnectionInterface(t *testing.T) {
defer th.TearDown()
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.Config().ServiceSettings.EnableOutgoingOAuthConnections = outgoingOAuthConnectionConfig
})
@ -776,7 +776,7 @@ func TestEnsureOutgoingOAuthConnectionInterface(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
@ -799,7 +799,7 @@ func TestEnsureOutgoingOAuthConnectionInterface(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
@ -850,7 +850,7 @@ func TestHandlerOutgoingOAuthConnectionListGet(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)
th.App.Srv().OutgoingOAuthConnection = outgoingOauthIface
defaultRolePermissions := th.SaveDefaultRolePermissions()
@ -973,7 +973,7 @@ func TestHandlerOutgoingOAuthConnectionListReadOnly(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)
th.App.Srv().OutgoingOAuthConnection = outgoingOauthIface
defaultRolePermissions := th.SaveDefaultRolePermissions()
@ -1109,7 +1109,7 @@ func TestHandlerOutgoingOAuthConnectionUpdate(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
@ -1161,7 +1161,7 @@ func TestHandlerOutgoingOAuthConnectionUpdate(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
@ -1227,7 +1227,7 @@ func TestHandlerOutgoingOAuthConnectionUpdate(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
@ -1261,7 +1261,7 @@ func TestHandlerOutgoingOAuthConnectionHandlerCreate(t *testing.T) {
defer th.App.Srv().RemoveLicense()
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.Config().ServiceSettings.EnableOutgoingOAuthConnections = outgoingOAuthConnectionConfig
})
@ -1320,7 +1320,7 @@ func TestHandlerOutgoingOAuthConnectionHandlerCreate(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
@ -1374,7 +1374,7 @@ func TestHandlerOutgoingOAuthConnectionHandlerCreate(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
@ -1435,7 +1435,7 @@ func TestHandlerOutgoingOAuthConnectionHandlerValidate(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
@ -1525,7 +1525,7 @@ func TestHandlerOutgoingOAuthConnectionHandlerValidate(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
@ -1577,7 +1577,7 @@ func TestHandlerOutgoingOAuthConnectionHandlerValidate(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
@ -1632,7 +1632,7 @@ func TestHandlerOutgoingOAuthConnectionHandlerValidate(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

View File

@ -1074,7 +1074,7 @@ func saveIsPinnedPost(c *Context, w http.ResponseWriter, isPinned bool) {
}
patch := &model.PostPatch{}
patch.IsPinned = model.NewBool(isPinned)
patch.IsPinned = model.NewPointer(isPinned)
patchedPost, err := c.App.PatchPost(c.AppContext, c.Params.PostId, patch)
if err != nil {

View File

@ -233,7 +233,7 @@ func TestCreatePost(t *testing.T) {
t.Run("Should not be able to define the RemoteId of a post from the API", func(t *testing.T) {
newPost := &model.Post{
RemoteId: model.NewString(model.NewId()),
RemoteId: model.NewPointer(model.NewId()),
ChannelId: th.BasicChannel.Id,
Message: "post content " + model.NewId(),
DeleteAt: 0,
@ -273,7 +273,7 @@ func TestCreatePostForPriority(t *testing.T) {
post := &model.Post{ChannelId: th.BasicChannel.Id, Message: "test", Metadata: &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("urgent"),
Priority: model.NewPointer("urgent"),
},
}}
@ -291,7 +291,7 @@ func TestCreatePostForPriority(t *testing.T) {
replyPost := &model.Post{RootId: post.Id, ChannelId: th.BasicChannel.Id, Message: "reply", Metadata: &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("urgent"),
Priority: model.NewPointer("urgent"),
},
}}
_, resp, err = client.CreatePost(context.Background(), replyPost)
@ -305,8 +305,8 @@ func TestCreatePostForPriority(t *testing.T) {
// for Acknowledment
p1 := &model.Post{ChannelId: th.BasicChannel.Id, Message: "test", Metadata: &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("urgent"),
RequestedAck: model.NewBool(true),
Priority: model.NewPointer("urgent"),
RequestedAck: model.NewPointer(true),
},
}}
_, resp, err := client.CreatePost(context.Background(), p1)
@ -316,8 +316,8 @@ func TestCreatePostForPriority(t *testing.T) {
// for Persistent Notification
p2 := &model.Post{ChannelId: th.BasicChannel.Id, Message: "test", Metadata: &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("urgent"),
PersistentNotifications: model.NewBool(true),
Priority: model.NewPointer("urgent"),
PersistentNotifications: model.NewPointer(true),
},
}}
_, resp, err = client.CreatePost(context.Background(), p2)
@ -337,8 +337,8 @@ func TestCreatePostForPriority(t *testing.T) {
p1 := &model.Post{ChannelId: th.BasicChannel.Id, Message: "test", Metadata: &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("urgent"),
PersistentNotifications: model.NewBool(true),
Priority: model.NewPointer("urgent"),
PersistentNotifications: model.NewPointer(true),
},
}}
_, resp, err := client.CreatePost(context.Background(), p1)
@ -349,8 +349,8 @@ func TestCreatePostForPriority(t *testing.T) {
t.Run("should return badRequest when post is not urgent for persistent notification", func(t *testing.T) {
p1 := &model.Post{ChannelId: th.BasicChannel.Id, Message: "test", Metadata: &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("important"),
PersistentNotifications: model.NewBool(true),
Priority: model.NewPointer("important"),
PersistentNotifications: model.NewPointer(true),
},
}}
_, resp, err := client.CreatePost(context.Background(), p1)
@ -373,8 +373,8 @@ func TestCreatePostForPriority(t *testing.T) {
p1 := &model.Post{ChannelId: th.BasicChannel.Id, Message: "test", Metadata: &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("urgent"),
PersistentNotifications: model.NewBool(true),
Priority: model.NewPointer("urgent"),
PersistentNotifications: model.NewPointer(true),
},
}}
_, resp, err := client.CreatePost(context.Background(), p1)
@ -385,7 +385,7 @@ func TestCreatePostForPriority(t *testing.T) {
t.Run("should create priority post", func(t *testing.T) {
p1 := &model.Post{ChannelId: th.BasicChannel.Id, Message: "test", Metadata: &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("important"),
Priority: model.NewPointer("important"),
},
}}
_, resp, err := client.CreatePost(context.Background(), p1)
@ -396,8 +396,8 @@ func TestCreatePostForPriority(t *testing.T) {
t.Run("should create acknowledge post", func(t *testing.T) {
p1 := &model.Post{ChannelId: th.BasicChannel.Id, Message: "test", Metadata: &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString(""),
RequestedAck: model.NewBool(true),
Priority: model.NewPointer(""),
RequestedAck: model.NewPointer(true),
},
}}
_, resp, err := client.CreatePost(context.Background(), p1)
@ -408,9 +408,9 @@ func TestCreatePostForPriority(t *testing.T) {
t.Run("should create persistent notification post", func(t *testing.T) {
p1 := &model.Post{ChannelId: th.BasicChannel.Id, Message: "test @" + th.BasicUser2.Username, Metadata: &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("urgent"),
RequestedAck: model.NewBool(false),
PersistentNotifications: model.NewBool(true),
Priority: model.NewPointer("urgent"),
RequestedAck: model.NewPointer(false),
PersistentNotifications: model.NewPointer(true),
},
}}
_, resp, err := client.CreatePost(context.Background(), p1)
@ -615,7 +615,7 @@ func testCreatePostWithOutgoingHook(
}
outGoingHookResponse := &model.OutgoingWebhookResponse{
Text: model.NewString("some test text"),
Text: model.NewPointer("some test text"),
Username: "TestCommandServer",
IconURL: "https://mattermost.com/wp-content/uploads/2022/02/icon.png",
Type: "custom_as",
@ -1532,12 +1532,12 @@ func TestPatchPost(t *testing.T) {
t.Run("new message, props, files, HasReactions bit", func(t *testing.T) {
patch := &model.PostPatch{}
patch.IsPinned = model.NewBool(false)
patch.Message = model.NewString("#otherhashtag other message")
patch.IsPinned = model.NewPointer(false)
patch.Message = model.NewPointer("#otherhashtag other message")
patch.Props = &model.StringInterface{"channel_header": "new_header"}
patchFileIds := model.StringArray(fileIDs) // one extra file
patch.FileIds = &patchFileIds
patch.HasReactions = model.NewBool(false)
patch.HasReactions = model.NewPointer(false)
rpost, _, err = client.PatchPost(context.Background(), post.Id, patch)
require.NoError(t, err)
@ -1655,7 +1655,7 @@ func TestPatchPost(t *testing.T) {
require.NoError(t, err)
patch2 := &model.PostPatch{
Message: model.NewString("new message"),
Message: model.NewPointer("new message"),
}
_, resp, err := th.SystemAdminClient.PatchPost(context.Background(), post2.Id, patch2)
require.Error(t, err)
@ -3757,7 +3757,7 @@ func TestGetEditHistoryForPost(t *testing.T) {
// update the post message
patch := &model.PostPatch{
Message: model.NewString("new message edited"),
Message: model.NewPointer("new message edited"),
}
// Patch the post
@ -3767,7 +3767,7 @@ func TestGetEditHistoryForPost(t *testing.T) {
// update the post message again
patch = &model.PostPatch{
Message: model.NewString("new message edited again"),
Message: model.NewPointer("new message edited again"),
}
_, response2, err2 := client.PatchPost(context.Background(), rpost.Id, patch)

View File

@ -446,7 +446,7 @@ func TestPatchRemoteCluster(t *testing.T) {
Token: model.NewId(),
}
rcp := &model.RemoteClusterPatch{DisplayName: model.NewString("different value")}
rcp := &model.RemoteClusterPatch{DisplayName: model.NewPointer("different value")}
t.Run("Should not work if the remote cluster service is not enabled", func(t *testing.T) {
th := Setup(t)
@ -488,7 +488,7 @@ func TestPatchRemoteCluster(t *testing.T) {
})
t.Run("should correctly patch the remote cluster", func(t *testing.T) {
rcp := &model.RemoteClusterPatch{DisplayName: model.NewString("patched!")}
rcp := &model.RemoteClusterPatch{DisplayName: model.NewPointer("patched!")}
patchedRC, resp, err := th.SystemAdminClient.PatchRemoteCluster(context.Background(), rc.RemoteId, rcp)
CheckOKStatus(t, resp)

View File

@ -316,7 +316,7 @@ func TestPatchRole(t *testing.T) {
t.Run("Check guest permissions editing without E20 license", func(t *testing.T) {
license := model.NewTestLicense()
license.Features.GuestAccountsPermissions = model.NewBool(false)
license.Features.GuestAccountsPermissions = model.NewPointer(false)
th.App.Srv().SetLicense(license)
guestRole, err := th.App.Srv().Store().Role().GetByName(context.Background(), "system_guest")
@ -328,7 +328,7 @@ func TestPatchRole(t *testing.T) {
t.Run("Check guest permissions editing with E20 license", func(t *testing.T) {
license := model.NewTestLicense()
license.Features.GuestAccountsPermissions = model.NewBool(true)
license.Features.GuestAccountsPermissions = model.NewPointer(true)
th.App.Srv().SetLicense(license)
guestRole, err := th.App.Srv().Store().Role().GetByName(context.Background(), "system_guest")
require.NoError(t, err)

View File

@ -61,7 +61,7 @@ func TestSamlResetId(t *testing.T) {
user := th.BasicUser
_, appErr := th.App.UpdateUserAuth(nil, user.Id, &model.UserAuth{
AuthData: model.NewString(model.NewId()),
AuthData: model.NewPointer(model.NewId()),
AuthService: model.UserAuthServiceSaml,
})
require.Nil(t, appErr)

View File

@ -153,7 +153,7 @@ func TestCreateScheme(t *testing.T) {
// Create scheme with a Professional SKU license but no explicit 'custom_permissions_schemes' license feature.
lic := &model.License{
Features: &model.Features{
CustomPermissionsSchemes: model.NewBool(false),
CustomPermissionsSchemes: model.NewPointer(false),
},
Customer: &model.Customer{
Name: "TestName",
@ -607,7 +607,7 @@ func TestPatchScheme(t *testing.T) {
// Patch scheme with a Professional SKU license but no explicit 'custom_permissions_schemes' license feature.
lic := &model.License{
Features: &model.Features{
CustomPermissionsSchemes: model.NewBool(false),
CustomPermissionsSchemes: model.NewPointer(false),
},
Customer: &model.Customer{
Name: "TestName",
@ -821,7 +821,7 @@ func TestDeleteScheme(t *testing.T) {
// Delete scheme with a Professional SKU license but no explicit 'custom_permissions_schemes' license feature.
lic := &model.License{
Features: &model.Features{
CustomPermissionsSchemes: model.NewBool(false),
CustomPermissionsSchemes: model.NewPointer(false),
},
Customer: &model.Customer{
Name: "TestName",

View File

@ -162,7 +162,7 @@ func TestCreateDirectChannelWithRemoteUser(t *testing.T) {
localUser := th.BasicUser
remoteUser := th.CreateUser()
remoteUser.RemoteId = model.NewString(model.NewId())
remoteUser.RemoteId = model.NewPointer(model.NewId())
remoteUser, appErr := th.App.UpdateUser(th.Context, remoteUser, false)
require.Nil(t, appErr)
@ -191,7 +191,7 @@ func TestCreateDirectChannelWithRemoteUser(t *testing.T) {
rc, appErr := th.App.AddRemoteCluster(rc)
require.Nil(t, appErr)
remoteUser.RemoteId = model.NewString(rc.RemoteId)
remoteUser.RemoteId = model.NewPointer(rc.RemoteId)
remoteUser, appErr = th.App.UpdateUser(th.Context, remoteUser, false)
require.Nil(t, appErr)
@ -220,7 +220,7 @@ func TestCreateDirectChannelWithRemoteUser(t *testing.T) {
rc, appErr := th.App.AddRemoteCluster(rc)
require.Nil(t, appErr)
remoteUser.RemoteId = model.NewString(rc.RemoteId)
remoteUser.RemoteId = model.NewPointer(rc.RemoteId)
remoteUser, appErr = th.App.UpdateUser(th.Context, remoteUser, false)
require.Nil(t, appErr)

View File

@ -137,27 +137,27 @@ func TestEmailTest(t *testing.T) {
es := model.EmailSettings{}
es.SetDefaults(false)
es.SMTPServer = model.NewString("")
es.SMTPPort = model.NewString("")
es.SMTPPassword = model.NewString("")
es.FeedbackName = model.NewString("")
es.FeedbackEmail = model.NewString("some-addr@test.com")
es.ReplyToAddress = model.NewString("some-addr@test.com")
es.ConnectionSecurity = model.NewString("")
es.SMTPUsername = model.NewString("")
es.EnableSMTPAuth = model.NewBool(false)
es.SkipServerCertificateVerification = model.NewBool(true)
es.SendEmailNotifications = model.NewBool(false)
es.SMTPServerTimeout = model.NewInt(15)
es.SMTPServer = model.NewPointer("")
es.SMTPPort = model.NewPointer("")
es.SMTPPassword = model.NewPointer("")
es.FeedbackName = model.NewPointer("")
es.FeedbackEmail = model.NewPointer("some-addr@test.com")
es.ReplyToAddress = model.NewPointer("some-addr@test.com")
es.ConnectionSecurity = model.NewPointer("")
es.SMTPUsername = model.NewPointer("")
es.EnableSMTPAuth = model.NewPointer(false)
es.SkipServerCertificateVerification = model.NewPointer(true)
es.SendEmailNotifications = model.NewPointer(false)
es.SMTPServerTimeout = model.NewPointer(15)
config := model.Config{
ServiceSettings: model.ServiceSettings{
SiteURL: model.NewString(""),
SiteURL: model.NewPointer(""),
},
EmailSettings: es,
FileSettings: model.FileSettings{
DriverName: model.NewString(model.ImageDriverLocal),
Directory: model.NewString(dir),
DriverName: model.NewPointer(model.ImageDriverLocal),
Directory: model.NewPointer(dir),
},
}
@ -573,14 +573,14 @@ func TestS3TestConnection(t *testing.T) {
fs := model.FileSettings{}
fs.SetDefaults(false)
fs.DriverName = model.NewString(model.ImageDriverS3)
fs.AmazonS3AccessKeyId = model.NewString(model.MinioAccessKey)
fs.AmazonS3SecretAccessKey = model.NewString(model.MinioSecretKey)
fs.AmazonS3Bucket = model.NewString("")
fs.AmazonS3Endpoint = model.NewString(s3Endpoint)
fs.AmazonS3Region = model.NewString("")
fs.AmazonS3PathPrefix = model.NewString("")
fs.AmazonS3SSL = model.NewBool(false)
fs.DriverName = model.NewPointer(model.ImageDriverS3)
fs.AmazonS3AccessKeyId = model.NewPointer(model.MinioAccessKey)
fs.AmazonS3SecretAccessKey = model.NewPointer(model.MinioSecretKey)
fs.AmazonS3Bucket = model.NewPointer("")
fs.AmazonS3Endpoint = model.NewPointer(s3Endpoint)
fs.AmazonS3Region = model.NewPointer("")
fs.AmazonS3PathPrefix = model.NewPointer("")
fs.AmazonS3SSL = model.NewPointer(false)
config := model.Config{
FileSettings: fs,
@ -599,18 +599,18 @@ func TestS3TestConnection(t *testing.T) {
// If this fails, check the test configuration to ensure minio is setup with the
// `mattermost-test` bucket defined by model.MINIO_BUCKET.
*config.FileSettings.AmazonS3Bucket = model.MinioBucket
config.FileSettings.AmazonS3PathPrefix = model.NewString("")
config.FileSettings.AmazonS3PathPrefix = model.NewPointer("")
*config.FileSettings.AmazonS3Region = "us-east-1"
resp, err = th.SystemAdminClient.TestS3Connection(context.Background(), &config)
require.NoError(t, err)
CheckOKStatus(t, resp)
config.FileSettings.AmazonS3Region = model.NewString("")
config.FileSettings.AmazonS3Region = model.NewPointer("")
resp, err = th.SystemAdminClient.TestS3Connection(context.Background(), &config)
require.NoError(t, err)
CheckOKStatus(t, resp)
config.FileSettings.AmazonS3Bucket = model.NewString("Wrong_bucket")
config.FileSettings.AmazonS3Bucket = model.NewPointer("Wrong_bucket")
resp, err = th.SystemAdminClient.TestS3Connection(context.Background(), &config)
CheckInternalErrorStatus(t, resp)
CheckErrorID(t, err, "api.file.test_connection_s3_bucket_does_not_exist.app_error")
@ -1054,7 +1054,7 @@ func TestCheckHasNilFields(t *testing.T) {
t.Run("check if the struct has any nil fields", func(t *testing.T) {
s := model.FileSettings{
DriverName: model.NewString(model.ImageDriverLocal),
DriverName: model.NewPointer(model.ImageDriverLocal),
}
res := checkHasNilFields(&s)
require.True(t, res)

View File

@ -1124,10 +1124,10 @@ func getAllTeams(c *Context, w http.ResponseWriter, r *http.Request) {
c.SetPermissionError(model.PermissionSysconsoleReadComplianceDataRetentionPolicy)
return
}
opts.ExcludePolicyConstrained = model.NewBool(true)
opts.ExcludePolicyConstrained = model.NewPointer(true)
}
if c.App.SessionHasPermissionTo(*c.AppContext.Session(), model.PermissionSysconsoleReadComplianceDataRetentionPolicy) {
opts.IncludePolicyID = model.NewBool(true)
opts.IncludePolicyID = model.NewPointer(true)
}
listPrivate := c.App.SessionHasPermissionTo(*c.AppContext.Session(), model.PermissionListPrivateTeams)
@ -1136,9 +1136,9 @@ func getAllTeams(c *Context, w http.ResponseWriter, r *http.Request) {
offset := limit * c.Params.Page
if listPrivate && listPublic {
} else if listPrivate {
opts.AllowOpenInvite = model.NewBool(false)
opts.AllowOpenInvite = model.NewPointer(false)
} else if listPublic {
opts.AllowOpenInvite = model.NewBool(true)
opts.AllowOpenInvite = model.NewPointer(true)
} else {
// The user doesn't have permissions to list private as well as public teams.
c.Err = model.NewAppError("getAllTeams", "api.team.get_all_teams.insufficient_permissions", nil, "", http.StatusForbidden)
@ -1188,7 +1188,7 @@ func searchTeams(c *Context, w http.ResponseWriter, r *http.Request) {
// policy ID may only be used through the /data_retention/policies endpoint
props.PolicyID = nil
if c.App.SessionHasPermissionTo(*c.AppContext.Session(), model.PermissionSysconsoleReadComplianceDataRetentionPolicy) {
props.IncludePolicyID = model.NewBool(true)
props.IncludePolicyID = model.NewPointer(true)
}
var (

View File

@ -62,7 +62,7 @@ func TestCreateTeam(t *testing.T) {
require.Equalf(t, r.StatusCode, http.StatusBadRequest, "wrong status code, actual: %s, expected: %s", strconv.Itoa(r.StatusCode), strconv.Itoa(http.StatusBadRequest))
// Test GroupConstrained flag
groupConstrainedTeam := &model.Team{Name: GenerateTestUsername(), DisplayName: "Some Team", Type: model.TeamOpen, GroupConstrained: model.NewBool(true)}
groupConstrainedTeam := &model.Team{Name: GenerateTestUsername(), DisplayName: "Some Team", Type: model.TeamOpen, GroupConstrained: model.NewPointer(true)}
rteam, resp, err = client.CreateTeam(context.Background(), groupConstrainedTeam)
require.NoError(t, err)
CheckCreatedStatus(t, resp)
@ -163,7 +163,7 @@ func TestCreateTeam(t *testing.T) {
cloud.Mock.On("GetCloudLimits", mock.Anything).Return(&model.ProductLimits{
Teams: &model.TeamsLimits{
Active: model.NewInt(1),
Active: model.NewPointer(1),
},
}, nil).Once()
team := &model.Team{Name: GenerateTestUsername(), DisplayName: "Some Team", Type: model.TeamOpen}
@ -184,7 +184,7 @@ func TestCreateTeam(t *testing.T) {
cloud.Mock.On("GetCloudLimits", mock.Anything).Return(&model.ProductLimits{
Teams: &model.TeamsLimits{
Active: model.NewInt(200),
Active: model.NewPointer(200),
},
}, nil).Once()
team := &model.Team{Name: GenerateTestUsername(), DisplayName: "Some Team", Type: model.TeamOpen}
@ -412,7 +412,7 @@ func TestUpdateTeam(t *testing.T) {
require.Equal(t, uteam.DisplayName, "Updated Name", "Update failed")
// Test GroupConstrained flag
team.GroupConstrained = model.NewBool(true)
team.GroupConstrained = model.NewPointer(true)
rteam, resp, err := client.UpdateTeam(context.Background(), team)
require.NoError(t, err)
CheckOKStatus(t, resp)
@ -531,10 +531,10 @@ func TestPatchTeam(t *testing.T) {
team, _, _ = th.Client.CreateTeam(context.Background(), team)
patch := &model.TeamPatch{}
patch.DisplayName = model.NewString("Other name")
patch.Description = model.NewString("Other description")
patch.CompanyName = model.NewString("Other company name")
patch.AllowOpenInvite = model.NewBool(true)
patch.DisplayName = model.NewPointer("Other name")
patch.Description = model.NewPointer("Other description")
patch.CompanyName = model.NewPointer("Other company name")
patch.AllowOpenInvite = model.NewPointer(true)
_, resp, err := th.Client.PatchTeam(context.Background(), GenerateTestID(), patch)
require.Error(t, err)
@ -566,7 +566,7 @@ func TestPatchTeam(t *testing.T) {
team2, _, _ = client.CreateTeam(context.Background(), team2)
patch2 := &model.TeamPatch{
AllowOpenInvite: model.NewBool(false),
AllowOpenInvite: model.NewPointer(false),
}
rteam2, _, err3 := client.PatchTeam(context.Background(), team2.Id, patch2)
@ -581,7 +581,7 @@ func TestPatchTeam(t *testing.T) {
team2, _, _ = client.CreateTeam(context.Background(), team2)
patch2 := &model.TeamPatch{
AllowOpenInvite: model.NewBool(true),
AllowOpenInvite: model.NewPointer(true),
}
rteam2, _, err3 := client.PatchTeam(context.Background(), team2.Id, patch2)
@ -592,7 +592,7 @@ func TestPatchTeam(t *testing.T) {
})
// Test GroupConstrained flag
patch.GroupConstrained = model.NewBool(true)
patch.GroupConstrained = model.NewPointer(true)
rteam, resp, err2 := client.PatchTeam(context.Background(), team.Id, patch)
require.NoError(t, err2)
CheckOKStatus(t, resp)
@ -709,7 +709,7 @@ func TestRestoreTeam(t *testing.T) {
cloud.Mock.On("GetCloudLimits", mock.Anything).Return(&model.ProductLimits{
Teams: &model.TeamsLimits{
Active: model.NewInt(1),
Active: model.NewPointer(1),
},
}, nil).Once()
@ -730,7 +730,7 @@ func TestRestoreTeam(t *testing.T) {
cloud.Mock.On("GetCloudLimits", mock.Anything).Return(&model.ProductLimits{
Teams: &model.TeamsLimits{
Active: model.NewInt(200),
Active: model.NewPointer(200),
},
}, nil).Twice()
team := createTeam(t, true, model.TeamOpen)
@ -917,9 +917,9 @@ func TestTeamUnicodeNames(t *testing.T) {
patch := &model.TeamPatch{}
patch.DisplayName = model.NewString("Goat\u206e Team")
patch.Description = model.NewString("\ufffaGreat team.")
patch.CompanyName = model.NewString("\u202bAcme Inc\u202c")
patch.DisplayName = model.NewPointer("Goat\u206e Team")
patch.Description = model.NewPointer("\ufffaGreat team.")
patch.CompanyName = model.NewPointer("\u202bAcme Inc\u202c")
rteam, _, err := client.PatchTeam(context.Background(), team.Id, patch)
require.NoError(t, err)
@ -1243,7 +1243,7 @@ func TestGetAllTeams(t *testing.T) {
policy, savePolicyErr := th.App.Srv().Store().RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{
RetentionPolicy: model.RetentionPolicy{
DisplayName: "Policy 1",
PostDurationDays: model.NewInt64(30),
PostDurationDays: model.NewPointer(int64(30)),
},
TeamIDs: []string{policyTeam.Id},
})
@ -1568,7 +1568,7 @@ func TestSearchAllTeams(t *testing.T) {
policy, savePolicyErr := th.App.Srv().Store().RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{
RetentionPolicy: model.RetentionPolicy{
DisplayName: "Policy 1",
PostDurationDays: model.NewInt64(30),
PostDurationDays: model.NewPointer(int64(30)),
},
TeamIDs: []string{policyTeam.Id},
})
@ -1637,37 +1637,37 @@ func TestSearchAllTeamsPaged(t *testing.T) {
}{
{
Name: "Retrieve foobar team using partial term search",
Search: &model.TeamSearch{Term: "oobardisplay", Page: model.NewInt(0), PerPage: model.NewInt(100)},
Search: &model.TeamSearch{Term: "oobardisplay", Page: model.NewPointer(0), PerPage: model.NewPointer(100)},
ExpectedTeams: []string{foobarTeam.Id},
ExpectedTotalCount: 1,
},
{
Name: "Retrieve foobar team using the beginning of the display name as search text",
Search: &model.TeamSearch{Term: "foobar", Page: model.NewInt(0), PerPage: model.NewInt(100)},
Search: &model.TeamSearch{Term: "foobar", Page: model.NewPointer(0), PerPage: model.NewPointer(100)},
ExpectedTeams: []string{foobarTeam.Id},
ExpectedTotalCount: 1,
},
{
Name: "Retrieve foobar team using the ending of the term of the display name",
Search: &model.TeamSearch{Term: "bardisplayname", Page: model.NewInt(0), PerPage: model.NewInt(100)},
Search: &model.TeamSearch{Term: "bardisplayname", Page: model.NewPointer(0), PerPage: model.NewPointer(100)},
ExpectedTeams: []string{foobarTeam.Id},
ExpectedTotalCount: 1,
},
{
Name: "Retrieve foobar team using partial term search on the name property of team",
Search: &model.TeamSearch{Term: "what", Page: model.NewInt(0), PerPage: model.NewInt(100)},
Search: &model.TeamSearch{Term: "what", Page: model.NewPointer(0), PerPage: model.NewPointer(100)},
ExpectedTeams: []string{foobarTeam.Id},
ExpectedTotalCount: 1,
},
{
Name: "Retrieve foobar team using partial term search on the name property of team #2",
Search: &model.TeamSearch{Term: "ever", Page: model.NewInt(0), PerPage: model.NewInt(100)},
Search: &model.TeamSearch{Term: "ever", Page: model.NewPointer(0), PerPage: model.NewPointer(100)},
ExpectedTeams: []string{foobarTeam.Id},
ExpectedTotalCount: 1,
},
{
Name: "Get all teams on one page",
Search: &model.TeamSearch{Term: commonRandom, Page: model.NewInt(0), PerPage: model.NewInt(100)},
Search: &model.TeamSearch{Term: commonRandom, Page: model.NewPointer(0), PerPage: model.NewPointer(100)},
ExpectedTeams: []string{teams[0].Id, teams[1].Id, teams[2].Id},
ExpectedTotalCount: 3,
},
@ -1691,13 +1691,13 @@ func TestSearchAllTeamsPaged(t *testing.T) {
},
{
Name: "Get 2 teams on the first page",
Search: &model.TeamSearch{Term: commonRandom, Page: model.NewInt(0), PerPage: model.NewInt(2)},
Search: &model.TeamSearch{Term: commonRandom, Page: model.NewPointer(0), PerPage: model.NewPointer(2)},
ExpectedTeams: []string{teams[0].Id, teams[1].Id},
ExpectedTotalCount: 3,
},
{
Name: "Get 1 team on the second page",
Search: &model.TeamSearch{Term: commonRandom, Page: model.NewInt(1), PerPage: model.NewInt(2)},
Search: &model.TeamSearch{Term: commonRandom, Page: model.NewPointer(1), PerPage: model.NewPointer(2)},
ExpectedTeams: []string{teams[2].Id},
ExpectedTotalCount: 3,
},
@ -1727,7 +1727,7 @@ func TestSearchAllTeamsPaged(t *testing.T) {
})
}
_, _, resp, err := th.Client.SearchTeamsPaged(context.Background(), &model.TeamSearch{Term: commonRandom, PerPage: model.NewInt(100)})
_, _, resp, err := th.Client.SearchTeamsPaged(context.Background(), &model.TeamSearch{Term: commonRandom, PerPage: model.NewPointer(100)})
CheckErrorID(t, err, "api.team.search_teams.pagination_not_implemented.public_team_search")
require.Equal(t, http.StatusNotImplemented, resp.StatusCode)
}
@ -2329,7 +2329,7 @@ func TestAddTeamMember(t *testing.T) {
require.Nil(t, tm, "should have not returned team member")
// Set a team to group-constrained
team.GroupConstrained = model.NewBool(true)
team.GroupConstrained = model.NewPointer(true)
_, appErr = th.App.UpdateTeam(team)
require.Nil(t, appErr)
@ -2648,7 +2648,7 @@ func TestAddTeamMembers(t *testing.T) {
CheckForbiddenStatus(t, resp)
// Set a team to group-constrained
team.GroupConstrained = model.NewBool(true)
team.GroupConstrained = model.NewPointer(true)
_, appErr = th.App.UpdateTeam(team)
require.Nil(t, appErr)
@ -2721,7 +2721,7 @@ func TestRemoveTeamMember(t *testing.T) {
require.NoError(t, err)
// If the team is group-constrained the user cannot be removed
th.BasicTeam.GroupConstrained = model.NewBool(true)
th.BasicTeam.GroupConstrained = model.NewPointer(true)
_, appErr := th.App.UpdateTeam(th.BasicTeam)
require.Nil(t, appErr)
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
@ -3860,7 +3860,7 @@ func TestTeamMembersMinusGroupMembers(t *testing.T) {
user2 := th.BasicUser2
team := th.CreateTeam()
team.GroupConstrained = model.NewBool(true)
team.GroupConstrained = model.NewPointer(true)
team, appErr := th.App.UpdateTeam(team)
require.Nil(t, appErr)

View File

@ -62,7 +62,7 @@ func (api *API) InitUser() {
api.BaseRoutes.User.Handle("/mfa/generate", api.APISessionRequiredMfa(generateMfaSecret)).Methods(http.MethodPost)
api.BaseRoutes.Users.Handle("/login", api.APIHandler(login)).Methods(http.MethodPost)
api.BaseRoutes.Users.Handle("/login/desktop_token", api.RateLimitedHandler(api.APIHandler(loginWithDesktopToken), model.RateLimitSettings{PerSec: model.NewInt(2), MaxBurst: model.NewInt(1)})).Methods(http.MethodPost)
api.BaseRoutes.Users.Handle("/login/desktop_token", api.RateLimitedHandler(api.APIHandler(loginWithDesktopToken), model.RateLimitSettings{PerSec: model.NewPointer(2), MaxBurst: model.NewPointer(1)})).Methods(http.MethodPost)
api.BaseRoutes.Users.Handle("/login/switch", api.APIHandler(switchAccountType)).Methods(http.MethodPost)
api.BaseRoutes.Users.Handle("/login/cws", api.APIHandlerTrustRequester(loginCWS)).Methods(http.MethodPost)
api.BaseRoutes.Users.Handle("/logout", api.APIHandler(logout)).Methods(http.MethodPost)

View File

@ -138,7 +138,7 @@ func TestCreateUser(t *testing.T) {
email := th.GenerateTestEmail()
newUser := &model.User{
Id: model.NewId(),
RemoteId: model.NewString(model.NewId()),
RemoteId: model.NewPointer(model.NewId()),
Email: email,
Password: "Password1",
Username: GenerateTestUsername(),
@ -281,7 +281,7 @@ func TestCreateUserInputFilter(t *testing.T) {
Email: "foobar+testdomainrestriction@mattermost.org",
Username: GenerateTestUsername(),
AuthService: "ldap",
AuthData: model.NewString("999099"),
AuthData: model.NewPointer("999099"),
}
u, _, err := th.SystemAdminClient.CreateUser(context.Background(), user)
require.NoError(t, err)
@ -293,7 +293,7 @@ func TestCreateUserInputFilter(t *testing.T) {
Email: "foobar+testdomainrestrictionlocalclient@mattermost.org",
Username: GenerateTestUsername(),
AuthService: "ldap",
AuthData: model.NewString("999100"),
AuthData: model.NewPointer("999100"),
}
u, _, err := th.LocalClient.CreateUser(context.Background(), user)
require.NoError(t, err)
@ -698,12 +698,12 @@ func TestCreateUserWithInviteId(t *testing.T) {
t.Run("GroupConstrainedTeam", func(t *testing.T) {
user := model.User{Email: th.GenerateTestEmail(), Nickname: "", Password: "hello1", Username: GenerateTestUsername(), Roles: model.SystemAdminRoleId + " " + model.SystemUserRoleId}
th.BasicTeam.GroupConstrained = model.NewBool(true)
th.BasicTeam.GroupConstrained = model.NewPointer(true)
team, appErr := th.App.UpdateTeam(th.BasicTeam)
require.Nil(t, appErr)
defer func() {
th.BasicTeam.GroupConstrained = model.NewBool(false)
th.BasicTeam.GroupConstrained = model.NewPointer(false)
_, appErr = th.App.UpdateTeam(th.BasicTeam)
require.Nil(t, appErr)
}()
@ -717,12 +717,12 @@ func TestCreateUserWithInviteId(t *testing.T) {
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
user := model.User{Email: th.GenerateTestEmail(), Nickname: "", Password: "hello1", Username: GenerateTestUsername(), Roles: model.SystemAdminRoleId + " " + model.SystemUserRoleId}
th.BasicTeam.GroupConstrained = model.NewBool(true)
th.BasicTeam.GroupConstrained = model.NewPointer(true)
team, appErr := th.App.UpdateTeam(th.BasicTeam)
require.Nil(t, appErr)
defer func() {
th.BasicTeam.GroupConstrained = model.NewBool(false)
th.BasicTeam.GroupConstrained = model.NewPointer(false)
_, appErr = th.App.UpdateTeam(th.BasicTeam)
require.Nil(t, appErr)
}()
@ -1381,10 +1381,10 @@ func TestSearchUsers(t *testing.T) {
id := model.NewId()
group, appErr := th.App.CreateGroup(&model.Group{
DisplayName: "dn-foo_" + 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()),
})
assert.Nil(t, appErr)
@ -1421,10 +1421,10 @@ func TestSearchUsers(t *testing.T) {
id = model.NewId()
group, appErr = th.App.CreateGroup(&model.Group{
DisplayName: "dn-foo_" + id,
Name: model.NewString("name" + id),
Name: model.NewPointer("name" + id),
Source: model.GroupSourceCustom,
Description: "description_" + id,
RemoteId: model.NewString(model.NewId()),
RemoteId: model.NewPointer(model.NewId()),
})
assert.Nil(t, appErr)
@ -2061,10 +2061,10 @@ func TestPatchUser(t *testing.T) {
})
patch := &model.UserPatch{}
patch.Password = model.NewString("testpassword")
patch.Nickname = model.NewString("Joram Wilander")
patch.FirstName = model.NewString("Joram")
patch.LastName = model.NewString("Wilander")
patch.Password = model.NewPointer("testpassword")
patch.Nickname = model.NewPointer("Joram Wilander")
patch.FirstName = model.NewPointer("Joram")
patch.LastName = model.NewPointer("Wilander")
patch.Position = new(string)
patch.NotifyProps = model.StringMap{}
patch.NotifyProps["comment"] = "somethingrandom"
@ -2099,19 +2099,19 @@ func TestPatchUser(t *testing.T) {
require.Nil(t, appErr, "Password should still match")
patch = &model.UserPatch{}
patch.Email = model.NewString(th.GenerateTestEmail())
patch.Email = model.NewPointer(th.GenerateTestEmail())
_, resp, err := th.Client.PatchUser(context.Background(), user.Id, patch)
require.Error(t, err)
CheckBadRequestStatus(t, resp)
patch.Password = model.NewString(currentPassword)
patch.Password = model.NewPointer(currentPassword)
ruser, _, err = th.Client.PatchUser(context.Background(), user.Id, patch)
require.NoError(t, err)
require.Equal(t, *patch.Email, ruser.Email, "Email should update properly")
patch.Username = model.NewString(th.BasicUser2.Username)
patch.Username = model.NewPointer(th.BasicUser2.Username)
_, resp, err = th.Client.PatchUser(context.Background(), user.Id, patch)
require.Error(t, err)
CheckBadRequestStatus(t, resp)
@ -2135,7 +2135,7 @@ func TestPatchUser(t *testing.T) {
session.IsOAuth = true
th.App.AddSessionToCache(session)
patch.Email = model.NewString(th.GenerateTestEmail())
patch.Email = model.NewPointer(th.GenerateTestEmail())
_, resp, err = th.Client.PatchUser(context.Background(), user.Id, patch)
require.Error(t, err)
CheckForbiddenStatus(t, resp)
@ -2164,7 +2164,7 @@ func TestPatchBotUser(t *testing.T) {
bot := th.CreateBotWithSystemAdminClient()
patch := &model.UserPatch{}
patch.Email = model.NewString("newemail@test.com")
patch.Email = model.NewPointer("newemail@test.com")
user, _, err := th.SystemAdminClient.PatchUser(context.Background(), bot.UserId, patch)
require.NoError(t, err)
@ -2183,7 +2183,7 @@ func TestPatchAdminUser(t *testing.T) {
th.App.UpdateUserRoles(th.Context, user.Id, model.SystemUserRoleId+" "+model.SystemAdminRoleId, false)
patch := &model.UserPatch{}
patch.Email = model.NewString(th.GenerateTestEmail())
patch.Email = model.NewPointer(th.GenerateTestEmail())
th.AddPermissionToRole(model.PermissionEditOtherUsers.Id, model.SystemUserManagerRoleId)
th.App.UpdateUserRoles(th.Context, th.BasicUser.Id, model.SystemUserManagerRoleId+" "+model.SystemUserAccessTokenRoleId, false)
@ -2244,9 +2244,9 @@ func TestUserUnicodeNames(t *testing.T) {
client.Login(context.Background(), user.Email, user.Password)
patch := &model.UserPatch{}
patch.Nickname = model.NewString("\U000E0000Ender\u206d Wiggin\U000E007F")
patch.FirstName = model.NewString("\U0001d173Andrew\U0001d17a")
patch.LastName = model.NewString("\u2028Wiggin\u2029")
patch.Nickname = model.NewPointer("\U000E0000Ender\u206d Wiggin\U000E007F")
patch.FirstName = model.NewPointer("\U0001d173Andrew\U0001d17a")
patch.LastName = model.NewPointer("\u2028Wiggin\u2029")
ruser, _, err := client.PatchUser(context.Background(), user.Id, patch)
require.NoError(t, err)
@ -2279,7 +2279,7 @@ func TestUpdateUserAuth(t *testing.T) {
_, respErr, _ := th.SystemAdminClient.UpdateUserAuth(context.Background(), user.Id, userAuth)
require.NotNil(t, respErr, "Shouldn't have permissions. Only Admins")
userAuth.AuthData = model.NewString("test@test.com")
userAuth.AuthData = model.NewPointer("test@test.com")
userAuth.AuthService = model.UserAuthServiceSaml
ruser, _, err := th.SystemAdminClient.UpdateUserAuth(context.Background(), user.Id, userAuth)
require.NoError(t, err)
@ -3068,20 +3068,20 @@ func TestGetUsersInGroup(t *testing.T) {
id := model.NewId()
group, appErr := th.App.CreateGroup(&model.Group{
DisplayName: "dn-foo_" + 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()),
})
assert.Nil(t, appErr)
cid := model.NewId()
customGroup, appErr := th.App.CreateGroup(&model.Group{
DisplayName: "dn-foo_" + cid,
Name: model.NewString("name" + cid),
Name: model.NewPointer("name" + cid),
Source: model.GroupSourceCustom,
Description: "description_" + cid,
RemoteId: model.NewString(model.NewId()),
RemoteId: model.NewPointer(model.NewId()),
})
assert.Nil(t, appErr)
@ -3145,10 +3145,10 @@ func TestGetUsersInGroupByDisplayName(t *testing.T) {
id := model.NewId()
group, appErr := th.App.CreateGroup(&model.Group{
DisplayName: "dn-foo_" + 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()),
})
assert.Nil(t, appErr)
@ -3930,7 +3930,7 @@ func TestLogin(t *testing.T) {
t.Run("remote user login rejected", func(t *testing.T) {
email := th.GenerateTestEmail()
user := model.User{Email: email, Nickname: "Darth Vader", Password: "hello1", Username: GenerateTestUsername(), Roles: model.SystemAdminRoleId + " " + model.SystemUserRoleId, RemoteId: model.NewString("remote-id")}
user := model.User{Email: email, Nickname: "Darth Vader", Password: "hello1", Username: GenerateTestUsername(), Roles: model.SystemAdminRoleId + " " + model.SystemUserRoleId, RemoteId: model.NewPointer("remote-id")}
ruser, appErr := th.App.CreateUser(th.Context, &user)
require.Nil(t, appErr)
@ -4702,7 +4702,7 @@ func TestCreateUserAccessToken(t *testing.T) {
// make a remote user
remoteUser, appErr := th.App.CreateUser(request.TestContext(t), &model.User{
Username: "remoteuser",
RemoteId: model.NewString(model.NewId()),
RemoteId: model.NewPointer(model.NewId()),
Password: model.NewId(),
Email: "remoteuser@example.com",
})
@ -6415,7 +6415,7 @@ func TestGetThreadsForUser(t *testing.T) {
Message: "testMsg",
Metadata: &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString(model.PostPriorityUrgent),
Priority: model.NewPointer(model.PostPriorityUrgent),
},
},
})
@ -6442,7 +6442,7 @@ func TestGetThreadsForUser(t *testing.T) {
Message: "testReply",
Metadata: &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString(model.PostPriorityUrgent),
Priority: model.NewPointer(model.PostPriorityUrgent),
},
},
})
@ -6462,7 +6462,7 @@ func TestGetThreadsForUser(t *testing.T) {
Message: "testMsg",
Metadata: &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString(model.PostPriorityUrgent),
Priority: model.NewPointer(model.PostPriorityUrgent),
},
},
})
@ -7235,7 +7235,7 @@ func TestSingleThreadGet(t *testing.T) {
Message: "testMsg2",
Metadata: &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString(model.PostPriorityUrgent),
Priority: model.NewPointer(model.PostPriorityUrgent),
},
},
})
@ -7588,7 +7588,7 @@ func TestPatchAndUpdateWithProviderAttributes(t *testing.T) {
model.ServiceOpenid,
} {
user := th.CreateUserWithAuth(authService)
patch := &model.UserPatch{Username: model.NewString("something new")}
patch := &model.UserPatch{Username: model.NewPointer("something new")}
conflictField := th.App.CheckProviderAttributes(th.Context, user, patch)
require.NotEqual(t, "", conflictField)
}

View File

@ -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))

View File

@ -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),
},
},
}

View File

@ -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))
}
}
}

View File

@ -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)),
},
}

View File

@ -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.

View File

@ -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),

View File

@ -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)

View File

@ -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, "")

View File

@ -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{})

View File

@ -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

View File

@ -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

View File

@ -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()

View File

@ -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)

View File

@ -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)

View File

@ -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) {

View File

@ -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{

View File

@ -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{

View File

@ -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,
})

View File

@ -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)

View File

@ -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)
})

View File

@ -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)
}
}

View File

@ -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)

View File

@ -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{}

View File

@ -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 {

View File

@ -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

View File

@ -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)

View File

@ -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 {

View File

@ -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)
},
},
}

View File

@ -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

View File

@ -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, "![image]("+proxiedImageURL+")", rpost.Message)
patch := &model.PostPatch{
Message: model.NewString("![image](" + imageURL + ")"),
Message: model.NewPointer("![image](" + imageURL + ")"),
}
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)

View File

@ -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{

View File

@ -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)

View File

@ -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

View File

@ -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,

View File

@ -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

View File

@ -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)
}
}

View File

@ -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++ {

View File

@ -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)

View File

@ -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)

View File

@ -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
}

View File

@ -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)

View File

@ -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),
},
},
} {

View File

@ -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)

View File

@ -54,10 +54,10 @@ func TestScheduler(t *testing.T) {
Cfg: &model.Config{
// mock config
DataRetentionSettings: model.DataRetentionSettings{
EnableMessageDeletion: model.NewBool(true),
EnableMessageDeletion: model.NewPointer(true),
},
MessageExportSettings: model.MessageExportSettings{
EnableExport: model.NewBool(true),
EnableExport: model.NewPointer(true),
},
},
},

View File

@ -145,7 +145,7 @@ func getMockStore(t *testing.T) *mocks.Store {
fakeUser := []*model.User{{
Id: "123",
AuthData: model.NewString("authData"),
AuthData: model.NewPointer("authData"),
AuthService: "authService",
}}
mockUserStore := mocks.UserStore{}
@ -164,7 +164,7 @@ func getMockStore(t *testing.T) *mocks.Store {
fakeUser[0],
{
Id: "456",
AuthData: model.NewString("authData"),
AuthData: model.NewPointer("authData"),
AuthService: "authService",
},
}

View File

@ -25,7 +25,7 @@ func TestUserStoreCache(t *testing.T) {
fakeUserIds := []string{"123"}
fakeUser := []*model.User{{
Id: "123",
AuthData: model.NewString("authData"),
AuthData: model.NewPointer("authData"),
AuthService: "authService",
}}
@ -231,7 +231,7 @@ func TestUserStoreGetCache(t *testing.T) {
fakeUserId := "123"
fakeUser := &model.User{
Id: "123",
AuthData: model.NewString("authData"),
AuthData: model.NewPointer("authData"),
AuthService: "authService",
}
t.Run("first call not cached, second cached and returning same data", func(t *testing.T) {
@ -301,12 +301,12 @@ func TestUserStoreGetCache(t *testing.T) {
func TestUserStoreGetManyCache(t *testing.T) {
fakeUser := &model.User{
Id: "123",
AuthData: model.NewString("authData"),
AuthData: model.NewPointer("authData"),
AuthService: "authService",
}
otherFakeUser := &model.User{
Id: "456",
AuthData: model.NewString("authData"),
AuthData: model.NewPointer("authData"),
AuthService: "authService",
}
t.Run("first call not cached, second cached and returning same data", func(t *testing.T) {

View File

@ -33,7 +33,7 @@ func TestUpdateConfigRace(t *testing.T) {
cfg := &model.Config{}
cfg.SetDefaults()
cfg.ClusterSettings.GossipPort = model.NewInt(9999)
cfg.ClusterSettings.GossipPort = model.NewPointer(9999)
searchEngine := searchengine.NewBroker(cfg)
layer := searchlayer.NewSearchLayer(&testlib.TestStore{Store: store}, searchEngine, cfg)
var wg sync.WaitGroup

View File

@ -153,7 +153,7 @@ func (s SqlChannelMemberHistoryStore) getFromChannelMembersTable(startTime int64
// we have to fill in the join/leave times, because that data doesn't exist in the channel members table
for _, channelMemberHistory := range histories {
channelMemberHistory.JoinTime = startTime
channelMemberHistory.LeaveTime = model.NewInt64(endTime)
channelMemberHistory.LeaveTime = model.NewPointer(endTime)
}
return histories, nil
}

View File

@ -593,7 +593,7 @@ func (s SqlChannelStore) CreateDirectChannel(rctx request.CTX, user *model.User,
channel.Header = ""
channel.Type = model.ChannelTypeDirect
channel.Shared = model.NewBool(user.IsRemote() || otherUser.IsRemote())
channel.Shared = model.NewPointer(user.IsRemote() || otherUser.IsRemote())
channel.CreatorId = user.Id
cm1 := &model.ChannelMember{

View File

@ -1157,7 +1157,7 @@ type groupWithSchemeAdmin struct {
func (g groupWithSchemeAdmin) ToModel() *model.GroupWithSchemeAdmin {
if g.SyncableSchemeAdmin == nil {
g.SyncableSchemeAdmin = model.NewBool(false)
g.SyncableSchemeAdmin = model.NewPointer(false)
}
res := &model.GroupWithSchemeAdmin{
Group: *g.group.ToModel(),

View File

@ -856,7 +856,7 @@ func TestCheckTeamsChannelsIntegrity(t *testing.T) {
ChildId: &channel.Id,
}, data.Records[0])
require.Equal(t, model.OrphanedRecord{
ParentId: model.NewString("test"),
ParentId: model.NewPointer("test"),
ChildId: &direct.Id,
}, data.Records[1])
dbmap.Exec(`DELETE FROM Channels WHERE Id=?`, channel.Id)

View File

@ -1156,7 +1156,7 @@ func (s *SqlPostStore) prepareThreadedResponse(posts []*postWithExtra, extended,
processPost := func(p *postWithExtra) error {
p.Post.ReplyCount = p.ThreadReplyCount
if p.IsFollowing != nil {
p.Post.IsFollowing = model.NewBool(*p.IsFollowing)
p.Post.IsFollowing = model.NewPointer(*p.IsFollowing)
}
for _, userID := range p.ThreadParticipants {
participant, ok := usersMap[userID]

View File

@ -462,7 +462,7 @@ func (s *SqlRetentionPolicyStore) GetChannels(policyId string, offset, limit int
}
for _, channel := range channels {
channel.PolicyID = model.NewString(policyId)
channel.PolicyID = model.NewPointer(policyId)
}
return channels, nil

View File

@ -537,8 +537,8 @@ func TestIsBinaryParamEnabled(t *testing.T) {
{
store: SqlStore{
settings: &model.SqlSettings{
DriverName: model.NewString(model.DatabaseDriverPostgres),
DataSource: model.NewString("postgres://mmuser:mostest@localhost/loadtest?sslmode=disable\u0026binary_parameters=yes"),
DriverName: model.NewPointer(model.DatabaseDriverPostgres),
DataSource: model.NewPointer("postgres://mmuser:mostest@localhost/loadtest?sslmode=disable\u0026binary_parameters=yes"),
},
},
expected: true,
@ -546,8 +546,8 @@ func TestIsBinaryParamEnabled(t *testing.T) {
{
store: SqlStore{
settings: &model.SqlSettings{
DriverName: model.NewString(model.DatabaseDriverMysql),
DataSource: model.NewString("postgres://mmuser:mostest@localhost/loadtest?sslmode=disable\u0026binary_parameters=yes"),
DriverName: model.NewPointer(model.DatabaseDriverMysql),
DataSource: model.NewPointer("postgres://mmuser:mostest@localhost/loadtest?sslmode=disable\u0026binary_parameters=yes"),
},
},
expected: false,
@ -555,8 +555,8 @@ func TestIsBinaryParamEnabled(t *testing.T) {
{
store: SqlStore{
settings: &model.SqlSettings{
DriverName: model.NewString(model.DatabaseDriverPostgres),
DataSource: model.NewString("postgres://mmuser:mostest@localhost/loadtest?sslmode=disable&binary_parameters=yes"),
DriverName: model.NewPointer(model.DatabaseDriverPostgres),
DataSource: model.NewPointer("postgres://mmuser:mostest@localhost/loadtest?sslmode=disable&binary_parameters=yes"),
},
},
expected: true,
@ -564,8 +564,8 @@ func TestIsBinaryParamEnabled(t *testing.T) {
{
store: SqlStore{
settings: &model.SqlSettings{
DriverName: model.NewString(model.DatabaseDriverPostgres),
DataSource: model.NewString("postgres://mmuser:mostest@localhost/loadtest?sslmode=disable"),
DriverName: model.NewPointer(model.DatabaseDriverPostgres),
DataSource: model.NewPointer("postgres://mmuser:mostest@localhost/loadtest?sslmode=disable"),
},
},
expected: false,
@ -760,9 +760,9 @@ func TestReplicaLagQuery(t *testing.T) {
}
settings.ReplicaLagSettings = []*model.ReplicaLagSettings{{
DataSource: model.NewString(*settings.DataSource),
QueryAbsoluteLag: model.NewString(query),
QueryTimeLag: model.NewString(query),
DataSource: model.NewPointer(*settings.DataSource),
QueryAbsoluteLag: model.NewPointer(query),
QueryTimeLag: model.NewPointer(query),
}}
mockMetrics := &mocks.MetricsInterface{}

View File

@ -546,16 +546,16 @@ func (s SqlTeamStore) SearchAllPaged(opts *model.TeamSearch) ([]*model.Team, int
// SearchOpen returns from the database a list of public teams that match the Name or DisplayName
// passed as the term search parameter.
func (s SqlTeamStore) SearchOpen(opts *model.TeamSearch) ([]*model.Team, error) {
opts.TeamType = model.NewString("O")
opts.AllowOpenInvite = model.NewBool(true)
opts.TeamType = model.NewPointer("O")
opts.AllowOpenInvite = model.NewPointer(true)
return s.SearchAll(opts)
}
// SearchPrivate returns from the database a list of private teams that match the Name or DisplayName
// passed as the term search parameter.
func (s SqlTeamStore) SearchPrivate(opts *model.TeamSearch) ([]*model.Team, error) {
opts.TeamType = model.NewString("O")
opts.AllowOpenInvite = model.NewBool(false)
opts.TeamType = model.NewPointer("O")
opts.AllowOpenInvite = model.NewPointer(false)
return s.SearchAll(opts)
}

View File

@ -377,7 +377,7 @@ func testPermanentDeleteBatchForRetentionPolicies(t *testing.T, rctx request.CTX
channelPolicy, err := ss.RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{
RetentionPolicy: model.RetentionPolicy{
DisplayName: "DisplayName",
PostDurationDays: model.NewInt64(30),
PostDurationDays: model.NewPointer(int64(30)),
},
ChannelIDs: []string{channel.Id},
})

View File

@ -3858,10 +3858,10 @@ func testChannelStoreGetAllChannels(t *testing.T, rctx request.CTX, ss store.Sto
require.NoError(t, nErr)
group := &model.Group{
Name: model.NewString(model.NewId()),
Name: model.NewPointer(model.NewId()),
DisplayName: model.NewId(),
Source: model.GroupSourceLdap,
RemoteId: model.NewString(model.NewId()),
RemoteId: model.NewPointer(model.NewId()),
}
_, err = ss.Group().Create(group)
require.NoError(t, err)
@ -3949,7 +3949,7 @@ func testChannelStoreGetAllChannels(t *testing.T, rctx request.CTX, ss store.Sto
policy, nErr := ss.RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{
RetentionPolicy: model.RetentionPolicy{
DisplayName: "Policy 1",
PostDurationDays: model.NewInt64(30),
PostDurationDays: model.NewPointer(int64(30)),
},
ChannelIDs: []string{c1.Id},
})
@ -4768,9 +4768,9 @@ func testCountUrgentPostsAfter(t *testing.T, rctx request.CTX, ss store.Store) {
CreateAt: 1000,
Metadata: &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString(model.PostPriorityUrgent),
RequestedAck: model.NewBool(false),
PersistentNotifications: model.NewBool(false),
Priority: model.NewPointer(model.PostPriorityUrgent),
RequestedAck: model.NewPointer(false),
PersistentNotifications: model.NewPointer(false),
},
},
})
@ -4782,9 +4782,9 @@ func testCountUrgentPostsAfter(t *testing.T, rctx request.CTX, ss store.Store) {
CreateAt: 1001,
Metadata: &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("important"),
RequestedAck: model.NewBool(false),
PersistentNotifications: model.NewBool(false),
Priority: model.NewPointer("important"),
RequestedAck: model.NewPointer(false),
PersistentNotifications: model.NewPointer(false),
},
},
})
@ -4803,9 +4803,9 @@ func testCountUrgentPostsAfter(t *testing.T, rctx request.CTX, ss store.Store) {
CreateAt: 1003,
Metadata: &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString(model.PostPriorityUrgent),
RequestedAck: model.NewBool(false),
PersistentNotifications: model.NewBool(false),
Priority: model.NewPointer(model.PostPriorityUrgent),
RequestedAck: model.NewPointer(false),
PersistentNotifications: model.NewPointer(false),
},
},
})
@ -5215,10 +5215,10 @@ func testGetMemberCountsByGroup(t *testing.T, rctx request.CTX, ss store.Store)
var memberCounts []*model.ChannelMemberCountByGroup
teamId := model.NewId()
g1 := &model.Group{
Name: model.NewString(model.NewId()),
Name: model.NewPointer(model.NewId()),
DisplayName: model.NewId(),
Source: model.GroupSourceLdap,
RemoteId: model.NewString(model.NewId()),
RemoteId: model.NewPointer(model.NewId()),
}
_, err := ss.Group().Create(g1)
require.NoError(t, err)
@ -5287,10 +5287,10 @@ func testGetMemberCountsByGroup(t *testing.T, rctx request.CTX, ss store.Store)
})
g2 := &model.Group{
Name: model.NewString(model.NewId()),
Name: model.NewPointer(model.NewId()),
DisplayName: model.NewId(),
Source: model.GroupSourceLdap,
RemoteId: model.NewString(model.NewId()),
RemoteId: model.NewPointer(model.NewId()),
}
_, err = ss.Group().Create(g2)
require.NoError(t, err)
@ -5326,10 +5326,10 @@ func testGetMemberCountsByGroup(t *testing.T, rctx request.CTX, ss store.Store)
}
g3 := &model.Group{
Name: model.NewString(model.NewId()),
Name: model.NewPointer(model.NewId()),
DisplayName: model.NewId(),
Source: model.GroupSourceLdap,
RemoteId: model.NewString(model.NewId()),
RemoteId: model.NewPointer(model.NewId()),
}
_, err = ss.Group().Create(g3)
@ -6379,7 +6379,7 @@ func testChannelStoreSearchAllChannels(t *testing.T, rctx request.CTX, ss store.
DisplayName: "A5 ChannelC",
Name: NewTestId(),
Type: model.ChannelTypePrivate,
GroupConstrained: model.NewBool(true),
GroupConstrained: model.NewPointer(true),
}
_, nErr = ss.Channel().Save(rctx, &o5, -1)
require.NoError(t, nErr)
@ -6403,10 +6403,10 @@ func testChannelStoreSearchAllChannels(t *testing.T, rctx request.CTX, ss store.
require.NoError(t, nErr)
group := &model.Group{
Name: model.NewString(model.NewId()),
Name: model.NewPointer(model.NewId()),
DisplayName: model.NewId(),
Source: model.GroupSourceLdap,
RemoteId: model.NewString(model.NewId()),
RemoteId: model.NewPointer(model.NewId()),
}
_, err = ss.Group().Create(group)
require.NoError(t, err)
@ -6486,7 +6486,7 @@ func testChannelStoreSearchAllChannels(t *testing.T, rctx request.CTX, ss store.
_, nErr = ss.RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{
RetentionPolicy: model.RetentionPolicy{
DisplayName: "Policy 1",
PostDurationDays: model.NewInt64(30),
PostDurationDays: model.NewPointer(int64(30)),
},
ChannelIDs: []string{o14.Id},
})
@ -6518,24 +6518,24 @@ func testChannelStoreSearchAllChannels(t *testing.T, rctx request.CTX, ss store.
{"exclude defaults search 'off'", "off-", store.ChannelSearchOpts{IncludeDeleted: false, ExcludeChannelNames: []string{"off-topic"}}, model.ChannelList{&o7, &o8}, 0},
{"exclude defaults search 'town'", "town", store.ChannelSearchOpts{IncludeDeleted: false, ExcludeChannelNames: []string{"town-square"}}, model.ChannelList{}, 0},
{"exclude by group association", "off-", store.ChannelSearchOpts{IncludeDeleted: false, NotAssociatedToGroup: group.Id}, model.ChannelList{&o6, &o8}, 0},
{"paginate includes count", "off-", store.ChannelSearchOpts{IncludeDeleted: false, PerPage: model.NewInt(100)}, model.ChannelList{&o6, &o7, &o8}, 3},
{"paginate, page 2 correct entries and count", "off-", store.ChannelSearchOpts{IncludeDeleted: false, PerPage: model.NewInt(2), Page: model.NewInt(1)}, model.ChannelList{&o8}, 3},
{"paginate includes count", "off-", store.ChannelSearchOpts{IncludeDeleted: false, PerPage: model.NewPointer(100)}, model.ChannelList{&o6, &o7, &o8}, 3},
{"paginate, page 2 correct entries and count", "off-", store.ChannelSearchOpts{IncludeDeleted: false, PerPage: model.NewPointer(2), Page: model.NewPointer(1)}, model.ChannelList{&o8}, 3},
{"Filter private", "", store.ChannelSearchOpts{IncludeDeleted: false, Private: true}, model.ChannelList{&o4, &o5, &o8}, 3},
{"Filter public", "", store.ChannelSearchOpts{IncludeDeleted: false, Public: true, Page: model.NewInt(0), PerPage: model.NewInt(5)}, model.ChannelList{&o1, &o2, &o3, &o6, &o7}, 10},
{"Filter public and private", "", store.ChannelSearchOpts{IncludeDeleted: false, Public: true, Private: true, Page: model.NewInt(0), PerPage: model.NewInt(5)}, model.ChannelList{&o1, &o2, &o3, &o4, &o5}, 13},
{"Filter public and private and include deleted", "", store.ChannelSearchOpts{IncludeDeleted: true, Public: true, Private: true, Page: model.NewInt(0), PerPage: model.NewInt(5)}, model.ChannelList{&o1, &o2, &o3, &o4, &o5}, 14},
{"Filter group constrained", "", store.ChannelSearchOpts{IncludeDeleted: false, GroupConstrained: true, Page: model.NewInt(0), PerPage: model.NewInt(5)}, model.ChannelList{&o5}, 1},
{"Filter exclude group constrained and include deleted", "", store.ChannelSearchOpts{IncludeDeleted: true, ExcludeGroupConstrained: true, Page: model.NewInt(0), PerPage: model.NewInt(5)}, model.ChannelList{&o1, &o2, &o3, &o4, &o6}, 13},
{"Filter private and exclude group constrained", "", store.ChannelSearchOpts{IncludeDeleted: false, ExcludeGroupConstrained: true, Private: true, Page: model.NewInt(0), PerPage: model.NewInt(5)}, model.ChannelList{&o4, &o8}, 2},
{"Filter public", "", store.ChannelSearchOpts{IncludeDeleted: false, Public: true, Page: model.NewPointer(0), PerPage: model.NewPointer(5)}, model.ChannelList{&o1, &o2, &o3, &o6, &o7}, 10},
{"Filter public and private", "", store.ChannelSearchOpts{IncludeDeleted: false, Public: true, Private: true, Page: model.NewPointer(0), PerPage: model.NewPointer(5)}, model.ChannelList{&o1, &o2, &o3, &o4, &o5}, 13},
{"Filter public and private and include deleted", "", store.ChannelSearchOpts{IncludeDeleted: true, Public: true, Private: true, Page: model.NewPointer(0), PerPage: model.NewPointer(5)}, model.ChannelList{&o1, &o2, &o3, &o4, &o5}, 14},
{"Filter group constrained", "", store.ChannelSearchOpts{IncludeDeleted: false, GroupConstrained: true, Page: model.NewPointer(0), PerPage: model.NewPointer(5)}, model.ChannelList{&o5}, 1},
{"Filter exclude group constrained and include deleted", "", store.ChannelSearchOpts{IncludeDeleted: true, ExcludeGroupConstrained: true, Page: model.NewPointer(0), PerPage: model.NewPointer(5)}, model.ChannelList{&o1, &o2, &o3, &o4, &o6}, 13},
{"Filter private and exclude group constrained", "", store.ChannelSearchOpts{IncludeDeleted: false, ExcludeGroupConstrained: true, Private: true, Page: model.NewPointer(0), PerPage: model.NewPointer(5)}, model.ChannelList{&o4, &o8}, 2},
{"Exclude policy constrained", "", store.ChannelSearchOpts{ExcludePolicyConstrained: true}, model.ChannelList{&o1, &o2, &o3, &o4, &o5, &o6, &o7, &o8, &o9, &o10, &o11, &o12}, 0},
{"Filter team 2", "", store.ChannelSearchOpts{IncludeDeleted: false, TeamIds: []string{t2.Id}, Page: model.NewInt(0), PerPage: model.NewInt(5)}, model.ChannelList{&o2, &o14}, 2},
{"Filter team 2, private", "", store.ChannelSearchOpts{IncludeDeleted: false, TeamIds: []string{t2.Id}, Private: true, Page: model.NewInt(0), PerPage: model.NewInt(5)}, model.ChannelList{}, 0},
{"Filter team 1 and team 2, private", "", store.ChannelSearchOpts{IncludeDeleted: false, TeamIds: []string{t1.Id, t2.Id}, Private: true, Page: model.NewInt(0), PerPage: model.NewInt(5)}, model.ChannelList{&o4, &o5, &o8}, 3},
{"Filter team 1 and team 2, public and private", "", store.ChannelSearchOpts{IncludeDeleted: false, TeamIds: []string{t1.Id, t2.Id}, Public: true, Private: true, Page: model.NewInt(0), PerPage: model.NewInt(5)}, model.ChannelList{&o1, &o2, &o3, &o4, &o5}, 13},
{"Filter team 1 and team 2, public and private and group constrained", "", store.ChannelSearchOpts{IncludeDeleted: false, TeamIds: []string{t1.Id, t2.Id}, Public: true, Private: true, GroupConstrained: true, Page: model.NewInt(0), PerPage: model.NewInt(5)}, model.ChannelList{&o5}, 1},
{"Filter team 1 and team 2, public and private and exclude group constrained", "", store.ChannelSearchOpts{IncludeDeleted: false, TeamIds: []string{t1.Id, t2.Id}, Public: true, Private: true, ExcludeGroupConstrained: true, Page: model.NewInt(0), PerPage: model.NewInt(5)}, model.ChannelList{&o1, &o2, &o3, &o4, &o6}, 12},
{"Filter deleted returns only deleted channels", "", store.ChannelSearchOpts{Deleted: true, Page: model.NewInt(0), PerPage: model.NewInt(5)}, model.ChannelList{&o13}, 1},
{"Search ChannelA by id", o1.Id, store.ChannelSearchOpts{IncludeDeleted: false, Page: model.NewInt(0), PerPage: model.NewInt(5), IncludeSearchById: true}, model.ChannelList{&o1}, 1},
{"Filter team 2", "", store.ChannelSearchOpts{IncludeDeleted: false, TeamIds: []string{t2.Id}, Page: model.NewPointer(0), PerPage: model.NewPointer(5)}, model.ChannelList{&o2, &o14}, 2},
{"Filter team 2, private", "", store.ChannelSearchOpts{IncludeDeleted: false, TeamIds: []string{t2.Id}, Private: true, Page: model.NewPointer(0), PerPage: model.NewPointer(5)}, model.ChannelList{}, 0},
{"Filter team 1 and team 2, private", "", store.ChannelSearchOpts{IncludeDeleted: false, TeamIds: []string{t1.Id, t2.Id}, Private: true, Page: model.NewPointer(0), PerPage: model.NewPointer(5)}, model.ChannelList{&o4, &o5, &o8}, 3},
{"Filter team 1 and team 2, public and private", "", store.ChannelSearchOpts{IncludeDeleted: false, TeamIds: []string{t1.Id, t2.Id}, Public: true, Private: true, Page: model.NewPointer(0), PerPage: model.NewPointer(5)}, model.ChannelList{&o1, &o2, &o3, &o4, &o5}, 13},
{"Filter team 1 and team 2, public and private and group constrained", "", store.ChannelSearchOpts{IncludeDeleted: false, TeamIds: []string{t1.Id, t2.Id}, Public: true, Private: true, GroupConstrained: true, Page: model.NewPointer(0), PerPage: model.NewPointer(5)}, model.ChannelList{&o5}, 1},
{"Filter team 1 and team 2, public and private and exclude group constrained", "", store.ChannelSearchOpts{IncludeDeleted: false, TeamIds: []string{t1.Id, t2.Id}, Public: true, Private: true, ExcludeGroupConstrained: true, Page: model.NewPointer(0), PerPage: model.NewPointer(5)}, model.ChannelList{&o1, &o2, &o3, &o4, &o6}, 12},
{"Filter deleted returns only deleted channels", "", store.ChannelSearchOpts{Deleted: true, Page: model.NewPointer(0), PerPage: model.NewPointer(5)}, model.ChannelList{&o13}, 1},
{"Search ChannelA by id", o1.Id, store.ChannelSearchOpts{IncludeDeleted: false, Page: model.NewPointer(0), PerPage: model.NewPointer(5), IncludeSearchById: true}, model.ChannelList{&o1}, 1},
}
for _, testCase := range testCases {
@ -7929,7 +7929,7 @@ func testGroupSyncedChannelCount(t *testing.T, rctx request.CTX, ss store.Store)
DisplayName: model.NewId(),
Name: model.NewId(),
Type: model.ChannelTypePrivate,
GroupConstrained: model.NewBool(true),
GroupConstrained: model.NewPointer(true),
}, 999)
require.NoError(t, nErr)
require.True(t, channel1.IsGroupConstrained())
@ -7948,7 +7948,7 @@ func testGroupSyncedChannelCount(t *testing.T, rctx request.CTX, ss store.Store)
require.NoError(t, err)
require.GreaterOrEqual(t, count, int64(1))
channel2.GroupConstrained = model.NewBool(true)
channel2.GroupConstrained = model.NewPointer(true)
channel2, err = ss.Channel().Update(rctx, channel2)
require.NoError(t, err)
require.True(t, channel2.IsGroupConstrained())

File diff suppressed because it is too large Load Diff

View File

@ -28,9 +28,9 @@ func testPostAcknowledgementsStoreSave(t *testing.T, rctx request.CTX, ss store.
p1.Message = NewTestId()
p1.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("important"),
RequestedAck: model.NewBool(true),
PersistentNotifications: model.NewBool(false),
Priority: model.NewPointer("important"),
RequestedAck: model.NewPointer(true),
PersistentNotifications: model.NewPointer(false),
},
}
post, err := ss.Post().Save(rctx, &p1)
@ -73,9 +73,9 @@ func testPostAcknowledgementsStoreGetForPost(t *testing.T, rctx request.CTX, ss
p1.Message = NewTestId()
p1.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("important"),
RequestedAck: model.NewBool(true),
PersistentNotifications: model.NewBool(false),
Priority: model.NewPointer("important"),
RequestedAck: model.NewPointer(true),
PersistentNotifications: model.NewPointer(false),
},
}
_, err := ss.Post().Save(rctx, &p1)
@ -124,9 +124,9 @@ func testPostAcknowledgementsStoreGetForPosts(t *testing.T, rctx request.CTX, ss
p1.Message = NewTestId()
p1.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("important"),
RequestedAck: model.NewBool(true),
PersistentNotifications: model.NewBool(false),
Priority: model.NewPointer("important"),
RequestedAck: model.NewPointer(true),
PersistentNotifications: model.NewPointer(false),
},
}
p2 := model.Post{}
@ -135,9 +135,9 @@ func testPostAcknowledgementsStoreGetForPosts(t *testing.T, rctx request.CTX, ss
p2.Message = NewTestId()
p2.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString(""),
RequestedAck: model.NewBool(true),
PersistentNotifications: model.NewBool(false),
Priority: model.NewPointer(""),
RequestedAck: model.NewPointer(true),
PersistentNotifications: model.NewPointer(false),
},
}
_, errIdx, err := ss.Post().SaveMultiple([]*model.Post{&p1, &p2})

View File

@ -28,9 +28,9 @@ func testPostPersistentNotificationStoreGet(t *testing.T, rctx request.CTX, ss s
p1.CreateAt = 10
p1.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("important"),
RequestedAck: model.NewBool(false),
PersistentNotifications: model.NewBool(true),
Priority: model.NewPointer("important"),
RequestedAck: model.NewPointer(false),
PersistentNotifications: model.NewPointer(true),
},
}
@ -41,9 +41,9 @@ func testPostPersistentNotificationStoreGet(t *testing.T, rctx request.CTX, ss s
p2.CreateAt = 20
p2.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString(model.PostPriorityUrgent),
RequestedAck: model.NewBool(true),
PersistentNotifications: model.NewBool(true),
Priority: model.NewPointer(model.PostPriorityUrgent),
RequestedAck: model.NewPointer(true),
PersistentNotifications: model.NewPointer(true),
},
}
@ -62,9 +62,9 @@ func testPostPersistentNotificationStoreGet(t *testing.T, rctx request.CTX, ss s
p4.CreateAt = 40
p4.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString(model.PostPriorityUrgent),
RequestedAck: model.NewBool(false),
PersistentNotifications: model.NewBool(false),
Priority: model.NewPointer(model.PostPriorityUrgent),
RequestedAck: model.NewPointer(false),
PersistentNotifications: model.NewPointer(false),
},
}
@ -75,9 +75,9 @@ func testPostPersistentNotificationStoreGet(t *testing.T, rctx request.CTX, ss s
p5.CreateAt = 50
p5.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString(model.PostPriorityUrgent),
RequestedAck: model.NewBool(false),
PersistentNotifications: model.NewBool(true),
Priority: model.NewPointer(model.PostPriorityUrgent),
RequestedAck: model.NewPointer(false),
PersistentNotifications: model.NewPointer(true),
},
}
@ -150,9 +150,9 @@ func testPostPersistentNotificationStoreUpdateLastSentAt(t *testing.T, rctx requ
p1.CreateAt = 10
p1.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("important"),
RequestedAck: model.NewBool(false),
PersistentNotifications: model.NewBool(true),
Priority: model.NewPointer("important"),
RequestedAck: model.NewPointer(false),
PersistentNotifications: model.NewPointer(true),
},
}
@ -203,9 +203,9 @@ func testPostPersistentNotificationStoreDelete(t *testing.T, rctx request.CTX, s
p1.CreateAt = 10
p1.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("important"),
RequestedAck: model.NewBool(false),
PersistentNotifications: model.NewBool(true),
Priority: model.NewPointer("important"),
RequestedAck: model.NewPointer(false),
PersistentNotifications: model.NewPointer(true),
},
}
@ -216,9 +216,9 @@ func testPostPersistentNotificationStoreDelete(t *testing.T, rctx request.CTX, s
p2.CreateAt = 20
p2.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString(model.PostPriorityUrgent),
RequestedAck: model.NewBool(true),
PersistentNotifications: model.NewBool(true),
Priority: model.NewPointer(model.PostPriorityUrgent),
RequestedAck: model.NewPointer(true),
PersistentNotifications: model.NewPointer(true),
},
}
@ -229,9 +229,9 @@ func testPostPersistentNotificationStoreDelete(t *testing.T, rctx request.CTX, s
p3.CreateAt = 30
p3.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString(model.PostPriorityUrgent),
RequestedAck: model.NewBool(false),
PersistentNotifications: model.NewBool(true),
Priority: model.NewPointer(model.PostPriorityUrgent),
RequestedAck: model.NewPointer(false),
PersistentNotifications: model.NewPointer(true),
},
}
@ -263,9 +263,9 @@ func testPostPersistentNotificationStoreDelete(t *testing.T, rctx request.CTX, s
p1.CreateAt = 10
p1.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("important"),
RequestedAck: model.NewBool(false),
PersistentNotifications: model.NewBool(true),
Priority: model.NewPointer("important"),
RequestedAck: model.NewPointer(false),
PersistentNotifications: model.NewPointer(true),
},
}
@ -276,9 +276,9 @@ func testPostPersistentNotificationStoreDelete(t *testing.T, rctx request.CTX, s
p2.CreateAt = 20
p2.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString(model.PostPriorityUrgent),
RequestedAck: model.NewBool(true),
PersistentNotifications: model.NewBool(true),
Priority: model.NewPointer(model.PostPriorityUrgent),
RequestedAck: model.NewPointer(true),
PersistentNotifications: model.NewPointer(true),
},
}
@ -289,9 +289,9 @@ func testPostPersistentNotificationStoreDelete(t *testing.T, rctx request.CTX, s
p3.CreateAt = 30
p3.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString(model.PostPriorityUrgent),
RequestedAck: model.NewBool(false),
PersistentNotifications: model.NewBool(true),
Priority: model.NewPointer(model.PostPriorityUrgent),
RequestedAck: model.NewPointer(false),
PersistentNotifications: model.NewPointer(true),
},
}
@ -302,9 +302,9 @@ func testPostPersistentNotificationStoreDelete(t *testing.T, rctx request.CTX, s
p4.CreateAt = 40
p4.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("important"),
RequestedAck: model.NewBool(false),
PersistentNotifications: model.NewBool(true),
Priority: model.NewPointer("important"),
RequestedAck: model.NewPointer(false),
PersistentNotifications: model.NewPointer(true),
},
}
@ -315,9 +315,9 @@ func testPostPersistentNotificationStoreDelete(t *testing.T, rctx request.CTX, s
p5.CreateAt = 50
p5.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("important"),
RequestedAck: model.NewBool(false),
PersistentNotifications: model.NewBool(true),
Priority: model.NewPointer("important"),
RequestedAck: model.NewPointer(false),
PersistentNotifications: model.NewPointer(true),
},
}
@ -367,9 +367,9 @@ func testPostPersistentNotificationStoreDelete(t *testing.T, rctx request.CTX, s
p1.CreateAt = 10
p1.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("important"),
RequestedAck: model.NewBool(false),
PersistentNotifications: model.NewBool(true),
Priority: model.NewPointer("important"),
RequestedAck: model.NewPointer(false),
PersistentNotifications: model.NewPointer(true),
},
}
@ -380,9 +380,9 @@ func testPostPersistentNotificationStoreDelete(t *testing.T, rctx request.CTX, s
p2.CreateAt = 20
p2.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString(model.PostPriorityUrgent),
RequestedAck: model.NewBool(true),
PersistentNotifications: model.NewBool(true),
Priority: model.NewPointer(model.PostPriorityUrgent),
RequestedAck: model.NewPointer(true),
PersistentNotifications: model.NewPointer(true),
},
}
@ -393,9 +393,9 @@ func testPostPersistentNotificationStoreDelete(t *testing.T, rctx request.CTX, s
p3.CreateAt = 30
p3.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString(model.PostPriorityUrgent),
RequestedAck: model.NewBool(false),
PersistentNotifications: model.NewBool(true),
Priority: model.NewPointer(model.PostPriorityUrgent),
RequestedAck: model.NewPointer(false),
PersistentNotifications: model.NewPointer(true),
},
}
@ -406,9 +406,9 @@ func testPostPersistentNotificationStoreDelete(t *testing.T, rctx request.CTX, s
p4.CreateAt = 40
p4.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("important"),
RequestedAck: model.NewBool(false),
PersistentNotifications: model.NewBool(true),
Priority: model.NewPointer("important"),
RequestedAck: model.NewPointer(false),
PersistentNotifications: model.NewPointer(true),
},
}
@ -419,9 +419,9 @@ func testPostPersistentNotificationStoreDelete(t *testing.T, rctx request.CTX, s
p5.CreateAt = 50
p5.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("important"),
RequestedAck: model.NewBool(false),
PersistentNotifications: model.NewBool(true),
Priority: model.NewPointer("important"),
RequestedAck: model.NewPointer(false),
PersistentNotifications: model.NewPointer(true),
},
}

View File

@ -28,9 +28,9 @@ func testPostPriorityStoreGetForPost(t *testing.T, rctx request.CTX, ss store.St
p1.Message = NewTestId()
p1.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("important"),
RequestedAck: model.NewBool(true),
PersistentNotifications: model.NewBool(false),
Priority: model.NewPointer("important"),
RequestedAck: model.NewPointer(true),
PersistentNotifications: model.NewPointer(false),
},
}
@ -40,9 +40,9 @@ func testPostPriorityStoreGetForPost(t *testing.T, rctx request.CTX, ss store.St
p2.Message = NewTestId()
p2.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString(model.PostPriorityUrgent),
RequestedAck: model.NewBool(false),
PersistentNotifications: model.NewBool(true),
Priority: model.NewPointer(model.PostPriorityUrgent),
RequestedAck: model.NewPointer(false),
PersistentNotifications: model.NewPointer(true),
},
}

View File

@ -249,9 +249,9 @@ func testPostStoreSave(t *testing.T, rctx request.CTX, ss store.Store) {
o1.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString("important"),
RequestedAck: model.NewBool(true),
PersistentNotifications: model.NewBool(false),
Priority: model.NewPointer("important"),
RequestedAck: model.NewPointer(true),
PersistentNotifications: model.NewPointer(false),
},
}
@ -4061,7 +4061,7 @@ func testPostStorePermanentDeleteBatch(t *testing.T, rctx request.CTX, ss store.
channelPolicy, err2 := ss.RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{
RetentionPolicy: model.RetentionPolicy{
DisplayName: "DisplayName",
PostDurationDays: model.NewInt64(30),
PostDurationDays: model.NewPointer(int64(30)),
},
ChannelIDs: []string{channel.Id},
})
@ -4090,7 +4090,7 @@ func testPostStorePermanentDeleteBatch(t *testing.T, rctx request.CTX, ss store.
teamPolicy, err2 := ss.RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{
RetentionPolicy: model.RetentionPolicy{
DisplayName: "DisplayName",
PostDurationDays: model.NewInt64(20),
PostDurationDays: model.NewPointer(int64(20)),
},
TeamIDs: []string{team.Id},
})
@ -4150,7 +4150,7 @@ func testPostStorePermanentDeleteBatch(t *testing.T, rctx request.CTX, ss store.
channelPolicy, err2 := ss.RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{
RetentionPolicy: model.RetentionPolicy{
DisplayName: "DisplayName",
PostDurationDays: model.NewInt64(30),
PostDurationDays: model.NewPointer(int64(30)),
},
ChannelIDs: []string{c1.Id},
})
@ -4159,7 +4159,7 @@ func testPostStorePermanentDeleteBatch(t *testing.T, rctx request.CTX, ss store.
teamPolicy, err2 := ss.RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{
RetentionPolicy: model.RetentionPolicy{
DisplayName: "DisplayName",
PostDurationDays: model.NewInt64(30),
PostDurationDays: model.NewPointer(int64(30)),
},
TeamIDs: []string{team.Id},
})
@ -4662,7 +4662,7 @@ func testHasAutoResponsePostByUserSince(t *testing.T, rctx request.CTX, ss store
func testGetPostsSinceUpdateForSync(t *testing.T, rctx request.CTX, ss store.Store, s SqlStore) {
// create some posts.
channelID := model.NewId()
remoteID := model.NewString(model.NewId())
remoteID := model.NewPointer(model.NewId())
first := model.GetMillis()
data := []*model.Post{
@ -4681,7 +4681,7 @@ func testGetPostsSinceUpdateForSync(t *testing.T, rctx request.CTX, ss store.Sto
for i, p := range data {
p.UpdateAt = first + (int64(i) * 300000)
if p.RemoteId == nil {
p.RemoteId = model.NewString(model.NewId())
p.RemoteId = model.NewPointer(model.NewId())
}
_, err := ss.Post().Save(rctx, p)
require.NoError(t, err, "couldn't save post")
@ -4765,7 +4765,7 @@ func testGetPostsSinceUpdateForSync(t *testing.T, rctx request.CTX, ss store.Sto
func testGetPostsSinceCreateForSync(t *testing.T, rctx request.CTX, ss store.Store, s SqlStore) {
// create some posts.
channelID := model.NewId()
remoteID := model.NewString(model.NewId())
remoteID := model.NewPointer(model.NewId())
first := model.GetMillis()
data := []*model.Post{
@ -4784,7 +4784,7 @@ func testGetPostsSinceCreateForSync(t *testing.T, rctx request.CTX, ss store.Sto
for i, p := range data {
p.CreateAt = first + (int64(i) * 300000)
if p.RemoteId == nil {
p.RemoteId = model.NewString(model.NewId())
p.RemoteId = model.NewPointer(model.NewId())
}
_, err := ss.Post().Save(rctx, p)
require.NoError(t, err, "couldn't save post")

View File

@ -982,7 +982,7 @@ func testReactionGetSingle(t *testing.T, rctx request.CTX, ss store.Store) {
UserId: testUserID,
PostId: post.Id,
EmojiName: testEmojiName,
RemoteId: model.NewString(testRemoteID),
RemoteId: model.NewPointer(testRemoteID),
}
_, nErr := ss.Reaction().Save(reaction)
@ -1007,7 +1007,7 @@ func testReactionGetSingle(t *testing.T, rctx request.CTX, ss store.Store) {
UserId: testUserID,
PostId: post.Id,
EmojiName: testEmojiName,
RemoteId: model.NewString(testRemoteID),
RemoteId: model.NewPointer(testRemoteID),
}
_, nErr := ss.Reaction().Save(reaction)

View File

@ -174,7 +174,7 @@ func createRetentionPolicyWithTeamAndChannelIds(displayName string, teamIDs, cha
return &model.RetentionPolicyWithTeamAndChannelIDs{
RetentionPolicy: model.RetentionPolicy{
DisplayName: displayName,
PostDurationDays: model.NewInt64(30),
PostDurationDays: model.NewPointer(int64(30)),
},
TeamIDs: teamIDs,
ChannelIDs: channelIDs,
@ -254,7 +254,7 @@ func testRetentionPolicyStorePatch(t *testing.T, rctx request.CTX, ss store.Stor
patch := &model.RetentionPolicyWithTeamAndChannelIDs{
RetentionPolicy: model.RetentionPolicy{
ID: policy.ID,
PostDurationDays: model.NewInt64(10000),
PostDurationDays: model.NewPointer(int64(10000)),
},
}
_, err := ss.RetentionPolicy().Patch(patch)
@ -264,7 +264,7 @@ func testRetentionPolicyStorePatch(t *testing.T, rctx request.CTX, ss store.Stor
checkRetentionPolicyLikeThisExists(t, ss, expected)
// Store a negative value (= infinity)
patch.PostDurationDays = model.NewInt64(-1)
patch.PostDurationDays = model.NewPointer(int64(-1))
_, err = ss.RetentionPolicy().Patch(patch)
require.NoError(t, err)
expected = copyRetentionPolicyWithTeamAndChannelIds(policy)

View File

@ -172,8 +172,8 @@ func databaseSettings(driver, dataSource string) *model.SqlSettings {
ConnMaxLifetimeMilliseconds: new(int),
ConnMaxIdleTimeMilliseconds: new(int),
MaxOpenConns: new(int),
Trace: model.NewBool(false),
AtRestEncryptKey: model.NewString(model.NewRandomString(32)),
Trace: model.NewPointer(false),
AtRestEncryptKey: model.NewPointer(model.NewRandomString(32)),
QueryTimeout: new(int),
MigrationsStatementTimeoutSeconds: new(int),
}
@ -261,7 +261,7 @@ func MakeSqlSettings(driver string, withReplica bool) *model.SqlSettings {
}
log("Created temporary " + driver + " database " + dbName)
settings.ReplicaMonitorIntervalSeconds = model.NewInt(5)
settings.ReplicaMonitorIntervalSeconds = model.NewPointer(5)
return settings
}

View File

@ -869,7 +869,7 @@ func createSharedTestChannel(ss store.Store, rctx request.CTX, name string, shar
Header: name + " header",
Purpose: name + "purpose",
CreatorId: model.NewId(),
Shared: model.NewBool(shared),
Shared: model.NewPointer(shared),
}
channel, err := ss.Channel().Save(rctx, channel, 10000)
if err != nil {

View File

@ -276,7 +276,7 @@ func testTeamStoreSearchAll(t *testing.T, rctx request.CTX, ss store.Store) {
g.Email = MakeEmail()
g.Type = model.TeamOpen
g.AllowOpenInvite = false
g.GroupConstrained = model.NewBool(true)
g.GroupConstrained = model.NewPointer(true)
_, err = ss.Team().Save(&g)
require.NoError(t, err)
@ -294,7 +294,7 @@ func testTeamStoreSearchAll(t *testing.T, rctx request.CTX, ss store.Store) {
_, err = ss.RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{
RetentionPolicy: model.RetentionPolicy{
DisplayName: "Policy 1",
PostDurationDays: model.NewInt64(20),
PostDurationDays: model.NewPointer(int64(20)),
},
TeamIDs: []string{q.Id},
})
@ -368,55 +368,55 @@ func testTeamStoreSearchAll(t *testing.T, rctx request.CTX, ss store.Store) {
},
{
"Search for all 3 teams filter by allow open invite",
&model.TeamSearch{Term: "searchterm", AllowOpenInvite: model.NewBool(true)},
&model.TeamSearch{Term: "searchterm", AllowOpenInvite: model.NewPointer(true)},
1,
[]string{o.Id},
},
{
"Search for all 3 teams filter by allow open invite = false",
&model.TeamSearch{Term: "searchterm", AllowOpenInvite: model.NewBool(false)},
&model.TeamSearch{Term: "searchterm", AllowOpenInvite: model.NewPointer(false)},
1,
[]string{p.Id},
},
{
"Search for all 3 teams filter by group constrained",
&model.TeamSearch{Term: "searchterm", GroupConstrained: model.NewBool(true)},
&model.TeamSearch{Term: "searchterm", GroupConstrained: model.NewPointer(true)},
1,
[]string{g.Id},
},
{
"Search for all 3 teams filter by group constrained = false",
&model.TeamSearch{Term: "searchterm", GroupConstrained: model.NewBool(false)},
&model.TeamSearch{Term: "searchterm", GroupConstrained: model.NewPointer(false)},
2,
[]string{o.Id, p.Id},
},
{
"Search for all 3 teams filter by allow open invite and include group constrained",
&model.TeamSearch{Term: "searchterm", AllowOpenInvite: model.NewBool(true), GroupConstrained: model.NewBool(true)},
&model.TeamSearch{Term: "searchterm", AllowOpenInvite: model.NewPointer(true), GroupConstrained: model.NewPointer(true)},
2,
[]string{o.Id, g.Id},
},
{
"Search for all 3 teams filter by group constrained and not open invite",
&model.TeamSearch{Term: "searchterm", GroupConstrained: model.NewBool(true), AllowOpenInvite: model.NewBool(false)},
&model.TeamSearch{Term: "searchterm", GroupConstrained: model.NewPointer(true), AllowOpenInvite: model.NewPointer(false)},
2,
[]string{g.Id, p.Id},
},
{
"Search for all 3 teams filter by group constrained false and open invite",
&model.TeamSearch{Term: "searchterm", GroupConstrained: model.NewBool(false), AllowOpenInvite: model.NewBool(true)},
&model.TeamSearch{Term: "searchterm", GroupConstrained: model.NewPointer(false), AllowOpenInvite: model.NewPointer(true)},
2,
[]string{o.Id, p.Id},
},
{
"Search for all 3 teams filter by group constrained false and open invite false",
&model.TeamSearch{Term: "searchterm", GroupConstrained: model.NewBool(false), AllowOpenInvite: model.NewBool(false)},
&model.TeamSearch{Term: "searchterm", GroupConstrained: model.NewPointer(false), AllowOpenInvite: model.NewPointer(false)},
2,
[]string{p.Id, o.Id},
},
{
"Search for teams which are not part of a data retention policy",
&model.TeamSearch{Term: "", ExcludePolicyConstrained: model.NewBool(true)},
&model.TeamSearch{Term: "", ExcludePolicyConstrained: model.NewPointer(true)},
3,
[]string{o.Id, p.Id, g.Id},
},
@ -700,7 +700,7 @@ func testTeamStoreGetAllPage(t *testing.T, rctx request.CTX, ss store.Store) {
policy, err := ss.RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{
RetentionPolicy: model.RetentionPolicy{
DisplayName: "Policy 1",
PostDurationDays: model.NewInt64(30),
PostDurationDays: model.NewPointer(int64(30)),
},
TeamIDs: []string{o.Id},
})
@ -720,7 +720,7 @@ func testTeamStoreGetAllPage(t *testing.T, rctx request.CTX, ss store.Store) {
require.True(t, found)
// With ExcludePolicyConstrained
teams, err = ss.Team().GetAllPage(0, 100, &model.TeamSearch{ExcludePolicyConstrained: model.NewBool(true)})
teams, err = ss.Team().GetAllPage(0, 100, &model.TeamSearch{ExcludePolicyConstrained: model.NewPointer(true)})
require.NoError(t, err)
found = false
for _, team := range teams {
@ -732,7 +732,7 @@ func testTeamStoreGetAllPage(t *testing.T, rctx request.CTX, ss store.Store) {
require.False(t, found)
// With policy ID
teams, err = ss.Team().GetAllPage(0, 100, &model.TeamSearch{IncludePolicyID: model.NewBool(true)})
teams, err = ss.Team().GetAllPage(0, 100, &model.TeamSearch{IncludePolicyID: model.NewPointer(true)})
require.NoError(t, err)
found = false
for _, team := range teams {
@ -826,7 +826,7 @@ func testGetAllTeamPageListing(t *testing.T, rctx request.CTX, ss store.Store) {
_, err = ss.Team().Save(&o4)
require.NoError(t, err)
opts := &model.TeamSearch{AllowOpenInvite: model.NewBool(true)}
opts := &model.TeamSearch{AllowOpenInvite: model.NewPointer(true)}
teams, err := ss.Team().GetAllPage(0, 10, opts)
require.NoError(t, err)
@ -946,7 +946,7 @@ func testGetAllPrivateTeamPageListing(t *testing.T, rctx request.CTX, ss store.S
_, err = ss.Team().Save(&o4)
require.NoError(t, err)
opts := &model.TeamSearch{AllowOpenInvite: model.NewBool(false)}
opts := &model.TeamSearch{AllowOpenInvite: model.NewPointer(false)}
teams, listErr := ss.Team().GetAllPage(0, 10, opts)
require.NoError(t, listErr)
@ -1021,7 +1021,7 @@ func testGetAllPublicTeamPageListing(t *testing.T, rctx request.CTX, ss store.St
_, err = ss.Team().Save(&o4)
require.NoError(t, err)
opts := &model.TeamSearch{AllowOpenInvite: model.NewBool(true)}
opts := &model.TeamSearch{AllowOpenInvite: model.NewPointer(true)}
teams, err := ss.Team().GetAllPage(0, 10, opts)
assert.NoError(t, err)
@ -1096,7 +1096,7 @@ func testPublicTeamCount(t *testing.T, rctx request.CTX, ss store.Store) {
_, err = ss.Team().Save(&o3)
require.NoError(t, err)
teamCount, err := ss.Team().AnalyticsTeamCount(&model.TeamSearch{AllowOpenInvite: model.NewBool(true)})
teamCount, err := ss.Team().AnalyticsTeamCount(&model.TeamSearch{AllowOpenInvite: model.NewPointer(true)})
require.NoError(t, err)
require.Equal(t, int64(2), teamCount, "should only be 1 team")
}
@ -1131,7 +1131,7 @@ func testPrivateTeamCount(t *testing.T, rctx request.CTX, ss store.Store) {
_, err = ss.Team().Save(&o3)
require.NoError(t, err)
teamCount, err := ss.Team().AnalyticsTeamCount(&model.TeamSearch{AllowOpenInvite: model.NewBool(false)})
teamCount, err := ss.Team().AnalyticsTeamCount(&model.TeamSearch{AllowOpenInvite: model.NewPointer(false)})
require.NoError(t, err)
require.Equal(t, int64(2), teamCount, "should only be 1 team")
}
@ -1161,7 +1161,7 @@ func testTeamCount(t *testing.T, rctx request.CTX, ss store.Store) {
require.NoError(t, err)
// get the count of teams including deleted
countIncludingDeleted, err := ss.Team().AnalyticsTeamCount(&model.TeamSearch{IncludeDeleted: model.NewBool(true)})
countIncludingDeleted, err := ss.Team().AnalyticsTeamCount(&model.TeamSearch{IncludeDeleted: model.NewPointer(true)})
require.NoError(t, err)
// count including deleted should be one greater than not including deleted
@ -3589,7 +3589,7 @@ func testGroupSyncedTeamCount(t *testing.T, rctx request.CTX, ss store.Store) {
Name: NewTestId(),
Email: MakeEmail(),
Type: model.TeamInvite,
GroupConstrained: model.NewBool(true),
GroupConstrained: model.NewPointer(true),
})
require.NoError(t, err)
require.True(t, team1.IsGroupConstrained())
@ -3609,7 +3609,7 @@ func testGroupSyncedTeamCount(t *testing.T, rctx request.CTX, ss store.Store) {
require.NoError(t, err)
require.GreaterOrEqual(t, count, int64(1))
team2.GroupConstrained = model.NewBool(true)
team2.GroupConstrained = model.NewPointer(true)
team2, err = ss.Team().Update(team2)
require.NoError(t, err)
require.True(t, team2.IsGroupConstrained())

View File

@ -64,9 +64,9 @@ func testThreadStorePopulation(t *testing.T, rctx request.CTX, ss store.Store) {
if urgent {
o.Metadata = &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString(model.PostPriorityUrgent),
RequestedAck: model.NewBool(false),
PersistentNotifications: model.NewBool(false),
Priority: model.NewPointer(model.PostPriorityUrgent),
RequestedAck: model.NewPointer(false),
PersistentNotifications: model.NewPointer(false),
},
}
}
@ -520,7 +520,7 @@ func testThreadStorePermanentDeleteBatchForRetentionPolicies(t *testing.T, rctx
channelPolicy, err := ss.RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{
RetentionPolicy: model.RetentionPolicy{
DisplayName: "DisplayName",
PostDurationDays: model.NewInt64(30),
PostDurationDays: model.NewPointer(int64(30)),
},
ChannelIDs: []string{channel.Id},
})
@ -542,7 +542,7 @@ func testThreadStorePermanentDeleteBatchForRetentionPolicies(t *testing.T, rctx
teamPolicy, err := ss.RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{
RetentionPolicy: model.RetentionPolicy{
DisplayName: "DisplayName",
PostDurationDays: model.NewInt64(20),
PostDurationDays: model.NewPointer(int64(20)),
},
TeamIDs: []string{team.Id},
})
@ -607,7 +607,7 @@ func testThreadStorePermanentDeleteBatchThreadMembershipsForRetentionPolicies(t
channelPolicy, err := ss.RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{
RetentionPolicy: model.RetentionPolicy{
DisplayName: "DisplayName",
PostDurationDays: model.NewInt64(30),
PostDurationDays: model.NewPointer(int64(30)),
},
ChannelIDs: []string{channel.Id},
})
@ -626,7 +626,7 @@ func testThreadStorePermanentDeleteBatchThreadMembershipsForRetentionPolicies(t
teamPolicy, err := ss.RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{
RetentionPolicy: model.RetentionPolicy{
DisplayName: "DisplayName",
PostDurationDays: model.NewInt64(20),
PostDurationDays: model.NewPointer(int64(20)),
},
TeamIDs: []string{team.Id},
})
@ -739,9 +739,9 @@ func testGetTeamsUnreadForUser(t *testing.T, rctx request.CTX, ss store.Store) {
Message: model.NewRandomString(10),
Metadata: &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString(model.PostPriorityUrgent),
RequestedAck: model.NewBool(false),
PersistentNotifications: model.NewBool(false),
Priority: model.NewPointer(model.PostPriorityUrgent),
RequestedAck: model.NewPointer(false),
PersistentNotifications: model.NewPointer(false),
},
},
})
@ -881,9 +881,9 @@ func testVarious(t *testing.T, rctx request.CTX, ss store.Store) {
Message: model.NewRandomString(10),
Metadata: &model.PostMetadata{
Priority: &model.PostPriority{
Priority: model.NewString(model.PostPriorityUrgent),
RequestedAck: model.NewBool(false),
PersistentNotifications: model.NewBool(false),
Priority: model.NewPointer(model.PostPriorityUrgent),
RequestedAck: model.NewPointer(false),
PersistentNotifications: model.NewPointer(false),
},
},
})

View File

@ -1605,10 +1605,10 @@ func testUserStoreGetProfilesNotInChannel(t *testing.T, rctx request.CTX, ss sto
// create a group
group, err := ss.Group().Create(&model.Group{
Name: model.NewString("n_" + model.NewId()),
Name: model.NewPointer("n_" + model.NewId()),
DisplayName: "dn_" + model.NewId(),
Source: model.GroupSourceLdap,
RemoteId: model.NewString("ri_" + model.NewId()),
RemoteId: model.NewPointer("ri_" + model.NewId()),
})
require.NoError(t, err)
@ -2357,7 +2357,7 @@ func testUserStoreResetAuthDataToEmailForUsers(t *testing.T, rctx request.CTX, s
resetAuthDataToID := func() {
_, err = ss.User().UpdateAuthData(
user.Id, model.UserAuthServiceSaml, model.NewString("some-id"), "", false)
user.Id, model.UserAuthServiceSaml, model.NewPointer("some-id"), "", false)
require.NoError(t, err)
}
resetAuthDataToID()
@ -3694,28 +3694,28 @@ func testUserStoreSearchInGroup(t *testing.T, rctx request.CTX, ss store.Store)
defer func() { require.NoError(t, ss.User().PermanentDelete(rctx, u3.Id)) }()
// The users returned from the database will have AuthData as an empty string.
nilAuthData := model.NewString("")
nilAuthData := model.NewPointer("")
u1.AuthData = nilAuthData
u2.AuthData = nilAuthData
u3.AuthData = nilAuthData
g1 := &model.Group{
Name: model.NewString(NewTestId()),
Name: model.NewPointer(NewTestId()),
DisplayName: NewTestId(),
Description: NewTestId(),
Source: model.GroupSourceLdap,
RemoteId: model.NewString(NewTestId()),
RemoteId: model.NewPointer(NewTestId()),
}
_, err = ss.Group().Create(g1)
require.NoError(t, err)
g2 := &model.Group{
Name: model.NewString(NewTestId()),
Name: model.NewPointer(NewTestId()),
DisplayName: NewTestId(),
Description: NewTestId(),
Source: model.GroupSourceLdap,
RemoteId: model.NewString(NewTestId()),
RemoteId: model.NewPointer(NewTestId()),
}
_, err = ss.Group().Create(g2)
require.NoError(t, err)
@ -3837,28 +3837,28 @@ func testUserStoreSearchNotInGroup(t *testing.T, rctx request.CTX, ss store.Stor
defer func() { require.NoError(t, ss.User().PermanentDelete(rctx, u3.Id)) }()
// The users returned from the database will have AuthData as an empty string.
nilAuthData := model.NewString("")
nilAuthData := model.NewPointer("")
u1.AuthData = nilAuthData
u2.AuthData = nilAuthData
u3.AuthData = nilAuthData
g1 := &model.Group{
Name: model.NewString(NewTestId()),
Name: model.NewPointer(NewTestId()),
DisplayName: NewTestId(),
Description: NewTestId(),
Source: model.GroupSourceCustom,
RemoteId: model.NewString(NewTestId()),
RemoteId: model.NewPointer(NewTestId()),
}
_, err = ss.Group().Create(g1)
require.NoError(t, err)
g2 := &model.Group{
Name: model.NewString(NewTestId()),
Name: model.NewPointer(NewTestId()),
DisplayName: NewTestId(),
Description: NewTestId(),
Source: model.GroupSourceCustom,
RemoteId: model.NewString(NewTestId()),
RemoteId: model.NewPointer(NewTestId()),
}
_, err = ss.Group().Create(g2)
require.NoError(t, err)
@ -4764,10 +4764,10 @@ func testUserStoreGetProfilesNotInTeam(t *testing.T, rctx request.CTX, ss store.
// create a group
group, err := ss.Group().Create(&model.Group{
Name: model.NewString("n_" + model.NewId()),
Name: model.NewPointer("n_" + model.NewId()),
DisplayName: "dn_" + model.NewId(),
Source: model.GroupSourceLdap,
RemoteId: model.NewString("ri_" + model.NewId()),
RemoteId: model.NewPointer("ri_" + model.NewId()),
})
require.NoError(t, err)
@ -5084,10 +5084,10 @@ func testUserStoreGetTeamGroupUsers(t *testing.T, rctx request.CTX, ss store.Sto
var group *model.Group
group, err = ss.Group().Create(&model.Group{
Name: model.NewString("n_" + id),
Name: model.NewPointer("n_" + id),
DisplayName: "dn_" + id,
Source: model.GroupSourceLdap,
RemoteId: model.NewString("ri_" + id),
RemoteId: model.NewPointer("ri_" + id),
})
require.NoError(t, err)
require.NotNil(t, group)
@ -5123,7 +5123,7 @@ func testUserStoreGetTeamGroupUsers(t *testing.T, rctx request.CTX, ss store.Sto
requireNUsers(1)
// update team to be group-constrained
team.GroupConstrained = model.NewBool(true)
team.GroupConstrained = model.NewPointer(true)
team, err = ss.Team().Update(team)
require.NoError(t, err)
@ -5205,10 +5205,10 @@ func testUserStoreGetChannelGroupUsers(t *testing.T, rctx request.CTX, ss store.
id = model.NewId()
var group *model.Group
group, err = ss.Group().Create(&model.Group{
Name: model.NewString("n_" + id),
Name: model.NewPointer("n_" + id),
DisplayName: "dn_" + id,
Source: model.GroupSourceLdap,
RemoteId: model.NewString("ri_" + id),
RemoteId: model.NewPointer("ri_" + id),
})
require.NoError(t, err)
require.NotNil(t, group)
@ -5244,7 +5244,7 @@ func testUserStoreGetChannelGroupUsers(t *testing.T, rctx request.CTX, ss store.
requireNUsers(1)
// update team to be group-constrained
channel.GroupConstrained = model.NewBool(true)
channel.GroupConstrained = model.NewPointer(true)
_, nErr = ss.Channel().Update(rctx, channel)
require.NoError(t, nErr)

View File

@ -970,7 +970,7 @@ func TestHandlerServeHTTPBasicSecurityChecks(t *testing.T) {
mockStore.On("GetDBSchemaVersion").Return(1, nil)
th.App.UpdateConfig(func(config *model.Config) {
config.ServiceSettings.MaximumURLLength = model.NewInt(10)
config.ServiceSettings.MaximumURLLength = model.NewPointer(10)
})
web := New(th.Server)
@ -1002,7 +1002,7 @@ func TestHandlerServeHTTPBasicSecurityChecks(t *testing.T) {
mockStore.On("GetDBSchemaVersion").Return(1, nil)
th.App.UpdateConfig(func(config *model.Config) {
config.ServiceSettings.MaximumURLLength = model.NewInt(20)
config.ServiceSettings.MaximumURLLength = model.NewPointer(20)
})
web := New(th.Server)
@ -1066,7 +1066,7 @@ func TestHandlerServeHTTPRequestPayloadLimit(t *testing.T) {
mockStore.On("GetDBSchemaVersion").Return(1, nil)
th.App.UpdateConfig(func(config *model.Config) {
config.ServiceSettings.MaximumPayloadSizeBytes = model.NewInt64(1)
config.ServiceSettings.MaximumPayloadSizeBytes = model.NewPointer(int64(1))
})
web := New(th.Server)

View File

@ -20,7 +20,7 @@ func TestMessageExportNotEnabled(t *testing.T) {
defer th.TearDown()
config := th.Config()
config.MessageExportSettings.EnableExport = model.NewBool(false)
config.MessageExportSettings.EnableExport = model.NewPointer(false)
th.SetConfig(config)
// should fail fast because the feature isn't enabled
@ -32,7 +32,7 @@ func TestMessageExportInvalidFormat(t *testing.T) {
defer th.TearDown()
config := th.Config()
config.MessageExportSettings.EnableExport = model.NewBool(true)
config.MessageExportSettings.EnableExport = model.NewPointer(true)
th.SetConfig(config)
// should fail fast because format isn't supported
@ -44,7 +44,7 @@ func TestMessageExportNegativeExportFrom(t *testing.T) {
defer th.TearDown()
config := th.Config()
config.MessageExportSettings.EnableExport = model.NewBool(true)
config.MessageExportSettings.EnableExport = model.NewPointer(true)
th.SetConfig(config)
// should fail fast because export from must be a valid timestamp
@ -56,7 +56,7 @@ func TestMessageExportNegativeTimeoutSeconds(t *testing.T) {
defer th.TearDown()
config := th.Config()
config.MessageExportSettings.EnableExport = model.NewBool(true)
config.MessageExportSettings.EnableExport = model.NewPointer(true)
th.SetConfig(config)
// should fail fast because timeout seconds must be a positive int

View File

@ -896,8 +896,8 @@ func (s *MmctlUnitTestSuite) TestConfigMigrateCmd() {
func TestCloudRestricted(t *testing.T) {
cfg := &model.Config{
ServiceSettings: model.ServiceSettings{
GoogleDeveloperKey: model.NewString("test"),
SiteURL: model.NewString("test"),
GoogleDeveloperKey: model.NewPointer("test"),
SiteURL: model.NewPointer("test"),
},
}
@ -937,40 +937,40 @@ func TestSetConfigValue(t *testing.T) {
path: "LogSettings.EnableConsole",
args: []string{"true"},
config: &model.Config{LogSettings: model.LogSettings{
EnableConsole: model.NewBool(false),
EnableConsole: model.NewPointer(false),
}},
expectedConfig: &model.Config{LogSettings: model.LogSettings{
EnableConsole: model.NewBool(true),
EnableConsole: model.NewPointer(true),
}},
},
"string": {
path: "LogSettings.ConsoleLevel",
args: []string{"foo"},
config: &model.Config{LogSettings: model.LogSettings{
ConsoleLevel: model.NewString("ConsoleLevel"),
ConsoleLevel: model.NewPointer("ConsoleLevel"),
}},
expectedConfig: &model.Config{LogSettings: model.LogSettings{
ConsoleLevel: model.NewString("foo"),
ConsoleLevel: model.NewPointer("foo"),
}},
},
"int": {
path: "LogSettings.MaxFieldSize",
args: []string{"123"},
config: &model.Config{LogSettings: model.LogSettings{
MaxFieldSize: model.NewInt(0),
MaxFieldSize: model.NewPointer(0),
}},
expectedConfig: &model.Config{LogSettings: model.LogSettings{
MaxFieldSize: model.NewInt(123),
MaxFieldSize: model.NewPointer(123),
}},
},
"int64": {
path: "ServiceSettings.TLSStrictTransportMaxAge",
config: &model.Config{ServiceSettings: model.ServiceSettings{
TLSStrictTransportMaxAge: model.NewInt64(0),
TLSStrictTransportMaxAge: model.NewPointer(int64(0)),
}},
args: []string{"123"},
expectedConfig: &model.Config{ServiceSettings: model.ServiceSettings{
TLSStrictTransportMaxAge: model.NewInt64(123),
TLSStrictTransportMaxAge: model.NewPointer(int64(123)),
}},
},
"string slice": {

View File

@ -184,7 +184,7 @@ func channelGroupEnableCmdF(c client.Client, cmd *cobra.Command, args []string)
return errors.New("Channel '" + args[0] + "' has no groups associated. It cannot be group-constrained")
}
channelPatch := model.ChannelPatch{GroupConstrained: model.NewBool(true)}
channelPatch := model.ChannelPatch{GroupConstrained: model.NewPointer(true)}
if _, _, err = c.PatchChannel(context.TODO(), channel.Id, &channelPatch); err != nil {
return err
}
@ -198,7 +198,7 @@ func channelGroupDisableCmdF(c client.Client, cmd *cobra.Command, args []string)
return errors.New("Unable to find channel '" + args[0] + "'")
}
channelPatch := model.ChannelPatch{GroupConstrained: model.NewBool(false)}
channelPatch := model.ChannelPatch{GroupConstrained: model.NewPointer(false)}
if _, _, err := c.PatchChannel(context.TODO(), channel.Id, &channelPatch); err != nil {
return err
}
@ -268,7 +268,7 @@ func teamGroupEnableCmdF(c client.Client, cmd *cobra.Command, args []string) err
return errors.New("Team '" + args[0] + "' has no groups associated. It cannot be group-constrained")
}
teamPatch := model.TeamPatch{GroupConstrained: model.NewBool(true)}
teamPatch := model.TeamPatch{GroupConstrained: model.NewPointer(true)}
if _, _, err = c.PatchTeam(context.TODO(), team.Id, &teamPatch); err != nil {
return err
}
@ -282,7 +282,7 @@ func teamGroupDisableCmdF(c client.Client, cmd *cobra.Command, args []string) er
return errors.New("Unable to find team '" + args[0] + "'")
}
teamPatch := model.TeamPatch{GroupConstrained: model.NewBool(false)}
teamPatch := model.TeamPatch{GroupConstrained: model.NewPointer(false)}
if _, _, err := c.PatchTeam(context.TODO(), team.Id, &teamPatch); err != nil {
return err
}

View File

@ -31,10 +31,10 @@ func (s *MmctlE2ETestSuite) TestChannelGroupEnableCmd() {
id := model.NewId()
group, appErr := s.th.App.CreateGroup(&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()),
})
s.Require().Nil(appErr)
defer func() {
@ -68,7 +68,7 @@ func (s *MmctlE2ETestSuite) TestChannelGroupEnableCmd() {
err := channelGroupEnableCmdF(c, &cobra.Command{}, []string{s.th.BasicTeam.Name + ":" + channelName})
s.Require().NoError(err)
channel.GroupConstrained = model.NewBool(false)
channel.GroupConstrained = model.NewPointer(false)
defer func() {
_, err := s.th.App.UpdateChannel(s.th.Context, channel)
s.Require().Nil(err)
@ -102,10 +102,10 @@ func (s *MmctlE2ETestSuite) TestChannelGroupDisableCmd() {
id := model.NewId()
group, appErr := s.th.App.CreateGroup(&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()),
})
s.Require().Nil(appErr)
defer func() {
@ -124,7 +124,7 @@ func (s *MmctlE2ETestSuite) TestChannelGroupDisableCmd() {
s.Require().Nil(err)
}()
channel.GroupConstrained = model.NewBool(true)
channel.GroupConstrained = model.NewPointer(true)
defer func() {
_, err := s.th.App.UpdateChannel(s.th.Context, channel)
s.Require().Nil(err)
@ -145,7 +145,7 @@ func (s *MmctlE2ETestSuite) TestChannelGroupDisableCmd() {
err := channelGroupDisableCmdF(c, &cobra.Command{}, []string{s.th.BasicTeam.Name + ":" + channelName})
s.Require().NoError(err)
channel.GroupConstrained = model.NewBool(true)
channel.GroupConstrained = model.NewPointer(true)
defer func() {
_, err := s.th.App.UpdateChannel(s.th.Context, channel)
s.Require().Nil(err)
@ -194,7 +194,7 @@ func (s *MmctlE2ETestSuite) TestChannelGroupStatusCmd() {
Name: channelName,
DisplayName: "dn_" + channelName,
Type: model.ChannelTypeOpen,
GroupConstrained: model.NewBool(true),
GroupConstrained: model.NewPointer(true),
}, false)
s.Require().Nil(appErr)
defer func() {
@ -257,10 +257,10 @@ func (s *MmctlE2ETestSuite) TestChannelGroupListCmd() {
id := model.NewId()
group, appErr := s.th.App.CreateGroup(&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()),
})
s.Require().Nil(appErr)
defer func() {
@ -308,7 +308,7 @@ func (s *MmctlE2ETestSuite) TestTeamGroupDisableCmd() {
team, _, cleanUpFn := createTestGroupTeam(s)
defer cleanUpFn()
team.GroupConstrained = model.NewBool(true)
team.GroupConstrained = model.NewPointer(true)
_, err := s.th.App.UpdateTeam(team)
s.Require().Nil(err)
@ -327,7 +327,7 @@ func (s *MmctlE2ETestSuite) TestTeamGroupDisableCmd() {
err := teamGroupDisableCmdF(c, &cobra.Command{}, []string{team.Name})
s.Require().NoError(err)
team.GroupConstrained = model.NewBool(true)
team.GroupConstrained = model.NewPointer(true)
defer func() {
_, err := s.th.App.UpdateTeam(team)
s.Require().Nil(err)
@ -363,7 +363,7 @@ func (s *MmctlE2ETestSuite) TestTeamGroupEnableCmd() {
err := teamGroupEnableCmdF(c, &cobra.Command{}, []string{team.Name})
s.Require().NoError(err)
team.GroupConstrained = model.NewBool(false)
team.GroupConstrained = model.NewPointer(false)
defer func() {
_, err := s.th.App.UpdateTeam(team)
s.Require().Nil(err)
@ -473,17 +473,17 @@ func createTestGroupTeam(s *MmctlE2ETestSuite) (*model.Team, *model.Group, func(
Name: teamName,
DisplayName: "dn_" + teamName,
Type: model.TeamOpen,
GroupConstrained: model.NewBool(true),
GroupConstrained: model.NewPointer(true),
})
s.Require().Nil(appErr)
id := model.NewId()
group, appErr := s.th.App.CreateGroup(&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()),
})
s.Require().Nil(appErr)
@ -515,10 +515,10 @@ func (s *MmctlE2ETestSuite) TestUserGroupRestoreCmd() {
id := model.NewId()
group, appErr := s.th.App.CreateGroup(&model.Group{
DisplayName: "dn_" + id,
Name: model.NewString("name" + id),
Name: model.NewPointer("name" + id),
Source: model.GroupSourceCustom,
Description: "description_" + id,
RemoteId: model.NewString(model.NewId()),
RemoteId: model.NewPointer(model.NewId()),
})
s.Require().Nil(appErr)
s.th.App.Srv().SetLicense(model.NewTestLicenseSKU(model.LicenseShortSkuProfessional, "ldap"))

Some files were not shown because too many files have changed in this diff Show More