OSF: Used model.NewPointer everywhere (#27838)

```release-note
NONE
```
Этот коммит содержится в:
Agniva De Sarker
2024-08-06 09:15:00 +05:30
коммит произвёл GitHub
родитель f290745496
Коммит c3ed07e679
148 изменённых файлов: 2341 добавлений и 2338 удалений

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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