From 1fa505c8334adf3729ead29b9ed9198fe2626256 Mon Sep 17 00:00:00 2001 From: Jesse Hallam Date: Fri, 26 Jul 2019 20:41:20 -0300 Subject: [PATCH] MM-17053: avoid colliding with reserved team names (#11705) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- store/storetest/channel_store.go | 18 +++++++++--------- store/storetest/post_store.go | 4 ++-- store/storetest/status_store.go | 4 ++-- store/storetest/team_store.go | 4 ++-- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/store/storetest/channel_store.go b/store/storetest/channel_store.go index 7d3d88ff30..f7761026ae 100644 --- a/store/storetest/channel_store.go +++ b/store/storetest/channel_store.go @@ -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) diff --git a/store/storetest/post_store.go b/store/storetest/post_store.go index 09ee9248ef..960bcd02bb 100644 --- a/store/storetest/post_store.go +++ b/store/storetest/post_store.go @@ -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) diff --git a/store/storetest/status_store.go b/store/storetest/status_store.go index 77df051642..609da5b7c9 100644 --- a/store/storetest/status_store.go +++ b/store/storetest/status_store.go @@ -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 diff --git a/store/storetest/team_store.go b/store/storetest/team_store.go index b2558d7f46..8406b69ea6 100644 --- a/store/storetest/team_store.go +++ b/store/storetest/team_store.go @@ -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)