MM-15021: Adding new builtin system schema for Guests (#10601)
* MM-15021: Adding new builtin system schema for Guests * Fixing tests * Setting properly the permissions * Adding guests to sampledata * Restrict more roles updates in the app layer for guests * Adding comment to explain that permissions migration must go at the end * Setting the default guest role for custom scheme during migration * Fixing import and export * Creating scheme guest roles on migration * Fixing tests * Fixing tests * Fixing tests
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
987360f325
Коммит
584ec68755
@@ -780,3 +780,71 @@ func TestGetTeamStats(t *testing.T) {
|
||||
require.Nil(t, err)
|
||||
assert.Equal(t, int64(len(members)), teamStats.TotalMemberCount)
|
||||
}
|
||||
|
||||
func TestUpdateTeamMemberRolesChangingGuest(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
t.Run("from guest to user", func(t *testing.T) {
|
||||
user := model.User{Email: strings.ToLower(model.NewId()) + "success+test@example.com", Nickname: "Darth Vader", Username: "vader" + model.NewId(), Password: "passwd1", AuthService: ""}
|
||||
ruser, _ := th.App.CreateGuest(&user)
|
||||
|
||||
_, err := th.App.AddUserToTeam(th.BasicTeam.Id, ruser.Id, "")
|
||||
require.Nil(t, err)
|
||||
|
||||
if _, err := th.App.UpdateTeamMemberRoles(th.BasicTeam.Id, ruser.Id, "team_user"); err == nil {
|
||||
t.Fatal("Should fail when try to modify the guest role")
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("from user to guest", func(t *testing.T) {
|
||||
user := model.User{Email: strings.ToLower(model.NewId()) + "success+test@example.com", Nickname: "Darth Vader", Username: "vader" + model.NewId(), Password: "passwd1", AuthService: ""}
|
||||
ruser, _ := th.App.CreateUser(&user)
|
||||
|
||||
_, err := th.App.AddUserToTeam(th.BasicTeam.Id, ruser.Id, "")
|
||||
require.Nil(t, err)
|
||||
|
||||
if _, err := th.App.UpdateTeamMemberRoles(th.BasicTeam.Id, ruser.Id, "team_guest"); err == nil {
|
||||
t.Fatal("Should fail when try to modify the guest role")
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("from user to admin", func(t *testing.T) {
|
||||
user := model.User{Email: strings.ToLower(model.NewId()) + "success+test@example.com", Nickname: "Darth Vader", Username: "vader" + model.NewId(), Password: "passwd1", AuthService: ""}
|
||||
ruser, _ := th.App.CreateUser(&user)
|
||||
|
||||
_, err := th.App.AddUserToTeam(th.BasicTeam.Id, ruser.Id, "")
|
||||
require.Nil(t, err)
|
||||
|
||||
if _, err := th.App.UpdateTeamMemberRoles(th.BasicTeam.Id, ruser.Id, "team_user team_admin"); err != nil {
|
||||
t.Fatal("Should work when you not modify guest role")
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("from guest to guest plus custom", func(t *testing.T) {
|
||||
user := model.User{Email: strings.ToLower(model.NewId()) + "success+test@example.com", Nickname: "Darth Vader", Username: "vader" + model.NewId(), Password: "passwd1", AuthService: ""}
|
||||
ruser, _ := th.App.CreateGuest(&user)
|
||||
|
||||
_, err := th.App.AddUserToTeam(th.BasicTeam.Id, ruser.Id, "")
|
||||
require.Nil(t, err)
|
||||
|
||||
_, err = th.App.CreateRole(&model.Role{Name: "custom", DisplayName: "custom", Description: "custom"})
|
||||
require.Nil(t, err)
|
||||
|
||||
if _, err := th.App.UpdateTeamMemberRoles(th.BasicTeam.Id, ruser.Id, "team_guest custom"); err != nil {
|
||||
t.Fatal("Should work when you not modify guest role")
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("a guest cant have user role", func(t *testing.T) {
|
||||
user := model.User{Email: strings.ToLower(model.NewId()) + "success+test@example.com", Nickname: "Darth Vader", Username: "vader" + model.NewId(), Password: "passwd1", AuthService: ""}
|
||||
ruser, _ := th.App.CreateGuest(&user)
|
||||
|
||||
_, err := th.App.AddUserToTeam(th.BasicTeam.Id, ruser.Id, "")
|
||||
require.Nil(t, err)
|
||||
|
||||
if _, err := th.App.UpdateTeamMemberRoles(th.BasicTeam.Id, ruser.Id, "team_guest team_user"); err == nil {
|
||||
t.Fatal("Should work when you not modify guest role")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user