коммит произвёл
GitHub
родитель
43e797010b
Коммит
3b1b8d9114
@@ -2071,8 +2071,16 @@ func TestGetGroups(t *testing.T) {
|
||||
|
||||
t.Run("not associated to channel", func(t *testing.T) {
|
||||
opts := baseOpts
|
||||
resp, err := th.SystemAdminClient.UpdateChannelRoles(context.Background(), th.BasicChannel.Id, th.BasicUser.Id, "")
|
||||
require.NoError(t, err)
|
||||
CheckOKStatus(t, resp)
|
||||
|
||||
opts.NotAssociatedToChannel = th.BasicChannel.Id
|
||||
|
||||
resp, err = th.SystemAdminClient.UpdateChannelRoles(context.Background(), th.BasicChannel.Id, th.BasicUser.Id, "channel_user channel_admin")
|
||||
require.NoError(t, err)
|
||||
CheckOKStatus(t, resp)
|
||||
|
||||
groups, resp, err := th.SystemAdminClient.GetGroups(context.Background(), opts)
|
||||
require.NoError(t, err)
|
||||
CheckOKStatus(t, resp)
|
||||
@@ -2081,8 +2089,16 @@ func TestGetGroups(t *testing.T) {
|
||||
|
||||
t.Run("not associated to team", func(t *testing.T) {
|
||||
opts := baseOpts
|
||||
resp, err := th.SystemAdminClient.UpdateTeamMemberRoles(context.Background(), th.BasicTeam.Id, th.BasicUser.Id, "")
|
||||
require.NoError(t, err)
|
||||
CheckOKStatus(t, resp)
|
||||
|
||||
opts.NotAssociatedToTeam = th.BasicTeam.Id
|
||||
|
||||
resp, err = th.SystemAdminClient.UpdateTeamMemberRoles(context.Background(), th.BasicTeam.Id, th.BasicUser.Id, "team_user team_admin")
|
||||
require.NoError(t, err)
|
||||
CheckOKStatus(t, resp)
|
||||
|
||||
groups, resp, err := th.SystemAdminClient.GetGroups(context.Background(), opts)
|
||||
require.NoError(t, err)
|
||||
CheckOKStatus(t, resp)
|
||||
|
||||
@@ -127,6 +127,12 @@ func createTeam(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
// Don't sanitize the team here since the user will be a team admin and their session won't reflect that yet
|
||||
// instead check the scheme roles for the team and if the user has the permission to invite users
|
||||
_, schemeUserRole, schemeAdminRole, schemeErr := c.App.GetSchemeRolesForTeam(rteam.Id)
|
||||
if schemeErr != nil || !c.App.RolesGrantPermission([]string{schemeUserRole, schemeAdminRole}, model.PermissionInviteUser.Id) {
|
||||
// If we can't check permissions, fail secure by hiding the invite_id because the team is already created above
|
||||
rteam.InviteId = ""
|
||||
}
|
||||
|
||||
auditRec.Success()
|
||||
auditRec.AddEventResultState(&team)
|
||||
|
||||
@@ -236,6 +236,29 @@ func TestCreateTeamSanitization(t *testing.T) {
|
||||
}, "system admin")
|
||||
}
|
||||
|
||||
func TestCreateTeamInviteIdHiddenWithoutInvitePermission(t *testing.T) {
|
||||
th := Setup(t)
|
||||
|
||||
defaultRolePermissions := th.SaveDefaultRolePermissions()
|
||||
defer th.RestoreDefaultRolePermissions(defaultRolePermissions)
|
||||
|
||||
// Remove PermissionInviteUser from the default team user role
|
||||
th.RemovePermissionFromRole(model.PermissionInviteUser.Id, model.TeamUserRoleId)
|
||||
|
||||
// Regular user creates a team - InviteId should be hidden
|
||||
// since the team user role lacks invite permission
|
||||
rteam, _, err := th.Client.CreateTeam(context.Background(), &model.Team{
|
||||
DisplayName: "Team Without Invite Permission",
|
||||
Name: GenerateTestTeamName(),
|
||||
Email: th.GenerateTestEmail(),
|
||||
Type: model.TeamOpen,
|
||||
AllowedDomains: "simulator.amazonses.com,localhost",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.NotEmpty(t, rteam.Email, "should not have sanitized email")
|
||||
require.Empty(t, rteam.InviteId, "should have hidden invite_id when user lacks invite permission")
|
||||
}
|
||||
|
||||
func TestGetTeam(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
|
||||
Ссылка в новой задаче
Block a user