MM-25014 - Default Group Name to null, until AllowGroupReference is set (#14651)
* make Group.Name a pointer to allow null * fix unit tests * fix build error * fix unit test * ensure Name field not nil Co-authored-by: mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
91f010b8b7
Коммит
ebece6c23a
@@ -689,7 +689,7 @@ func (me *TestHelper) GenerateTestEmail() string {
|
||||
func (me *TestHelper) CreateGroup() *model.Group {
|
||||
id := model.NewId()
|
||||
group := &model.Group{
|
||||
Name: "n-" + id,
|
||||
Name: model.NewString("n-" + id),
|
||||
DisplayName: "dn_" + id,
|
||||
Source: model.GroupSourceLdap,
|
||||
RemoteId: "ri_" + id,
|
||||
|
||||
@@ -3611,7 +3611,7 @@ func TestGetChannelMemberCountsByGroup(t *testing.T) {
|
||||
id := model.NewId()
|
||||
group := &model.Group{
|
||||
DisplayName: "dn_" + id,
|
||||
Name: "name" + id,
|
||||
Name: model.NewString("name" + id),
|
||||
Source: model.GroupSourceLdap,
|
||||
RemoteId: model.NewId(),
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ func TestGetGroup(t *testing.T) {
|
||||
id := model.NewId()
|
||||
g, err := th.App.CreateGroup(&model.Group{
|
||||
DisplayName: "dn_" + id,
|
||||
Name: "name" + id,
|
||||
Name: model.NewString("name" + id),
|
||||
Source: model.GroupSourceLdap,
|
||||
Description: "description_" + id,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -66,7 +66,7 @@ func TestPatchGroup(t *testing.T) {
|
||||
id := model.NewId()
|
||||
g, err := th.App.CreateGroup(&model.Group{
|
||||
DisplayName: "dn_" + id,
|
||||
Name: "name" + id,
|
||||
Name: model.NewString("name" + id),
|
||||
Source: model.GroupSourceLdap,
|
||||
Description: "description_" + id,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -75,7 +75,7 @@ func TestPatchGroup(t *testing.T) {
|
||||
|
||||
updateFmt := "%s_updated"
|
||||
|
||||
newName := fmt.Sprintf(updateFmt, g.Name)
|
||||
newName := fmt.Sprintf(updateFmt, *g.Name)
|
||||
newDisplayName := fmt.Sprintf(updateFmt, g.DisplayName)
|
||||
newDescription := fmt.Sprintf(updateFmt, g.Description)
|
||||
|
||||
@@ -101,8 +101,8 @@ func TestPatchGroup(t *testing.T) {
|
||||
|
||||
assert.Equal(t, *gp.DisplayName, group.DisplayName)
|
||||
assert.Equal(t, *gp.DisplayName, group2.DisplayName)
|
||||
assert.Equal(t, *gp.Name, group.Name)
|
||||
assert.Equal(t, *gp.Name, group2.Name)
|
||||
assert.Equal(t, *gp.Name, *group.Name)
|
||||
assert.Equal(t, *gp.Name, *group2.Name)
|
||||
assert.Equal(t, *gp.Description, group.Description)
|
||||
assert.Equal(t, *gp.Description, group2.Description)
|
||||
|
||||
@@ -132,7 +132,7 @@ func TestLinkGroupTeam(t *testing.T) {
|
||||
id := model.NewId()
|
||||
g, err := th.App.CreateGroup(&model.Group{
|
||||
DisplayName: "dn_" + id,
|
||||
Name: "name" + id,
|
||||
Name: model.NewString("name" + id),
|
||||
Source: model.GroupSourceLdap,
|
||||
Description: "description_" + id,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -170,7 +170,7 @@ func TestLinkGroupChannel(t *testing.T) {
|
||||
id := model.NewId()
|
||||
g, err := th.App.CreateGroup(&model.Group{
|
||||
DisplayName: "dn_" + id,
|
||||
Name: "name" + id,
|
||||
Name: model.NewString("name" + id),
|
||||
Source: model.GroupSourceLdap,
|
||||
Description: "description_" + id,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -209,7 +209,7 @@ func TestUnlinkGroupTeam(t *testing.T) {
|
||||
id := model.NewId()
|
||||
g, err := th.App.CreateGroup(&model.Group{
|
||||
DisplayName: "dn_" + id,
|
||||
Name: "name" + id,
|
||||
Name: model.NewString("name" + id),
|
||||
Source: model.GroupSourceLdap,
|
||||
Description: "description_" + id,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -256,7 +256,7 @@ func TestUnlinkGroupChannel(t *testing.T) {
|
||||
id := model.NewId()
|
||||
g, err := th.App.CreateGroup(&model.Group{
|
||||
DisplayName: "dn_" + id,
|
||||
Name: "name" + id,
|
||||
Name: model.NewString("name" + id),
|
||||
Source: model.GroupSourceLdap,
|
||||
Description: "description_" + id,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -306,7 +306,7 @@ func TestGetGroupTeam(t *testing.T) {
|
||||
id := model.NewId()
|
||||
g, err := th.App.CreateGroup(&model.Group{
|
||||
DisplayName: "dn_" + id,
|
||||
Name: "name" + id,
|
||||
Name: model.NewString("name" + id),
|
||||
Source: model.GroupSourceLdap,
|
||||
Description: "description_" + id,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -360,7 +360,7 @@ func TestGetGroupChannel(t *testing.T) {
|
||||
id := model.NewId()
|
||||
g, err := th.App.CreateGroup(&model.Group{
|
||||
DisplayName: "dn_" + id,
|
||||
Name: "name" + id,
|
||||
Name: model.NewString("name" + id),
|
||||
Source: model.GroupSourceLdap,
|
||||
Description: "description_" + id,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -414,7 +414,7 @@ func TestGetGroupTeams(t *testing.T) {
|
||||
id := model.NewId()
|
||||
g, err := th.App.CreateGroup(&model.Group{
|
||||
DisplayName: "dn_" + id,
|
||||
Name: "name" + id,
|
||||
Name: model.NewString("name" + id),
|
||||
Source: model.GroupSourceLdap,
|
||||
Description: "description_" + id,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -463,7 +463,7 @@ func TestGetGroupChannels(t *testing.T) {
|
||||
id := model.NewId()
|
||||
g, err := th.App.CreateGroup(&model.Group{
|
||||
DisplayName: "dn_" + id,
|
||||
Name: "name" + id,
|
||||
Name: model.NewString("name" + id),
|
||||
Source: model.GroupSourceLdap,
|
||||
Description: "description_" + id,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -512,7 +512,7 @@ func TestPatchGroupTeam(t *testing.T) {
|
||||
id := model.NewId()
|
||||
g, err := th.App.CreateGroup(&model.Group{
|
||||
DisplayName: "dn_" + id,
|
||||
Name: "name" + id,
|
||||
Name: model.NewString("name" + id),
|
||||
Source: model.GroupSourceLdap,
|
||||
Description: "description_" + id,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -577,7 +577,7 @@ func TestPatchGroupChannel(t *testing.T) {
|
||||
id := model.NewId()
|
||||
g, err := th.App.CreateGroup(&model.Group{
|
||||
DisplayName: "dn_" + id,
|
||||
Name: "name" + id,
|
||||
Name: model.NewString("name" + id),
|
||||
Source: model.GroupSourceLdap,
|
||||
Description: "description_" + id,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -651,7 +651,7 @@ func TestGetGroupsByChannel(t *testing.T) {
|
||||
id := model.NewId()
|
||||
group, err := th.App.CreateGroup(&model.Group{
|
||||
DisplayName: "dn_" + id,
|
||||
Name: "name" + id,
|
||||
Name: model.NewString("name" + id),
|
||||
Source: model.GroupSourceLdap,
|
||||
Description: "description_" + id,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -718,7 +718,7 @@ func TestGetGroupsAssociatedToChannelsByTeam(t *testing.T) {
|
||||
id := model.NewId()
|
||||
group, err := th.App.CreateGroup(&model.Group{
|
||||
DisplayName: "dn_" + id,
|
||||
Name: "name" + id,
|
||||
Name: model.NewString("name" + id),
|
||||
Source: model.GroupSourceLdap,
|
||||
Description: "description_" + id,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -792,7 +792,7 @@ func TestGetGroupsByTeam(t *testing.T) {
|
||||
id := model.NewId()
|
||||
group, err := th.App.CreateGroup(&model.Group{
|
||||
DisplayName: "dn_" + id,
|
||||
Name: "name" + id,
|
||||
Name: model.NewString("name" + id),
|
||||
Source: model.GroupSourceLdap,
|
||||
Description: "description_" + id,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -856,7 +856,7 @@ func TestGetGroups(t *testing.T) {
|
||||
id := model.NewId()
|
||||
group, err := th.App.CreateGroup(&model.Group{
|
||||
DisplayName: "dn-foo_" + id,
|
||||
Name: "name" + id,
|
||||
Name: model.NewString("name" + id),
|
||||
Source: model.GroupSourceLdap,
|
||||
Description: "description_" + id,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -953,7 +953,7 @@ func TestGetGroupsByUserId(t *testing.T) {
|
||||
id := model.NewId()
|
||||
group1, err := th.App.CreateGroup(&model.Group{
|
||||
DisplayName: "dn-foo_" + id,
|
||||
Name: "name" + id,
|
||||
Name: model.NewString("name" + id),
|
||||
Source: model.GroupSourceLdap,
|
||||
Description: "description_" + id,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -969,7 +969,7 @@ func TestGetGroupsByUserId(t *testing.T) {
|
||||
id = model.NewId()
|
||||
group2, err := th.App.CreateGroup(&model.Group{
|
||||
DisplayName: "dn-foo_" + id,
|
||||
Name: "name" + id,
|
||||
Name: model.NewString("name" + id),
|
||||
Source: model.GroupSourceLdap,
|
||||
Description: "description_" + id,
|
||||
RemoteId: model.NewId(),
|
||||
|
||||
@@ -194,11 +194,9 @@ func linkLdapGroup(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
} else {
|
||||
// Group has never been linked
|
||||
//
|
||||
// TODO: In a future phase of LDAP groups sync `Name` will be used for at-mentions and will be editable on
|
||||
// the front-end so it will not have an initial value of `model.NewId()` but rather a slugified version of
|
||||
// the LDAP group name with an appended duplicate-breaker.
|
||||
// For group mentions implementation, the Name column will no longer be set by default.
|
||||
// Instead it will be set and saved in the web app when Group Mentions is enabled.
|
||||
newGroup := &model.Group{
|
||||
Name: model.NewId(),
|
||||
DisplayName: displayName,
|
||||
RemoteId: ldapGroup.RemoteId,
|
||||
Source: model.GroupSourceLdap,
|
||||
|
||||
@@ -62,7 +62,7 @@ func TestCreateGroup(t *testing.T) {
|
||||
id := model.NewId()
|
||||
group := &model.Group{
|
||||
DisplayName: "dn_" + id,
|
||||
Name: "name" + id,
|
||||
Name: model.NewString("name" + id),
|
||||
Source: model.GroupSourceLdap,
|
||||
RemoteId: model.NewId(),
|
||||
}
|
||||
|
||||
@@ -500,7 +500,7 @@ func (me *TestHelper) CreateGroup() *model.Group {
|
||||
id := model.NewId()
|
||||
group := &model.Group{
|
||||
DisplayName: "dn_" + id,
|
||||
Name: "name" + id,
|
||||
Name: model.NewString("name" + id),
|
||||
Source: model.GroupSourceLdap,
|
||||
Description: "description_" + id,
|
||||
RemoteId: model.NewId(),
|
||||
|
||||
@@ -658,7 +658,9 @@ func (m *ExplicitMentions) addGroupMention(word string, groups map[string]*model
|
||||
m.GroupMentions = make(map[string]*model.Group)
|
||||
}
|
||||
|
||||
m.GroupMentions[group.Name] = group
|
||||
if group.Name != nil {
|
||||
m.GroupMentions[*group.Name] = group
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
@@ -766,7 +768,9 @@ func (a *App) getGroupsAllowedForReferenceInChannel(channel *model.Channel, team
|
||||
return nil, err
|
||||
}
|
||||
for _, group := range groups {
|
||||
groupsMap[group.Group.Name] = &group.Group
|
||||
if group.Group.Name != nil {
|
||||
groupsMap[*group.Group.Name] = &group.Group
|
||||
}
|
||||
}
|
||||
return groupsMap, nil
|
||||
}
|
||||
@@ -776,7 +780,9 @@ func (a *App) getGroupsAllowedForReferenceInChannel(channel *model.Channel, team
|
||||
return nil, err
|
||||
}
|
||||
for _, group := range groups {
|
||||
groupsMap[group.Name] = group
|
||||
if group.Name != nil {
|
||||
groupsMap[*group.Name] = group
|
||||
}
|
||||
}
|
||||
|
||||
return groupsMap, nil
|
||||
|
||||
@@ -831,7 +831,7 @@ func TestGetExplicitMentions(t *testing.T) {
|
||||
},
|
||||
"No matching groups": {
|
||||
Message: "@nothing",
|
||||
Groups: map[string]*model.Group{"engineering": {Name: "engineering"}},
|
||||
Groups: map[string]*model.Group{"engineering": {Name: model.NewString("engineering")}},
|
||||
Expected: &ExplicitMentions{
|
||||
Mentions: nil,
|
||||
GroupMentions: nil,
|
||||
@@ -840,7 +840,7 @@ func TestGetExplicitMentions(t *testing.T) {
|
||||
},
|
||||
"matching group with no @": {
|
||||
Message: "engineering",
|
||||
Groups: map[string]*model.Group{"engineering": {Name: "engineering"}},
|
||||
Groups: map[string]*model.Group{"engineering": {Name: model.NewString("engineering")}},
|
||||
Expected: &ExplicitMentions{
|
||||
Mentions: nil,
|
||||
GroupMentions: nil,
|
||||
@@ -849,22 +849,22 @@ func TestGetExplicitMentions(t *testing.T) {
|
||||
},
|
||||
"matching group with preceeding @": {
|
||||
Message: "@engineering",
|
||||
Groups: map[string]*model.Group{"engineering": {Name: "engineering"}},
|
||||
Groups: map[string]*model.Group{"engineering": {Name: model.NewString("engineering")}},
|
||||
Expected: &ExplicitMentions{
|
||||
Mentions: nil,
|
||||
GroupMentions: map[string]*model.Group{
|
||||
"engineering": {Name: "engineering"},
|
||||
"engineering": {Name: model.NewString("engineering")},
|
||||
},
|
||||
OtherPotentialMentions: []string{"engineering"},
|
||||
},
|
||||
},
|
||||
"matching upper case group with preceeding @": {
|
||||
Message: "@Engineering",
|
||||
Groups: map[string]*model.Group{"engineering": {Name: "engineering"}},
|
||||
Groups: map[string]*model.Group{"engineering": {Name: model.NewString("engineering")}},
|
||||
Expected: &ExplicitMentions{
|
||||
Mentions: nil,
|
||||
GroupMentions: map[string]*model.Group{
|
||||
"engineering": {Name: "engineering"},
|
||||
"engineering": {Name: model.NewString("engineering")},
|
||||
},
|
||||
OtherPotentialMentions: []string{"Engineering"},
|
||||
},
|
||||
@@ -2042,22 +2042,22 @@ func TestAddGroupMention(t *testing.T) {
|
||||
},
|
||||
"No matching groups": {
|
||||
Word: "nothing",
|
||||
Groups: map[string]*model.Group{"engineering": {Name: "engineering"}, "developers": {Name: "developers"}},
|
||||
Groups: map[string]*model.Group{"engineering": {Name: model.NewString("engineering")}, "developers": {Name: model.NewString("developers")}},
|
||||
Expected: false,
|
||||
},
|
||||
"matching group with no @": {
|
||||
Word: "engineering",
|
||||
Groups: map[string]*model.Group{"engineering": {Name: "engineering"}, "developers": {Name: "developers"}},
|
||||
Groups: map[string]*model.Group{"engineering": {Name: model.NewString("engineering")}, "developers": {Name: model.NewString("developers")}},
|
||||
Expected: false,
|
||||
},
|
||||
"matching group with preceeding @": {
|
||||
Word: "@engineering",
|
||||
Groups: map[string]*model.Group{"engineering": {Name: "engineering"}, "developers": {Name: "developers"}},
|
||||
Groups: map[string]*model.Group{"engineering": {Name: model.NewString("engineering")}, "developers": {Name: model.NewString("developers")}},
|
||||
Expected: true,
|
||||
},
|
||||
"matching upper case group with preceeding @": {
|
||||
Word: "@Engineering",
|
||||
Groups: map[string]*model.Group{"engineering": {Name: "engineering"}, "developers": {Name: "developers"}},
|
||||
Groups: map[string]*model.Group{"engineering": {Name: model.NewString("engineering")}, "developers": {Name: model.NewString("developers")}},
|
||||
Expected: true,
|
||||
},
|
||||
} {
|
||||
@@ -2086,7 +2086,7 @@ func TestProcessText(t *testing.T) {
|
||||
"Mention user in text": {
|
||||
Text: "hello user @user1",
|
||||
Keywords: map[string][]string{"@user1": {id1}},
|
||||
Groups: map[string]*model.Group{"engineering": {Name: "engineering"}, "developers": {Name: "developers"}},
|
||||
Groups: map[string]*model.Group{"engineering": {Name: model.NewString("engineering")}, "developers": {Name: model.NewString("developers")}},
|
||||
Expected: &ExplicitMentions{
|
||||
Mentions: map[string]MentionType{
|
||||
id1: KeywordMention,
|
||||
@@ -2096,7 +2096,7 @@ func TestProcessText(t *testing.T) {
|
||||
"Mention user after ending a sentence with full stop": {
|
||||
Text: "hello user.@user1",
|
||||
Keywords: map[string][]string{"@user1": {id1}},
|
||||
Groups: map[string]*model.Group{"engineering": {Name: "engineering"}, "developers": {Name: "developers"}},
|
||||
Groups: map[string]*model.Group{"engineering": {Name: model.NewString("engineering")}, "developers": {Name: model.NewString("developers")}},
|
||||
Expected: &ExplicitMentions{
|
||||
Mentions: map[string]MentionType{
|
||||
id1: KeywordMention,
|
||||
@@ -2115,7 +2115,7 @@ func TestProcessText(t *testing.T) {
|
||||
"Mention user after colon": {
|
||||
Text: "hello user:@user1",
|
||||
Keywords: map[string][]string{"@user1": {id1}},
|
||||
Groups: map[string]*model.Group{"engineering": {Name: "engineering"}, "developers": {Name: "developers"}},
|
||||
Groups: map[string]*model.Group{"engineering": {Name: model.NewString("engineering")}, "developers": {Name: model.NewString("developers")}},
|
||||
Expected: &ExplicitMentions{
|
||||
Mentions: map[string]MentionType{
|
||||
id1: KeywordMention,
|
||||
@@ -2125,7 +2125,7 @@ func TestProcessText(t *testing.T) {
|
||||
"Mention here after colon": {
|
||||
Text: "hello all:@here",
|
||||
Keywords: map[string][]string{},
|
||||
Groups: map[string]*model.Group{"engineering": {Name: "engineering"}, "developers": {Name: "developers"}},
|
||||
Groups: map[string]*model.Group{"engineering": {Name: model.NewString("engineering")}, "developers": {Name: model.NewString("developers")}},
|
||||
Expected: &ExplicitMentions{
|
||||
HereMentioned: true,
|
||||
},
|
||||
@@ -2133,7 +2133,7 @@ func TestProcessText(t *testing.T) {
|
||||
"Mention all after hyphen": {
|
||||
Text: "hello all-@all",
|
||||
Keywords: map[string][]string{},
|
||||
Groups: map[string]*model.Group{"engineering": {Name: "engineering"}, "developers": {Name: "developers"}},
|
||||
Groups: map[string]*model.Group{"engineering": {Name: model.NewString("engineering")}, "developers": {Name: model.NewString("developers")}},
|
||||
Expected: &ExplicitMentions{
|
||||
AllMentioned: true,
|
||||
},
|
||||
@@ -2141,7 +2141,7 @@ func TestProcessText(t *testing.T) {
|
||||
"Mention channel after full stop": {
|
||||
Text: "hello channel.@channel",
|
||||
Keywords: map[string][]string{},
|
||||
Groups: map[string]*model.Group{"engineering": {Name: "engineering"}, "developers": {Name: "developers"}},
|
||||
Groups: map[string]*model.Group{"engineering": {Name: model.NewString("engineering")}, "developers": {Name: model.NewString("developers")}},
|
||||
Expected: &ExplicitMentions{
|
||||
ChannelMentioned: true,
|
||||
},
|
||||
@@ -2149,7 +2149,7 @@ func TestProcessText(t *testing.T) {
|
||||
"Mention other pontential users or system calls": {
|
||||
Text: "hello @potentialuser and @otherpotentialuser",
|
||||
Keywords: map[string][]string{},
|
||||
Groups: map[string]*model.Group{"engineering": {Name: "engineering"}, "developers": {Name: "developers"}},
|
||||
Groups: map[string]*model.Group{"engineering": {Name: model.NewString("engineering")}, "developers": {Name: model.NewString("developers")}},
|
||||
Expected: &ExplicitMentions{
|
||||
OtherPotentialMentions: []string{"potentialuser", "otherpotentialuser"},
|
||||
},
|
||||
@@ -2157,7 +2157,7 @@ func TestProcessText(t *testing.T) {
|
||||
"Mention a real user and another potential user": {
|
||||
Text: "@user1, you can use @systembot to get help",
|
||||
Keywords: map[string][]string{"@user1": {id1}},
|
||||
Groups: map[string]*model.Group{"engineering": {Name: "engineering"}, "developers": {Name: "developers"}},
|
||||
Groups: map[string]*model.Group{"engineering": {Name: model.NewString("engineering")}, "developers": {Name: model.NewString("developers")}},
|
||||
Expected: &ExplicitMentions{
|
||||
Mentions: map[string]MentionType{
|
||||
id1: KeywordMention,
|
||||
@@ -2168,21 +2168,21 @@ func TestProcessText(t *testing.T) {
|
||||
"Mention a group": {
|
||||
Text: "@engineering",
|
||||
Keywords: map[string][]string{"@user1": {id1}},
|
||||
Groups: map[string]*model.Group{"engineering": {Name: "engineering"}, "developers": {Name: "developers"}},
|
||||
Groups: map[string]*model.Group{"engineering": {Name: model.NewString("engineering")}, "developers": {Name: model.NewString("developers")}},
|
||||
Expected: &ExplicitMentions{
|
||||
GroupMentions: map[string]*model.Group{"engineering": {Name: "engineering"}},
|
||||
GroupMentions: map[string]*model.Group{"engineering": {Name: model.NewString("engineering")}},
|
||||
OtherPotentialMentions: []string{"engineering"},
|
||||
},
|
||||
},
|
||||
"Mention a real user and another potential user and a group": {
|
||||
Text: "@engineering @user1, you can use @systembot to get help from",
|
||||
Keywords: map[string][]string{"@user1": {id1}},
|
||||
Groups: map[string]*model.Group{"engineering": {Name: "engineering"}, "developers": {Name: "developers"}},
|
||||
Groups: map[string]*model.Group{"engineering": {Name: model.NewString("engineering")}, "developers": {Name: model.NewString("developers")}},
|
||||
Expected: &ExplicitMentions{
|
||||
Mentions: map[string]MentionType{
|
||||
id1: KeywordMention,
|
||||
},
|
||||
GroupMentions: map[string]*model.Group{"engineering": {Name: "engineering"}},
|
||||
GroupMentions: map[string]*model.Group{"engineering": {Name: model.NewString("engineering")}},
|
||||
OtherPotentialMentions: []string{"engineering", "systembot"},
|
||||
},
|
||||
},
|
||||
@@ -2324,7 +2324,7 @@ func TestInsertGroupMentions(t *testing.T) {
|
||||
channel := th.BasicChannel
|
||||
group := th.CreateGroup()
|
||||
group.DisplayName = "engineering"
|
||||
group.Name = "engineering"
|
||||
group.Name = model.NewString("engineering")
|
||||
group, err := th.App.UpdateGroup(group)
|
||||
require.Nil(t, err)
|
||||
|
||||
@@ -2345,7 +2345,7 @@ func TestInsertGroupMentions(t *testing.T) {
|
||||
|
||||
groupWithNoMembers := th.CreateGroup()
|
||||
groupWithNoMembers.DisplayName = "marketing"
|
||||
groupWithNoMembers.Name = "marketing"
|
||||
groupWithNoMembers.Name = model.NewString("marketing")
|
||||
groupWithNoMembers, err = th.App.UpdateGroup(groupWithNoMembers)
|
||||
require.Nil(t, err)
|
||||
|
||||
@@ -2444,8 +2444,8 @@ func TestGetGroupsAllowedForReferenceInChannel(t *testing.T) {
|
||||
groupsMap, err = th.App.getGroupsAllowedForReferenceInChannel(channel, team)
|
||||
require.Nil(t, err)
|
||||
require.Len(t, groupsMap, 1)
|
||||
require.Nil(t, groupsMap[group2.Name])
|
||||
require.Equal(t, groupsMap[group1.Name], group1)
|
||||
require.Nil(t, groupsMap[*group2.Name])
|
||||
require.Equal(t, groupsMap[*group1.Name], group1)
|
||||
})
|
||||
|
||||
group2.AllowReference = true
|
||||
@@ -2468,8 +2468,8 @@ func TestGetGroupsAllowedForReferenceInChannel(t *testing.T) {
|
||||
groupsMap, err = th.App.getGroupsAllowedForReferenceInChannel(constrainedChannel, team)
|
||||
require.Nil(t, err)
|
||||
require.Len(t, groupsMap, 1)
|
||||
require.Nil(t, groupsMap[group2.Name])
|
||||
require.Equal(t, groupsMap[group1.Name], group1)
|
||||
require.Nil(t, groupsMap[*group2.Name])
|
||||
require.Equal(t, groupsMap[*group1.Name], group1)
|
||||
})
|
||||
|
||||
// Create a third group not synced with a team or channel
|
||||
@@ -2493,18 +2493,18 @@ func TestGetGroupsAllowedForReferenceInChannel(t *testing.T) {
|
||||
groupsMap, err = th.App.getGroupsAllowedForReferenceInChannel(channel, team)
|
||||
require.Nil(t, err)
|
||||
require.Len(t, groupsMap, 2)
|
||||
require.Nil(t, groupsMap[group3.Name])
|
||||
require.Equal(t, groupsMap[group2.Name], group2)
|
||||
require.Equal(t, groupsMap[group1.Name], group1)
|
||||
require.Nil(t, groupsMap[*group3.Name])
|
||||
require.Equal(t, groupsMap[*group2.Name], group2)
|
||||
require.Equal(t, groupsMap[*group1.Name], group1)
|
||||
})
|
||||
|
||||
t.Run("should return only subset of groups synced to channel for group constrained channel when team is also group constrained", func(t *testing.T) {
|
||||
groupsMap, err = th.App.getGroupsAllowedForReferenceInChannel(constrainedChannel, team)
|
||||
require.Nil(t, err)
|
||||
require.Len(t, groupsMap, 1)
|
||||
require.Nil(t, groupsMap[group3.Name])
|
||||
require.Nil(t, groupsMap[group2.Name])
|
||||
require.Equal(t, groupsMap[group1.Name], group1)
|
||||
require.Nil(t, groupsMap[*group3.Name])
|
||||
require.Nil(t, groupsMap[*group2.Name])
|
||||
require.Equal(t, groupsMap[*group1.Name], group1)
|
||||
})
|
||||
|
||||
team.GroupConstrained = model.NewBool(false)
|
||||
@@ -2515,8 +2515,8 @@ func TestGetGroupsAllowedForReferenceInChannel(t *testing.T) {
|
||||
groupsMap, err = th.App.getGroupsAllowedForReferenceInChannel(channel, team)
|
||||
require.Nil(t, err)
|
||||
require.Len(t, groupsMap, 3)
|
||||
require.Equal(t, groupsMap[group1.Name], group1)
|
||||
require.Equal(t, groupsMap[group2.Name], group2)
|
||||
require.Equal(t, groupsMap[group3.Name], group3)
|
||||
require.Equal(t, groupsMap[*group1.Name], group1)
|
||||
require.Equal(t, groupsMap[*group2.Name], group2)
|
||||
require.Equal(t, groupsMap[*group3.Name], group3)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ func TestCreateDefaultMemberships(t *testing.T) {
|
||||
}
|
||||
|
||||
gleeGroup, err := th.App.CreateGroup(&model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: "Glee Club",
|
||||
RemoteId: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
@@ -65,7 +65,7 @@ func TestCreateDefaultMemberships(t *testing.T) {
|
||||
}
|
||||
|
||||
scienceGroup, err := th.App.CreateGroup(&model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: "Science Club",
|
||||
RemoteId: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
|
||||
@@ -29,7 +29,7 @@ func TestChannelGroupEnable(t *testing.T) {
|
||||
id := model.NewId()
|
||||
group, err := th.App.CreateGroup(&model.Group{
|
||||
DisplayName: "dn_" + id,
|
||||
Name: "name" + id,
|
||||
Name: model.NewString("name" + id),
|
||||
Source: model.GroupSourceLdap,
|
||||
Description: "description_" + id,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -73,7 +73,7 @@ func TestChannelGroupDisable(t *testing.T) {
|
||||
id := model.NewId()
|
||||
group, err := th.App.CreateGroup(&model.Group{
|
||||
DisplayName: "dn_" + id,
|
||||
Name: "name" + id,
|
||||
Name: model.NewString("name" + id),
|
||||
Source: model.GroupSourceLdap,
|
||||
Description: "description_" + id,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -120,7 +120,7 @@ func TestChannelGroupStatus(t *testing.T) {
|
||||
id := model.NewId()
|
||||
group, err := th.App.CreateGroup(&model.Group{
|
||||
DisplayName: "dn_" + id,
|
||||
Name: "name" + id,
|
||||
Name: model.NewString("name" + id),
|
||||
Source: model.GroupSourceLdap,
|
||||
Description: "description_" + id,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -163,7 +163,7 @@ func TestChannelGroupList(t *testing.T) {
|
||||
id1 := model.NewId()
|
||||
g1, err := th.App.CreateGroup(&model.Group{
|
||||
DisplayName: "dn_" + id1,
|
||||
Name: "name" + id1,
|
||||
Name: model.NewString("name" + id1),
|
||||
Source: model.GroupSourceLdap,
|
||||
Description: "description_" + id1,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -181,7 +181,7 @@ func TestChannelGroupList(t *testing.T) {
|
||||
id2 := model.NewId()
|
||||
g2, err := th.App.CreateGroup(&model.Group{
|
||||
DisplayName: "dn_" + id2,
|
||||
Name: "name" + id2,
|
||||
Name: model.NewString("name" + id2),
|
||||
Source: model.GroupSourceLdap,
|
||||
Description: "description_" + id2,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -222,7 +222,7 @@ func TestTeamGroupEnable(t *testing.T) {
|
||||
id := model.NewId()
|
||||
group, err := th.App.CreateGroup(&model.Group{
|
||||
DisplayName: "dn_" + id,
|
||||
Name: "name" + id,
|
||||
Name: model.NewString("name" + id),
|
||||
Source: model.GroupSourceLdap,
|
||||
Description: "description_" + id,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -263,7 +263,7 @@ func TestTeamGroupDisable(t *testing.T) {
|
||||
id := model.NewId()
|
||||
group, err := th.App.CreateGroup(&model.Group{
|
||||
DisplayName: "dn_" + id,
|
||||
Name: "name" + id,
|
||||
Name: model.NewString("name" + id),
|
||||
Source: model.GroupSourceLdap,
|
||||
Description: "description_" + id,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -307,7 +307,7 @@ func TestTeamGroupStatus(t *testing.T) {
|
||||
id := model.NewId()
|
||||
group, err := th.App.CreateGroup(&model.Group{
|
||||
DisplayName: "dn_" + id,
|
||||
Name: "name" + id,
|
||||
Name: model.NewString("name" + id),
|
||||
Source: model.GroupSourceLdap,
|
||||
Description: "description_" + id,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -347,7 +347,7 @@ func TestTeamGroupList(t *testing.T) {
|
||||
id1 := model.NewId()
|
||||
g1, err := th.App.CreateGroup(&model.Group{
|
||||
DisplayName: "dn_" + id1,
|
||||
Name: "name" + id1,
|
||||
Name: model.NewString("name" + id1),
|
||||
Source: model.GroupSourceLdap,
|
||||
Description: "description_" + id1,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -365,7 +365,7 @@ func TestTeamGroupList(t *testing.T) {
|
||||
id2 := model.NewId()
|
||||
g2, err := th.App.CreateGroup(&model.Group{
|
||||
DisplayName: "dn_" + id2,
|
||||
Name: "name" + id2,
|
||||
Name: model.NewString("name" + id2),
|
||||
Source: model.GroupSourceLdap,
|
||||
Description: "description_" + id2,
|
||||
RemoteId: model.NewId(),
|
||||
|
||||
@@ -353,7 +353,11 @@ func newAuditGroup(g *Group) auditGroup {
|
||||
var group auditGroup
|
||||
if g != nil {
|
||||
group.ID = g.Id
|
||||
group.Name = g.Name
|
||||
if g.Name == nil {
|
||||
group.Name = ""
|
||||
} else {
|
||||
group.Name = *g.Name
|
||||
}
|
||||
group.DisplayName = g.DisplayName
|
||||
group.Description = g.Description
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ var groupSourcesRequiringRemoteID = []GroupSource{
|
||||
|
||||
type Group struct {
|
||||
Id string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
DisplayName string `json:"display_name"`
|
||||
Description string `json:"description"`
|
||||
Source GroupSource `json:"source"`
|
||||
@@ -90,7 +90,7 @@ type PageOpts struct {
|
||||
|
||||
func (group *Group) Patch(patch *GroupPatch) {
|
||||
if patch.Name != nil {
|
||||
group.Name = *patch.Name
|
||||
group.Name = patch.Name
|
||||
}
|
||||
if patch.DisplayName != nil {
|
||||
group.DisplayName = *patch.DisplayName
|
||||
@@ -168,14 +168,20 @@ func (group *Group) ToJson() string {
|
||||
var validGroupnameChars = regexp.MustCompile(`^[a-z0-9\.\-_]+$`)
|
||||
|
||||
func (group *Group) IsValidName() *AppError {
|
||||
if l := len(group.Name); l == 0 || l > GroupNameMaxLength {
|
||||
return NewAppError("Group.IsValidName", "model.group.name.app_error", map[string]interface{}{"GroupNameMaxLength": GroupNameMaxLength}, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if !validGroupnameChars.MatchString(group.Name) {
|
||||
return NewAppError("Group.IsValidName", "model.group.name.invalid_chars.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
if group.Name == nil {
|
||||
if group.AllowReference {
|
||||
return NewAppError("Group.IsValidName", "model.group.name.app_error", map[string]interface{}{"GroupNameMaxLength": GroupNameMaxLength}, "", http.StatusBadRequest)
|
||||
}
|
||||
} else {
|
||||
if l := len(*group.Name); l == 0 || l > GroupNameMaxLength {
|
||||
return NewAppError("Group.IsValidName", "model.group.name.app_error", map[string]interface{}{"GroupNameMaxLength": GroupNameMaxLength}, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if !validGroupnameChars.MatchString(*group.Name) {
|
||||
return NewAppError("Group.IsValidName", "model.group.name.invalid_chars.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -798,6 +798,7 @@ func upgradeDatabaseToVersion524(sqlStore SqlStore) {
|
||||
// if shouldPerformUpgrade(sqlStore, VERSION_5_23_0, VERSION_5_24_0) {
|
||||
|
||||
sqlStore.CreateColumnIfNotExists("UserGroups", "AllowReference", "boolean", "boolean", "0")
|
||||
sqlStore.GetMaster().Exec("UPDATE UserGroups SET Name = null, AllowReference = false")
|
||||
sqlStore.AlterPrimaryKey("Reactions", []string{"PostId", "UserId", "EmojiName"})
|
||||
|
||||
// saveSchemaVersion(sqlStore, VERSION_5_24_0)
|
||||
|
||||
@@ -3203,7 +3203,7 @@ func testChannelStoreGetAllChannels(t *testing.T, ss store.Store, s SqlSupplier)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
group := &model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -4276,7 +4276,7 @@ func testGetMemberCountsByGroup(t *testing.T, ss store.Store) {
|
||||
var memberCounts []*model.ChannelMemberCountByGroup
|
||||
teamId := model.NewId()
|
||||
g1 := &model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -4348,7 +4348,7 @@ func testGetMemberCountsByGroup(t *testing.T, ss store.Store) {
|
||||
})
|
||||
|
||||
g2 := &model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -4386,7 +4386,7 @@ func testGetMemberCountsByGroup(t *testing.T, ss store.Store) {
|
||||
}
|
||||
|
||||
g3 := &model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -5168,7 +5168,7 @@ func testChannelStoreSearchAllChannels(t *testing.T, ss store.Store) {
|
||||
require.Nil(t, nErr)
|
||||
|
||||
group := &model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
RemoteId: model.NewId(),
|
||||
|
||||
@@ -87,7 +87,7 @@ func TestGroupStore(t *testing.T, ss store.Store) {
|
||||
func testGroupStoreCreate(t *testing.T, ss store.Store) {
|
||||
// Save a new group
|
||||
g1 := &model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
Description: model.NewId(),
|
||||
@@ -98,7 +98,7 @@ func testGroupStoreCreate(t *testing.T, ss store.Store) {
|
||||
d1, err := ss.Group().Create(g1)
|
||||
require.Nil(t, err)
|
||||
require.Len(t, d1.Id, 26)
|
||||
require.Equal(t, g1.Name, d1.Name)
|
||||
require.Equal(t, *g1.Name, *d1.Name)
|
||||
require.Equal(t, g1.DisplayName, d1.DisplayName)
|
||||
require.Equal(t, g1.Description, d1.Description)
|
||||
require.Equal(t, g1.RemoteId, d1.RemoteId)
|
||||
@@ -106,28 +106,21 @@ func testGroupStoreCreate(t *testing.T, ss store.Store) {
|
||||
require.NotZero(t, d1.UpdateAt)
|
||||
require.Zero(t, d1.DeleteAt)
|
||||
|
||||
// Requires name and display name
|
||||
// Requires display name
|
||||
g2 := &model.Group{
|
||||
Name: "",
|
||||
DisplayName: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: "",
|
||||
Source: model.GroupSourceLdap,
|
||||
RemoteId: model.NewId(),
|
||||
}
|
||||
data, err := ss.Group().Create(g2)
|
||||
require.Nil(t, data)
|
||||
require.NotNil(t, err)
|
||||
require.Equal(t, err.Id, "model.group.name.app_error")
|
||||
|
||||
g2.Name = model.NewId()
|
||||
g2.DisplayName = ""
|
||||
data, err = ss.Group().Create(g2)
|
||||
require.Nil(t, data)
|
||||
require.NotNil(t, err)
|
||||
require.Equal(t, err.Id, "model.group.display_name.app_error")
|
||||
|
||||
// Won't accept a duplicate name
|
||||
g4 := &model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -146,7 +139,7 @@ func testGroupStoreCreate(t *testing.T, ss store.Store) {
|
||||
|
||||
// Fields cannot be greater than max values
|
||||
g5 := &model.Group{
|
||||
Name: strings.Repeat("x", model.GroupNameMaxLength),
|
||||
Name: model.NewString(strings.Repeat("x", model.GroupNameMaxLength)),
|
||||
DisplayName: strings.Repeat("x", model.GroupDisplayNameMaxLength),
|
||||
Description: strings.Repeat("x", model.GroupDescriptionMaxLength),
|
||||
Source: model.GroupSourceLdap,
|
||||
@@ -154,9 +147,9 @@ func testGroupStoreCreate(t *testing.T, ss store.Store) {
|
||||
}
|
||||
require.Nil(t, g5.IsValidForCreate())
|
||||
|
||||
g5.Name = g5.Name + "x"
|
||||
g5.Name = model.NewString(*g5.Name + "x")
|
||||
require.Equal(t, g5.IsValidForCreate().Id, "model.group.name.app_error")
|
||||
g5.Name = model.NewId()
|
||||
g5.Name = model.NewString(model.NewId())
|
||||
require.Nil(t, g5.IsValidForCreate())
|
||||
|
||||
g5.DisplayName = g5.DisplayName + "x"
|
||||
@@ -171,7 +164,7 @@ func testGroupStoreCreate(t *testing.T, ss store.Store) {
|
||||
|
||||
// Must use a valid type
|
||||
g6 := &model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Description: model.NewId(),
|
||||
Source: model.GroupSource("fake"),
|
||||
@@ -181,7 +174,7 @@ func testGroupStoreCreate(t *testing.T, ss store.Store) {
|
||||
|
||||
//must use valid characters
|
||||
g7 := &model.Group{
|
||||
Name: "%^#@$$",
|
||||
Name: model.NewString("%^#@$$"),
|
||||
DisplayName: model.NewId(),
|
||||
Description: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
@@ -193,7 +186,7 @@ func testGroupStoreCreate(t *testing.T, ss store.Store) {
|
||||
func testGroupStoreGet(t *testing.T, ss store.Store) {
|
||||
// Create a group
|
||||
g1 := &model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Description: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
@@ -207,7 +200,7 @@ func testGroupStoreGet(t *testing.T, ss store.Store) {
|
||||
d2, err := ss.Group().Get(d1.Id)
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, d1.Id, d2.Id)
|
||||
require.Equal(t, d1.Name, d2.Name)
|
||||
require.Equal(t, *d1.Name, *d2.Name)
|
||||
require.Equal(t, d1.DisplayName, d2.DisplayName)
|
||||
require.Equal(t, d1.Description, d2.Description)
|
||||
require.Equal(t, d1.RemoteId, d2.RemoteId)
|
||||
@@ -224,7 +217,7 @@ func testGroupStoreGet(t *testing.T, ss store.Store) {
|
||||
func testGroupStoreGetByName(t *testing.T, ss store.Store) {
|
||||
// Create a group
|
||||
g1 := &model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Description: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
@@ -239,10 +232,10 @@ func testGroupStoreGetByName(t *testing.T, ss store.Store) {
|
||||
require.Len(t, d1.Id, 26)
|
||||
|
||||
// Get the group
|
||||
d2, err := ss.Group().GetByName(d1.Name, g1Opts)
|
||||
d2, err := ss.Group().GetByName(*d1.Name, g1Opts)
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, d1.Id, d2.Id)
|
||||
require.Equal(t, d1.Name, d2.Name)
|
||||
require.Equal(t, *d1.Name, *d2.Name)
|
||||
require.Equal(t, d1.DisplayName, d2.DisplayName)
|
||||
require.Equal(t, d1.Description, d2.Description)
|
||||
require.Equal(t, d1.RemoteId, d2.RemoteId)
|
||||
@@ -262,7 +255,7 @@ func testGroupStoreGetByIDs(t *testing.T, ss store.Store) {
|
||||
|
||||
for i := 0; i < 2; i++ {
|
||||
group := &model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Description: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
@@ -292,7 +285,7 @@ func testGroupStoreGetByIDs(t *testing.T, ss store.Store) {
|
||||
func testGroupStoreGetByRemoteID(t *testing.T, ss store.Store) {
|
||||
// Create a group
|
||||
g1 := &model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Description: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
@@ -306,7 +299,7 @@ func testGroupStoreGetByRemoteID(t *testing.T, ss store.Store) {
|
||||
d2, err := ss.Group().GetByRemoteID(d1.RemoteId, model.GroupSourceLdap)
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, d1.Id, d2.Id)
|
||||
require.Equal(t, d1.Name, d2.Name)
|
||||
require.Equal(t, *d1.Name, *d2.Name)
|
||||
require.Equal(t, d1.DisplayName, d2.DisplayName)
|
||||
require.Equal(t, d1.Description, d2.Description)
|
||||
require.Equal(t, d1.RemoteId, d2.RemoteId)
|
||||
@@ -328,7 +321,7 @@ func testGroupStoreGetAllByType(t *testing.T, ss store.Store) {
|
||||
// Create groups
|
||||
for i := 0; i < numGroups; i++ {
|
||||
g := &model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Description: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
@@ -358,7 +351,7 @@ func testGroupStoreGetAllByType(t *testing.T, ss store.Store) {
|
||||
func testGroupStoreGetByUser(t *testing.T, ss store.Store) {
|
||||
// Save a group
|
||||
g1 := &model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Description: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
@@ -368,7 +361,7 @@ func testGroupStoreGetByUser(t *testing.T, ss store.Store) {
|
||||
require.Nil(t, err)
|
||||
|
||||
g2 := &model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Description: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
@@ -428,7 +421,7 @@ func testGroupStoreGetByUser(t *testing.T, ss store.Store) {
|
||||
func testGroupStoreUpdate(t *testing.T, ss store.Store) {
|
||||
// Save a new group
|
||||
g1 := &model.Group{
|
||||
Name: "g1-test",
|
||||
Name: model.NewString("g1-test"),
|
||||
DisplayName: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
Description: model.NewId(),
|
||||
@@ -442,7 +435,7 @@ func testGroupStoreUpdate(t *testing.T, ss store.Store) {
|
||||
// Update happy path
|
||||
g1Update := &model.Group{}
|
||||
*g1Update = *g1
|
||||
g1Update.Name = model.NewId()
|
||||
g1Update.Name = model.NewString(model.NewId())
|
||||
g1Update.DisplayName = model.NewId()
|
||||
g1Update.Description = model.NewId()
|
||||
g1Update.RemoteId = model.NewId()
|
||||
@@ -456,27 +449,15 @@ func testGroupStoreUpdate(t *testing.T, ss store.Store) {
|
||||
// Still zero...
|
||||
require.Zero(t, ud1.DeleteAt)
|
||||
// Updated...
|
||||
require.Equal(t, g1Update.Name, ud1.Name)
|
||||
require.Equal(t, *g1Update.Name, *ud1.Name)
|
||||
require.Equal(t, g1Update.DisplayName, ud1.DisplayName)
|
||||
require.Equal(t, g1Update.Description, ud1.Description)
|
||||
require.Equal(t, g1Update.RemoteId, ud1.RemoteId)
|
||||
|
||||
// Requires name and display name
|
||||
// Requires display name
|
||||
data, err := ss.Group().Update(&model.Group{
|
||||
Id: d1.Id,
|
||||
Name: "",
|
||||
DisplayName: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
RemoteId: model.NewId(),
|
||||
Description: model.NewId(),
|
||||
})
|
||||
require.Nil(t, data)
|
||||
require.NotNil(t, err)
|
||||
require.Equal(t, err.Id, "model.group.name.app_error")
|
||||
|
||||
data, err = ss.Group().Update(&model.Group{
|
||||
Id: d1.Id,
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: "",
|
||||
Source: model.GroupSourceLdap,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -487,7 +468,7 @@ func testGroupStoreUpdate(t *testing.T, ss store.Store) {
|
||||
|
||||
// Create another Group
|
||||
g2 := &model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
Description: model.NewId(),
|
||||
@@ -529,7 +510,7 @@ func testGroupStoreUpdate(t *testing.T, ss store.Store) {
|
||||
func testGroupStoreDelete(t *testing.T, ss store.Store) {
|
||||
// Save a group
|
||||
g1 := &model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Description: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
@@ -577,7 +558,7 @@ func testGroupStoreDelete(t *testing.T, ss store.Store) {
|
||||
func testGroupGetMemberUsers(t *testing.T, ss store.Store) {
|
||||
// Save a group
|
||||
g1 := &model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Description: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
@@ -629,7 +610,7 @@ func testGroupGetMemberUsers(t *testing.T, ss store.Store) {
|
||||
func testGroupGetMemberUsersPage(t *testing.T, ss store.Store) {
|
||||
// Save a group
|
||||
g1 := &model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Description: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
@@ -716,7 +697,7 @@ func testGroupGetMemberUsersInTeam(t *testing.T, ss store.Store) {
|
||||
|
||||
// Save a group
|
||||
g1 := &model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Description: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
@@ -802,7 +783,7 @@ func testGroupGetMemberUsersNotInChannel(t *testing.T, ss store.Store) {
|
||||
|
||||
// Save a group
|
||||
g1 := &model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Description: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
@@ -929,7 +910,7 @@ func testGroupGetMemberUsersNotInChannel(t *testing.T, ss store.Store) {
|
||||
func testUpsertMember(t *testing.T, ss store.Store) {
|
||||
// Create group
|
||||
g1 := &model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -987,7 +968,7 @@ func testUpsertMember(t *testing.T, ss store.Store) {
|
||||
func testGroupDeleteMember(t *testing.T, ss store.Store) {
|
||||
// Create group
|
||||
g1 := &model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -1035,7 +1016,7 @@ func testGroupPermanentDeleteMembersByUser(t *testing.T, ss store.Store) {
|
||||
|
||||
for i := 0; i < numberOfGroups; i++ {
|
||||
g = &model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -1071,7 +1052,7 @@ func testCreateGroupSyncable(t *testing.T, ss store.Store) {
|
||||
|
||||
// Create Group
|
||||
g1 := &model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -1107,7 +1088,7 @@ func testCreateGroupSyncable(t *testing.T, ss store.Store) {
|
||||
func testGetGroupSyncable(t *testing.T, ss store.Store) {
|
||||
// Create a group
|
||||
g1 := &model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Description: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
@@ -1151,7 +1132,7 @@ func testGetAllGroupSyncablesByGroup(t *testing.T, ss store.Store) {
|
||||
|
||||
// Create group
|
||||
g := &model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Description: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
@@ -1208,7 +1189,7 @@ func testGetAllGroupSyncablesByGroup(t *testing.T, ss store.Store) {
|
||||
func testUpdateGroupSyncable(t *testing.T, ss store.Store) {
|
||||
// Create Group
|
||||
g1 := &model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -1274,7 +1255,7 @@ func testUpdateGroupSyncable(t *testing.T, ss store.Store) {
|
||||
func testDeleteGroupSyncable(t *testing.T, ss store.Store) {
|
||||
// Create Group
|
||||
g1 := &model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -1328,7 +1309,7 @@ func testDeleteGroupSyncable(t *testing.T, ss store.Store) {
|
||||
func testTeamMembersToAdd(t *testing.T, ss store.Store) {
|
||||
// Create Group
|
||||
group, err := ss.Group().Create(&model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: "TeamMembersToAdd Test Group",
|
||||
RemoteId: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
@@ -1490,7 +1471,7 @@ func testTeamMembersToAdd(t *testing.T, ss store.Store) {
|
||||
|
||||
func testTeamMembersToAddSingleTeam(t *testing.T, ss store.Store) {
|
||||
group1, err := ss.Group().Create(&model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: "TeamMembersToAdd Test Group",
|
||||
RemoteId: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
@@ -1498,7 +1479,7 @@ func testTeamMembersToAddSingleTeam(t *testing.T, ss store.Store) {
|
||||
require.Nil(t, err)
|
||||
|
||||
group2, err := ss.Group().Create(&model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: "TeamMembersToAdd Test Group",
|
||||
RemoteId: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
@@ -1581,7 +1562,7 @@ func testTeamMembersToAddSingleTeam(t *testing.T, ss store.Store) {
|
||||
func testChannelMembersToAdd(t *testing.T, ss store.Store) {
|
||||
// Create Group
|
||||
group, err := ss.Group().Create(&model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: "ChannelMembersToAdd Test Group",
|
||||
RemoteId: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
@@ -1749,7 +1730,7 @@ func testChannelMembersToAdd(t *testing.T, ss store.Store) {
|
||||
|
||||
func testChannelMembersToAddSingleChannel(t *testing.T, ss store.Store) {
|
||||
group1, err := ss.Group().Create(&model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: "TeamMembersToAdd Test Group",
|
||||
RemoteId: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
@@ -1757,7 +1738,7 @@ func testChannelMembersToAddSingleChannel(t *testing.T, ss store.Store) {
|
||||
require.Nil(t, err)
|
||||
|
||||
group2, err := ss.Group().Create(&model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: "TeamMembersToAdd Test Group",
|
||||
RemoteId: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
@@ -2137,7 +2118,7 @@ type removalsData struct {
|
||||
func pendingMemberRemovalsDataSetup(t *testing.T, ss store.Store) *removalsData {
|
||||
// create group
|
||||
group, err := ss.Group().Create(&model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: "Pending[Channel|Team]MemberRemovals Test Group",
|
||||
RemoteId: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
@@ -2300,7 +2281,7 @@ func testGetGroupsByChannel(t *testing.T, ss store.Store) {
|
||||
|
||||
// Create Groups 1, 2 and a deleted group
|
||||
group1, err := ss.Group().Create(&model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: "group-1",
|
||||
RemoteId: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
@@ -2309,7 +2290,7 @@ func testGetGroupsByChannel(t *testing.T, ss store.Store) {
|
||||
require.Nil(t, err)
|
||||
|
||||
group2, err := ss.Group().Create(&model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: "group-2",
|
||||
RemoteId: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
@@ -2318,7 +2299,7 @@ func testGetGroupsByChannel(t *testing.T, ss store.Store) {
|
||||
require.Nil(t, err)
|
||||
|
||||
deletedGroup, err := ss.Group().Create(&model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: "group-deleted",
|
||||
RemoteId: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
@@ -2350,7 +2331,7 @@ func testGetGroupsByChannel(t *testing.T, ss store.Store) {
|
||||
|
||||
// Create Group3
|
||||
group3, err := ss.Group().Create(&model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: "group-3",
|
||||
RemoteId: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
@@ -2456,7 +2437,7 @@ func testGetGroupsByChannel(t *testing.T, ss store.Store) {
|
||||
{
|
||||
Name: "Get group matching name",
|
||||
ChannelId: channel1.Id,
|
||||
Opts: model.GroupSearchOpts{Q: string([]rune(group1.Name)[2:10])}, // very low change of a name collision
|
||||
Opts: model.GroupSearchOpts{Q: string([]rune(*group1.Name)[2:10])}, // very low change of a name collision
|
||||
Page: 0,
|
||||
PerPage: 100,
|
||||
Result: []*model.GroupWithSchemeAdmin{group1WSA},
|
||||
@@ -2548,7 +2529,7 @@ func testGetGroupsAssociatedToChannelsByTeam(t *testing.T, ss store.Store) {
|
||||
|
||||
// Create Groups 1, 2 and a deleted group
|
||||
group1, err := ss.Group().Create(&model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: "group-1",
|
||||
RemoteId: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
@@ -2557,7 +2538,7 @@ func testGetGroupsAssociatedToChannelsByTeam(t *testing.T, ss store.Store) {
|
||||
require.Nil(t, err)
|
||||
|
||||
group2, err := ss.Group().Create(&model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: "group-2",
|
||||
RemoteId: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
@@ -2566,7 +2547,7 @@ func testGetGroupsAssociatedToChannelsByTeam(t *testing.T, ss store.Store) {
|
||||
require.Nil(t, err)
|
||||
|
||||
deletedGroup, err := ss.Group().Create(&model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: "group-deleted",
|
||||
RemoteId: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
@@ -2598,7 +2579,7 @@ func testGetGroupsAssociatedToChannelsByTeam(t *testing.T, ss store.Store) {
|
||||
|
||||
// Create Group3
|
||||
group3, err := ss.Group().Create(&model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: "group-3",
|
||||
RemoteId: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
@@ -2696,7 +2677,7 @@ func testGetGroupsAssociatedToChannelsByTeam(t *testing.T, ss store.Store) {
|
||||
{
|
||||
Name: "Get group matching name",
|
||||
TeamId: team1.Id,
|
||||
Opts: model.GroupSearchOpts{Q: string([]rune(group1.Name)[2:10])}, // very low chance of a name collision
|
||||
Opts: model.GroupSearchOpts{Q: string([]rune(*group1.Name)[2:10])}, // very low chance of a name collision
|
||||
Page: 0,
|
||||
PerPage: 100,
|
||||
Result: map[string][]*model.GroupWithSchemeAdmin{channel1.Id: {group1WSA}},
|
||||
@@ -2781,7 +2762,7 @@ func testGetGroupsByTeam(t *testing.T, ss store.Store) {
|
||||
|
||||
// Create Groups 1, 2 and a deleted group
|
||||
group1, err := ss.Group().Create(&model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: "group-1",
|
||||
RemoteId: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
@@ -2790,7 +2771,7 @@ func testGetGroupsByTeam(t *testing.T, ss store.Store) {
|
||||
require.Nil(t, err)
|
||||
|
||||
group2, err := ss.Group().Create(&model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: "group-2",
|
||||
RemoteId: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
@@ -2799,7 +2780,7 @@ func testGetGroupsByTeam(t *testing.T, ss store.Store) {
|
||||
require.Nil(t, err)
|
||||
|
||||
deletedGroup, err := ss.Group().Create(&model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: "group-deleted",
|
||||
RemoteId: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
@@ -2835,7 +2816,7 @@ func testGetGroupsByTeam(t *testing.T, ss store.Store) {
|
||||
|
||||
// Create Group3
|
||||
group3, err := ss.Group().Create(&model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: "group-3",
|
||||
RemoteId: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
@@ -2945,7 +2926,7 @@ func testGetGroupsByTeam(t *testing.T, ss store.Store) {
|
||||
{
|
||||
Name: "Get group matching name",
|
||||
TeamId: team1.Id,
|
||||
Opts: model.GroupSearchOpts{Q: string([]rune(group1.Name)[2:10])}, // very low change of a name collision
|
||||
Opts: model.GroupSearchOpts{Q: string([]rune(*group1.Name)[2:10])}, // very low change of a name collision
|
||||
Page: 0,
|
||||
PerPage: 100,
|
||||
Result: []*model.GroupWithSchemeAdmin{group1WSA},
|
||||
@@ -3039,7 +3020,7 @@ func testGetGroups(t *testing.T, ss store.Store) {
|
||||
|
||||
// Create Groups 1 and 2
|
||||
group1, err := ss.Group().Create(&model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: "group-1",
|
||||
RemoteId: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
@@ -3048,7 +3029,7 @@ func testGetGroups(t *testing.T, ss store.Store) {
|
||||
require.Nil(t, err)
|
||||
|
||||
group2, err := ss.Group().Create(&model.Group{
|
||||
Name: model.NewId() + "-group-2",
|
||||
Name: model.NewString(model.NewId() + "-group-2"),
|
||||
DisplayName: "group-2",
|
||||
RemoteId: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
@@ -3057,7 +3038,7 @@ func testGetGroups(t *testing.T, ss store.Store) {
|
||||
require.Nil(t, err)
|
||||
|
||||
deletedGroup, err := ss.Group().Create(&model.Group{
|
||||
Name: model.NewId() + "-group-deleted",
|
||||
Name: model.NewString(model.NewId() + "-group-deleted"),
|
||||
DisplayName: "group-deleted",
|
||||
RemoteId: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
@@ -3103,7 +3084,7 @@ func testGetGroups(t *testing.T, ss store.Store) {
|
||||
|
||||
// Create Group3
|
||||
group3, err := ss.Group().Create(&model.Group{
|
||||
Name: model.NewId() + "-group-3",
|
||||
Name: model.NewString(model.NewId() + "-group-3"),
|
||||
DisplayName: "group-3",
|
||||
RemoteId: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
@@ -3213,7 +3194,7 @@ func testGetGroups(t *testing.T, ss store.Store) {
|
||||
PerPage: 100,
|
||||
Resultf: func(groups []*model.Group) bool {
|
||||
for _, g := range groups {
|
||||
if !strings.Contains(g.Name, group2NameSubstring) && !strings.Contains(g.DisplayName, group2NameSubstring) {
|
||||
if !strings.Contains(*g.Name, group2NameSubstring) && !strings.Contains(g.DisplayName, group2NameSubstring) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -3413,7 +3394,7 @@ func testTeamMembersMinusGroupMembers(t *testing.T, ss store.Store) {
|
||||
|
||||
for i := 0; i < numberOfGroups; i++ {
|
||||
group := &model.Group{
|
||||
Name: fmt.Sprintf("n_%d_%s", i, model.NewId()),
|
||||
Name: model.NewString(fmt.Sprintf("n_%d_%s", i, model.NewId())),
|
||||
DisplayName: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
Description: model.NewId(),
|
||||
@@ -3576,7 +3557,7 @@ func testChannelMembersMinusGroupMembers(t *testing.T, ss store.Store) {
|
||||
|
||||
for i := 0; i < numberOfGroups; i++ {
|
||||
group := &model.Group{
|
||||
Name: fmt.Sprintf("n_%d_%s", i, model.NewId()),
|
||||
Name: model.NewString(fmt.Sprintf("n_%d_%s", i, model.NewId())),
|
||||
DisplayName: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
Description: model.NewId(),
|
||||
@@ -3686,7 +3667,7 @@ func testChannelMembersMinusGroupMembers(t *testing.T, ss store.Store) {
|
||||
|
||||
func groupTestGetMemberCount(t *testing.T, ss store.Store) {
|
||||
group := &model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
Description: model.NewId(),
|
||||
@@ -3731,7 +3712,7 @@ func groupTestAdminRoleGroupsForSyncableMemberChannel(t *testing.T, ss store.Sto
|
||||
require.Nil(t, err)
|
||||
|
||||
group1 := &model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
Description: model.NewId(),
|
||||
@@ -3744,7 +3725,7 @@ func groupTestAdminRoleGroupsForSyncableMemberChannel(t *testing.T, ss store.Sto
|
||||
require.Nil(t, err)
|
||||
|
||||
group2 := &model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
Description: model.NewId(),
|
||||
@@ -3819,7 +3800,7 @@ func groupTestAdminRoleGroupsForSyncableMemberTeam(t *testing.T, ss store.Store)
|
||||
require.Nil(t, err)
|
||||
|
||||
group1 := &model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
Description: model.NewId(),
|
||||
@@ -3832,7 +3813,7 @@ func groupTestAdminRoleGroupsForSyncableMemberTeam(t *testing.T, ss store.Store)
|
||||
require.Nil(t, err)
|
||||
|
||||
group2 := &model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
Description: model.NewId(),
|
||||
@@ -3920,7 +3901,7 @@ func groupTestPermittedSyncableAdminsTeam(t *testing.T, ss store.Store) {
|
||||
require.Nil(t, err)
|
||||
|
||||
group1 := &model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
Description: model.NewId(),
|
||||
@@ -3935,7 +3916,7 @@ func groupTestPermittedSyncableAdminsTeam(t *testing.T, ss store.Store) {
|
||||
require.Nil(t, err)
|
||||
|
||||
group2 := &model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
Description: model.NewId(),
|
||||
@@ -4026,7 +4007,7 @@ func groupTestPermittedSyncableAdminsChannel(t *testing.T, ss store.Store) {
|
||||
require.Nil(t, err)
|
||||
|
||||
group1 := &model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
Description: model.NewId(),
|
||||
@@ -4041,7 +4022,7 @@ func groupTestPermittedSyncableAdminsChannel(t *testing.T, ss store.Store) {
|
||||
require.Nil(t, err)
|
||||
|
||||
group2 := &model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
Description: model.NewId(),
|
||||
@@ -4326,7 +4307,7 @@ func groupTestpUpdateMembersRoleChannel(t *testing.T, ss store.Store) {
|
||||
|
||||
func groupTestGroupCount(t *testing.T, ss store.Store) {
|
||||
group1, err := ss.Group().Create(&model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -4339,7 +4320,7 @@ func groupTestGroupCount(t *testing.T, ss store.Store) {
|
||||
require.GreaterOrEqual(t, count, int64(1))
|
||||
|
||||
group2, err := ss.Group().Create(&model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -4366,7 +4347,7 @@ func groupTestGroupTeamCount(t *testing.T, ss store.Store) {
|
||||
defer ss.Team().PermanentDelete(team.Id)
|
||||
|
||||
group1, err := ss.Group().Create(&model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -4375,7 +4356,7 @@ func groupTestGroupTeamCount(t *testing.T, ss store.Store) {
|
||||
defer ss.Group().Delete(group1.Id)
|
||||
|
||||
group2, err := ss.Group().Create(&model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -4411,7 +4392,7 @@ func groupTestGroupChannelCount(t *testing.T, ss store.Store) {
|
||||
defer ss.Channel().Delete(channel.Id, 0)
|
||||
|
||||
group1, err := ss.Group().Create(&model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -4420,7 +4401,7 @@ func groupTestGroupChannelCount(t *testing.T, ss store.Store) {
|
||||
defer ss.Group().Delete(group1.Id)
|
||||
|
||||
group2, err := ss.Group().Create(&model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -4447,7 +4428,7 @@ func groupTestGroupChannelCount(t *testing.T, ss store.Store) {
|
||||
|
||||
func groupTestGroupMemberCount(t *testing.T, ss store.Store) {
|
||||
group, err := ss.Group().Create(&model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -4474,7 +4455,7 @@ func groupTestGroupMemberCount(t *testing.T, ss store.Store) {
|
||||
|
||||
func groupTestDistinctGroupMemberCount(t *testing.T, ss store.Store) {
|
||||
group1, err := ss.Group().Create(&model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -4483,7 +4464,7 @@ func groupTestDistinctGroupMemberCount(t *testing.T, ss store.Store) {
|
||||
defer ss.Group().Delete(group1.Id)
|
||||
|
||||
group2, err := ss.Group().Create(&model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -4521,7 +4502,7 @@ func groupTestGroupCountWithAllowReference(t *testing.T, ss store.Store) {
|
||||
require.Nil(t, err)
|
||||
|
||||
group1, err := ss.Group().Create(&model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
RemoteId: model.NewId(),
|
||||
@@ -4534,7 +4515,7 @@ func groupTestGroupCountWithAllowReference(t *testing.T, ss store.Store) {
|
||||
require.Equal(t, count, initialCount)
|
||||
|
||||
group2, err := ss.Group().Create(&model.Group{
|
||||
Name: model.NewId(),
|
||||
Name: model.NewString(model.NewId()),
|
||||
DisplayName: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
RemoteId: model.NewId(),
|
||||
|
||||
@@ -1198,7 +1198,7 @@ func testUserStoreGetProfilesNotInChannel(t *testing.T, ss store.Store) {
|
||||
|
||||
// create a group
|
||||
group, err := ss.Group().Create(&model.Group{
|
||||
Name: "n_" + model.NewId(),
|
||||
Name: model.NewString("n_" + model.NewId()),
|
||||
DisplayName: "dn_" + model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
RemoteId: "ri_" + model.NewId(),
|
||||
@@ -3375,7 +3375,7 @@ func testUserStoreGetProfilesNotInTeam(t *testing.T, ss store.Store) {
|
||||
|
||||
// create a group
|
||||
group, err := ss.Group().Create(&model.Group{
|
||||
Name: "n_" + model.NewId(),
|
||||
Name: model.NewString("n_" + model.NewId()),
|
||||
DisplayName: "dn_" + model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
RemoteId: "ri_" + model.NewId(),
|
||||
@@ -3691,7 +3691,7 @@ func testUserStoreGetTeamGroupUsers(t *testing.T, ss store.Store) {
|
||||
|
||||
var group *model.Group
|
||||
group, err = ss.Group().Create(&model.Group{
|
||||
Name: "n_" + id,
|
||||
Name: model.NewString("n_" + id),
|
||||
DisplayName: "dn_" + id,
|
||||
Source: model.GroupSourceLdap,
|
||||
RemoteId: "ri_" + id,
|
||||
@@ -3811,7 +3811,7 @@ func testUserStoreGetChannelGroupUsers(t *testing.T, ss store.Store) {
|
||||
id = model.NewId()
|
||||
var group *model.Group
|
||||
group, err = ss.Group().Create(&model.Group{
|
||||
Name: "n_" + id,
|
||||
Name: model.NewString("n_" + id),
|
||||
DisplayName: "dn_" + id,
|
||||
Source: model.GroupSourceLdap,
|
||||
RemoteId: "ri_" + id,
|
||||
|
||||
Ссылка в новой задаче
Block a user