[MM-56061] Only render where field in model.AppError when it's present (#25648)
* Only render where field in model.AppError when it's present * Remove trailing comma from permission error
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
a54f927e3d
Коммит
5b6b425cfc
@@ -242,7 +242,7 @@ func (s *MmctlE2ETestSuite) TestUserInviteCmdf() {
|
||||
s.Require().Len(printer.GetLines(), 0)
|
||||
s.Require().Len(printer.GetErrorLines(), 1)
|
||||
s.Require().Equal(
|
||||
fmt.Sprintf("Unable to invite user with email %s to team %s. Error: : Email invitations are disabled.",
|
||||
fmt.Sprintf("Unable to invite user with email %s to team %s. Error: Email invitations are disabled.",
|
||||
s.th.BasicUser.Email,
|
||||
s.th.BasicTeam.Name,
|
||||
),
|
||||
@@ -270,7 +270,7 @@ func (s *MmctlE2ETestSuite) TestUserInviteCmdf() {
|
||||
s.Require().Len(printer.GetLines(), 0)
|
||||
s.Require().Len(printer.GetErrorLines(), 1)
|
||||
s.Require().Equal(
|
||||
fmt.Sprintf(`Unable to invite user with email %s to team %s. Error: : The following email addresses do not belong to an accepted domain: %s. Please contact your System Administrator for details.`,
|
||||
fmt.Sprintf(`Unable to invite user with email %s to team %s. Error: The following email addresses do not belong to an accepted domain: %s. Please contact your System Administrator for details.`,
|
||||
user.Email,
|
||||
team.Name,
|
||||
user.Email,
|
||||
@@ -337,7 +337,7 @@ func (s *MmctlE2ETestSuite) TestResetUserMfaCmd() {
|
||||
var expected error
|
||||
|
||||
expected = multierror.Append(
|
||||
expected, fmt.Errorf(`unable to reset user %q MFA. Error: : You do not have the appropriate permissions.`, user.Id), //nolint:revive
|
||||
expected, fmt.Errorf(`unable to reset user %q MFA. Error: You do not have the appropriate permissions.`, user.Id), //nolint:revive
|
||||
|
||||
)
|
||||
|
||||
@@ -368,7 +368,7 @@ func (s *MmctlE2ETestSuite) TestVerifyUserEmailWithoutTokenCmd() {
|
||||
var expected error
|
||||
|
||||
expected = multierror.Append(
|
||||
expected, fmt.Errorf("unable to verify user "+user.Id+" email: : You do not have the appropriate permissions."),
|
||||
expected, fmt.Errorf("unable to verify user "+user.Id+" email: You do not have the appropriate permissions."),
|
||||
)
|
||||
|
||||
s.Require().EqualError(err, expected.Error())
|
||||
@@ -452,7 +452,7 @@ func (s *MmctlE2ETestSuite) TestCreateUserCmd() {
|
||||
cmd.Flags().Bool("system-admin", true, "")
|
||||
|
||||
err := userCreateCmdF(s.th.Client, cmd, []string{})
|
||||
s.EqualError(err, "Unable to update user roles. Error: : You do not have the appropriate permissions.")
|
||||
s.EqualError(err, "Unable to update user roles. Error: You do not have the appropriate permissions.")
|
||||
s.Require().Empty(printer.GetLines())
|
||||
user, err := s.th.App.GetUserByEmail(email)
|
||||
s.Require().Nil(err)
|
||||
@@ -541,7 +541,7 @@ func (s *MmctlE2ETestSuite) TestUpdateUserEmailCmd() {
|
||||
printer.Clean()
|
||||
newEmail := "basicuser2-change@fakedomain.com"
|
||||
err := updateUserEmailCmdF(s.th.Client, &cobra.Command{}, []string{s.th.BasicUser2.Id, newEmail})
|
||||
s.Require().EqualError(err, ": You do not have the appropriate permissions.")
|
||||
s.Require().EqualError(err, "You do not have the appropriate permissions.")
|
||||
|
||||
u, err := s.th.App.GetUser(s.th.BasicUser2.Id)
|
||||
s.Require().Nil(err)
|
||||
@@ -553,7 +553,7 @@ func (s *MmctlE2ETestSuite) TestUpdateUserEmailCmd() {
|
||||
|
||||
newEmail := "basicuser-change@fakedomain.com"
|
||||
err := updateUserEmailCmdF(s.th.Client, &cobra.Command{}, []string{s.th.BasicUser.Id, newEmail})
|
||||
s.Require().EqualError(err, ": Invalid or missing password in request body.")
|
||||
s.Require().EqualError(err, "Invalid or missing password in request body.")
|
||||
})
|
||||
}
|
||||
|
||||
@@ -580,7 +580,7 @@ func (s *MmctlE2ETestSuite) TestUpdateUsernameCmd() {
|
||||
printer.Clean()
|
||||
newUsername := "basicusernamechange"
|
||||
err := updateUsernameCmdF(s.th.Client, &cobra.Command{}, []string{s.th.BasicUser2.Id, newUsername})
|
||||
s.Require().EqualError(err, ": You do not have the appropriate permissions.")
|
||||
s.Require().EqualError(err, "You do not have the appropriate permissions.")
|
||||
|
||||
u, err := s.th.App.GetUser(s.th.BasicUser2.Id)
|
||||
s.Require().Nil(err)
|
||||
@@ -675,7 +675,7 @@ func (s *MmctlE2ETestSuite) TestDeleteUsersCmd() {
|
||||
s.Require().Nil(err)
|
||||
s.Len(printer.GetLines(), 0)
|
||||
s.Len(printer.GetErrorLines(), 1)
|
||||
s.Require().Equal(fmt.Sprintf("Unable to delete user '%s' error: : You do not have the appropriate permissions.", newUser.Username), printer.GetErrorLines()[0])
|
||||
s.Require().Equal(fmt.Sprintf("Unable to delete user '%s' error: You do not have the appropriate permissions.", newUser.Username), printer.GetErrorLines()[0])
|
||||
|
||||
// expect user not deleted
|
||||
user, err := s.th.App.GetUser(newUser.Id)
|
||||
@@ -701,7 +701,7 @@ func (s *MmctlE2ETestSuite) TestDeleteUsersCmd() {
|
||||
s.Require().Nil(err)
|
||||
s.Len(printer.GetLines(), 0)
|
||||
s.Len(printer.GetErrorLines(), 1)
|
||||
s.Require().Equal(fmt.Sprintf("Unable to delete user '%s' error: : Permanent user deletion feature is not enabled. Please contact your System Administrator.", newUser.Username), printer.GetErrorLines()[0])
|
||||
s.Require().Equal(fmt.Sprintf("Unable to delete user '%s' error: Permanent user deletion feature is not enabled. Please contact your System Administrator.", newUser.Username), printer.GetErrorLines()[0])
|
||||
|
||||
// expect user not deleted
|
||||
user, err := s.th.App.GetUser(newUser.Id)
|
||||
@@ -793,7 +793,7 @@ func (s *MmctlE2ETestSuite) TestUserConvertCmdF() {
|
||||
_ = userConvertCmdF(s.th.Client, cmd, []string{email})
|
||||
s.Require().Len(printer.GetLines(), 0)
|
||||
s.Require().Len(printer.GetErrorLines(), 1)
|
||||
s.Equal(": You do not have the appropriate permissions.", printer.GetErrorLines()[0])
|
||||
s.Equal("You do not have the appropriate permissions.", printer.GetErrorLines()[0])
|
||||
})
|
||||
|
||||
s.RunForSystemAdminAndLocal("Valid bot to user convert", func(c client.Client) {
|
||||
@@ -826,7 +826,7 @@ func (s *MmctlE2ETestSuite) TestUserConvertCmdF() {
|
||||
|
||||
err := userConvertCmdF(s.th.Client, cmd, []string{bot.Username})
|
||||
s.Require().Error(err)
|
||||
s.EqualError(err, ": You do not have the appropriate permissions.")
|
||||
s.EqualError(err, "You do not have the appropriate permissions.")
|
||||
s.Require().Len(printer.GetLines(), 0)
|
||||
s.Require().Len(printer.GetErrorLines(), 0)
|
||||
})
|
||||
@@ -940,7 +940,7 @@ func (s *MmctlE2ETestSuite) TestPromoteGuestToUserCmd() {
|
||||
s.Require().Nil(err)
|
||||
s.Require().Len(printer.GetLines(), 0)
|
||||
s.Require().Len(printer.GetErrorLines(), 1)
|
||||
s.Require().Equal(fmt.Sprintf("unable to promote guest %s: %s", user.Email, ": You do not have the appropriate permissions."), printer.GetErrorLines()[0])
|
||||
s.Require().Equal(fmt.Sprintf("unable to promote guest %s: You do not have the appropriate permissions.", user.Email), printer.GetErrorLines()[0])
|
||||
})
|
||||
}
|
||||
|
||||
@@ -970,7 +970,7 @@ func (s *MmctlE2ETestSuite) TestDemoteUserToGuestCmd() {
|
||||
s.Require().NotNil(err)
|
||||
s.Require().Len(printer.GetLines(), 0)
|
||||
s.Require().Len(printer.GetErrorLines(), 1)
|
||||
s.Require().Equal(fmt.Sprintf("unable to demote user %s: %s", user.Email, ": You do not have the appropriate permissions."), printer.GetErrorLines()[0])
|
||||
s.Require().Equal(fmt.Sprintf("unable to demote user %s: You do not have the appropriate permissions.", user.Email), printer.GetErrorLines()[0])
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user