[MM-13671] Rework Team InviteId Creation and Updates (#10536)

* Add regenerate invite ID endpoint; Dont allow inviteID updates via other methods; Remove unrequired checks in get handler

* Fix tests; Dont accept TeamId as invite ID

* Ensure all teams have an InviteID set

* Custom Selector to get empty teams; dont crash when inviteid set fails

* Remote InviteId from TeamPatch

* Add missing translation

* Translation string order

* Use sync store

* gofmt
Этот коммит содержится в:
Daniel Schalla
2019-04-25 23:09:38 +02:00
коммит произвёл GitHub
родитель ec95793b90
Коммит f7982216e4
11 изменённых файлов: 109 добавлений и 99 удалений

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

@@ -307,8 +307,8 @@ func TestUpdateTeam(t *testing.T) {
uteam, resp = Client.UpdateTeam(team)
CheckNoError(t, resp)
if uteam.InviteId != "inviteid1" {
t.Fatal("Update failed")
if uteam.InviteId == "inviteid1" {
t.Fatal("InviteID should not be updated")
}
team.AllowedDomains = "domain"
@@ -411,7 +411,6 @@ func TestPatchTeam(t *testing.T) {
patch.DisplayName = model.NewString("Other name")
patch.Description = model.NewString("Other description")
patch.CompanyName = model.NewString("Other company name")
patch.InviteId = model.NewString("inviteid1")
patch.AllowOpenInvite = model.NewBool(true)
rteam, resp := Client.PatchTeam(team.Id, patch)
@@ -426,8 +425,8 @@ func TestPatchTeam(t *testing.T) {
if rteam.CompanyName != "Other company name" {
t.Fatal("CompanyName did not update properly")
}
if rteam.InviteId != "inviteid1" {
t.Fatal("InviteId did not update properly")
if rteam.InviteId == "inviteid1" {
t.Fatal("InviteId should not update")
}
if !rteam.AllowOpenInvite {
t.Fatal("AllowOpenInvite did not update properly")
@@ -504,6 +503,24 @@ func TestPatchTeamSanitization(t *testing.T) {
})
}
func TestRegenerateTeamInviteId(t *testing.T) {
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
team := &model.Team{DisplayName: "Name", Description: "Some description", CompanyName: "Some company name", AllowOpenInvite: false, InviteId: "inviteid0", Name: "z-z-" + model.NewId() + "a", Email: "success+" + model.NewId() + "@simulator.amazonses.com", Type: model.TEAM_OPEN}
team, _ = Client.CreateTeam(team)
assert.NotEqual(t, team.InviteId, "")
assert.NotEqual(t, team.InviteId, "inviteid0")
rteam, resp := Client.RegenerateTeamInviteId(team.Id)
CheckNoError(t, resp)
assert.NotEqual(t, team.InviteId, rteam.InviteId)
assert.NotEqual(t, team.InviteId, "")
}
func TestSoftDeleteTeam(t *testing.T) {
th := Setup().InitBasic()
defer th.TearDown()