MM-17053: avoid colliding with reserved team names (#11705)

There are a handful of “reserved” team names that will be rejected if found at the start of the team name – e.g. “api21251251” or “error1251251”. Turns out we just got really unlucky and a model.NewId invocation generated just such a collision. I've changed all such random generations to include a prefix.
Этот коммит содержится в:
Jesse Hallam
2019-07-26 20:41:20 -03:00
коммит произвёл GitHub
родитель f6480d1ac6
Коммит 1fa505c833
4 изменённых файлов: 15 добавлений и 15 удалений

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

@@ -1109,7 +1109,7 @@ func testChannelStoreGetAllChannels(t *testing.T, ss store.Store, s SqlSupplier)
t1 := model.Team{}
t1.DisplayName = "Name"
t1.Name = model.NewId()
t1.Name = "zz" + model.NewId()
t1.Email = MakeEmail()
t1.Type = model.TEAM_OPEN
_, err := ss.Team().Save(&t1)
@@ -1117,7 +1117,7 @@ func testChannelStoreGetAllChannels(t *testing.T, ss store.Store, s SqlSupplier)
t2 := model.Team{}
t2.DisplayName = "Name2"
t2.Name = model.NewId()
t2.Name = "zz" + model.NewId()
t2.Email = MakeEmail()
t2.Type = model.TEAM_OPEN
_, err = ss.Team().Save(&t2)
@@ -1594,7 +1594,7 @@ func testChannelStoreGetChannelCounts(t *testing.T, ss store.Store) {
func testChannelStoreGetMembersForUser(t *testing.T, ss store.Store) {
t1 := model.Team{}
t1.DisplayName = "Name"
t1.Name = model.NewId()
t1.Name = "zz" + model.NewId()
t1.Email = MakeEmail()
t1.Type = model.TEAM_OPEN
_, err := ss.Team().Save(&t1)
@@ -1686,7 +1686,7 @@ func testChannelStoreGetMembersForUser(t *testing.T, ss store.Store) {
func testChannelStoreGetMembersForUserWithPagination(t *testing.T, ss store.Store) {
t1 := model.Team{}
t1.DisplayName = "Name"
t1.Name = model.NewId()
t1.Name = "zz" + model.NewId()
t1.Email = MakeEmail()
t1.Type = model.TEAM_OPEN
_, err := ss.Team().Save(&t1)
@@ -2573,7 +2573,7 @@ func testChannelStoreSearchAllChannels(t *testing.T, ss store.Store) {
t1 := model.Team{}
t1.DisplayName = "Name"
t1.Name = model.NewId()
t1.Name = "zz" + model.NewId()
t1.Email = MakeEmail()
t1.Type = model.TEAM_OPEN
_, err := ss.Team().Save(&t1)
@@ -2581,7 +2581,7 @@ func testChannelStoreSearchAllChannels(t *testing.T, ss store.Store) {
t2 := model.Team{}
t2.DisplayName = "Name2"
t2.Name = model.NewId()
t2.Name = "zz" + model.NewId()
t2.Email = MakeEmail()
t2.Type = model.TEAM_OPEN
_, err = ss.Team().Save(&t2)
@@ -3670,7 +3670,7 @@ func testMaterializedPublicChannels(t *testing.T, ss store.Store, s SqlSupplier)
func testChannelStoreGetAllChannelsForExportAfter(t *testing.T, ss store.Store) {
t1 := model.Team{}
t1.DisplayName = "Name"
t1.Name = model.NewId()
t1.Name = "zz" + model.NewId()
t1.Email = MakeEmail()
t1.Type = model.TEAM_OPEN
_, err := ss.Team().Save(&t1)
@@ -3702,7 +3702,7 @@ func testChannelStoreGetAllChannelsForExportAfter(t *testing.T, ss store.Store)
func testChannelStoreGetChannelMembersForExport(t *testing.T, ss store.Store) {
t1 := model.Team{}
t1.DisplayName = "Name"
t1.Name = model.NewId()
t1.Name = "zz" + model.NewId()
t1.Email = MakeEmail()
t1.Type = model.TEAM_OPEN
_, err := ss.Team().Save(&t1)
@@ -3759,7 +3759,7 @@ func testChannelStoreRemoveAllDeactivatedMembers(t *testing.T, ss store.Store) {
// Set up all the objects needed in the store.
t1 := model.Team{}
t1.DisplayName = "Name"
t1.Name = model.NewId()
t1.Name = "zz" + model.NewId()
t1.Email = MakeEmail()
t1.Type = model.TEAM_OPEN
_, err := ss.Team().Save(&t1)

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

@@ -2370,7 +2370,7 @@ func testGetMaxPostSize(t *testing.T, ss store.Store) {
func testPostStoreGetParentsForExportAfter(t *testing.T, ss store.Store) {
t1 := model.Team{}
t1.DisplayName = "Name"
t1.Name = model.NewId()
t1.Name = "zz" + model.NewId()
t1.Email = MakeEmail()
t1.Type = model.TEAM_OPEN
_, err := ss.Team().Save(&t1)
@@ -2419,7 +2419,7 @@ func testPostStoreGetParentsForExportAfter(t *testing.T, ss store.Store) {
func testPostStoreGetRepliesForExport(t *testing.T, ss store.Store) {
t1 := model.Team{}
t1.DisplayName = "Name"
t1.Name = model.NewId()
t1.Name = "zz" + model.NewId()
t1.Email = MakeEmail()
t1.Type = model.TEAM_OPEN
_, err := ss.Team().Save(&t1)

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

@@ -107,7 +107,7 @@ func testGetAllFromTeam(t *testing.T, ss store.Store) {
team1 := model.Team{}
team1.DisplayName = model.NewId()
team1.Name = model.NewId()
team1.Name = "zz" + model.NewId()
team1.Email = MakeEmail()
team1.Type = model.TEAM_OPEN
@@ -117,7 +117,7 @@ func testGetAllFromTeam(t *testing.T, ss store.Store) {
team2 := model.Team{}
team2.DisplayName = model.NewId()
team2.Name = model.NewId()
team2.Name = "zz" + model.NewId()
team2.Email = MakeEmail()
team2.Type = model.TEAM_OPEN

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

@@ -1613,7 +1613,7 @@ func testTeamStoreAnalyticsGetTeamCountForScheme(t *testing.T, ss store.Store) {
func testTeamStoreGetAllForExportAfter(t *testing.T, ss store.Store) {
t1 := model.Team{}
t1.DisplayName = "Name"
t1.Name = model.NewId()
t1.Name = "zz" + model.NewId()
t1.Email = MakeEmail()
t1.Type = model.TEAM_OPEN
_, err := ss.Team().Save(&t1)
@@ -1637,7 +1637,7 @@ func testTeamStoreGetAllForExportAfter(t *testing.T, ss store.Store) {
func testTeamStoreGetTeamMembersForExport(t *testing.T, ss store.Store) {
t1 := model.Team{}
t1.DisplayName = "Name"
t1.Name = model.NewId()
t1.Name = "zz" + model.NewId()
t1.Email = MakeEmail()
t1.Type = model.TEAM_OPEN
_, err := ss.Team().Save(&t1)