Not allowing to use team invite links by guest accounts (#12608)

* Not allowing to use team invite links by guest accounts

* Adding needed tests

* Updating error text
Этот коммит содержится в:
Jesús Espino
2019-10-08 19:07:56 +02:00
коммит произвёл GitHub
родитель 7ed2ac52a0
Коммит a6fdb72b19
3 изменённых файлов: 32 добавлений и 1 удалений

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

@@ -1359,13 +1359,26 @@ func TestAddTeamMember(t *testing.T) {
team := th.BasicTeam
otherUser := th.CreateUser()
th.App.SetLicense(model.NewTestLicense(""))
defer th.App.SetLicense(nil)
enableGuestAccounts := *th.App.Config().GuestAccountsSettings.Enable
defer func() {
th.App.UpdateConfig(func(cfg *model.Config) { cfg.GuestAccountsSettings.Enable = &enableGuestAccounts })
}()
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.GuestAccountsSettings.Enable = true })
guest := th.CreateUser()
_, resp := th.SystemAdminClient.DemoteUserToGuest(guest.Id)
CheckNoError(t, resp)
if err := th.App.RemoveUserFromTeam(th.BasicTeam.Id, th.BasicUser2.Id, ""); err != nil {
t.Fatalf(err.Error())
}
// Regular user can't add a member to a team they don't belong to.
th.LoginBasic2()
_, resp := Client.AddTeamMember(team.Id, otherUser.Id)
_, resp = Client.AddTeamMember(team.Id, otherUser.Id)
CheckForbiddenStatus(t, resp)
if resp.Error == nil {
t.Fatalf("Error is nil")
@@ -1506,6 +1519,15 @@ func TestAddTeamMember(t *testing.T) {
CheckNotFoundStatus(t, resp)
th.App.DeleteToken(token)
// by invite_id
th.App.SetLicense(model.NewTestLicense(""))
defer th.App.SetLicense(nil)
_, resp = Client.Login(guest.Email, guest.Password)
CheckNoError(t, resp)
tm, resp = Client.AddTeamMemberFromInvite("", team.InviteId)
CheckForbiddenStatus(t, resp)
// by invite_id
Client.Login(otherUser.Email, otherUser.Password)