Fix backup of Groups without an associated Team (#4520)
Previously we were trying to fetch channels of Groups without channels. --- #### Does this PR need a docs update or release note? - [x] ✅ Yes, it's included - [ ] 🕐 Yes, but in a later PR - [ ] ⛔ No #### Type of change <!--- Please check the type of change your PR introduces: ---> - [ ] 🌻 Feature - [x] 🐛 Bugfix - [ ] 🗺️ Documentation - [ ] 🤖 Supportability/Tests - [ ] 💻 CI/Deployment - [ ] 🧹 Tech Debt/Cleanup #### Issue(s) <!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. --> * closes https://github.com/alcionai/corso/issues/4519 #### Test Plan <!-- How will this be tested prior to merging.--> - [ ] 💪 Manual - [ ] ⚡ Unit test - [x] 💚 E2E
This commit is contained in:
parent
d10b1a306c
commit
08e8b18afc
@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Email size metadata was incorrectly set to the size of the last attachment. Emails will now correctly report the size of the mail content plus the size of all attachments.
|
- Email size metadata was incorrectly set to the size of the last attachment. Emails will now correctly report the size of the mail content plus the size of all attachments.
|
||||||
- Improves the filtering capabilities for Groups restore and backup
|
- Improves the filtering capabilities for Groups restore and backup
|
||||||
- Improve check to skip OneNote files that cannot be downloaded.
|
- Improve check to skip OneNote files that cannot be downloaded.
|
||||||
|
- Fix Groups backup for non Team groups
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Groups restore now expects the site whose backup we should restore
|
- Groups restore now expects the site whose backup we should restore
|
||||||
|
|||||||
@ -517,7 +517,7 @@ func (suite *BackupDeleteGroupsE2ESuite) SetupSuite() {
|
|||||||
|
|
||||||
suite.dpnd = prepM365Test(t, ctx, path.GroupsService)
|
suite.dpnd = prepM365Test(t, ctx, path.GroupsService)
|
||||||
|
|
||||||
m365GroupID := tconfig.M365GroupID(t)
|
m365GroupID := tconfig.M365TeamID(t)
|
||||||
groups := []string{m365GroupID}
|
groups := []string{m365GroupID}
|
||||||
|
|
||||||
// some tests require an existing backup
|
// some tests require an existing backup
|
||||||
|
|||||||
@ -511,7 +511,7 @@ func (suite *GroupsCollectionIntgSuite) TestCreateGroupsCollection_SharePoint()
|
|||||||
defer flush()
|
defer flush()
|
||||||
|
|
||||||
var (
|
var (
|
||||||
groupID = tconfig.M365GroupID(t)
|
groupID = tconfig.M365TeamID(t)
|
||||||
ctrl = newController(ctx, t, path.GroupsService)
|
ctrl = newController(ctx, t, path.GroupsService)
|
||||||
groupIDs = []string{groupID}
|
groupIDs = []string{groupID}
|
||||||
)
|
)
|
||||||
@ -585,7 +585,7 @@ func (suite *GroupsCollectionIntgSuite) TestCreateGroupsCollection_SharePoint_In
|
|||||||
defer flush()
|
defer flush()
|
||||||
|
|
||||||
var (
|
var (
|
||||||
groupID = tconfig.M365GroupID(t)
|
groupID = tconfig.M365TeamID(t)
|
||||||
ctrl = newController(ctx, t, path.GroupsService)
|
ctrl = newController(ctx, t, path.GroupsService)
|
||||||
groupIDs = []string{groupID}
|
groupIDs = []string{groupID}
|
||||||
)
|
)
|
||||||
|
|||||||
@ -470,7 +470,7 @@ func (suite *BackupIntgSuite) SetupSuite() {
|
|||||||
|
|
||||||
func (suite *BackupIntgSuite) TestCreateCollections() {
|
func (suite *BackupIntgSuite) TestCreateCollections() {
|
||||||
var (
|
var (
|
||||||
protectedResource = tconfig.M365GroupID(suite.T())
|
protectedResource = tconfig.M365TeamID(suite.T())
|
||||||
resources = []string{protectedResource}
|
resources = []string{protectedResource}
|
||||||
handler = NewChannelBackupHandler(protectedResource, suite.ac.Channels())
|
handler = NewChannelBackupHandler(protectedResource, suite.ac.Channels())
|
||||||
)
|
)
|
||||||
|
|||||||
@ -184,13 +184,13 @@ func ReadTestConfig() (map[string]string, error) {
|
|||||||
TestCfgGroupID,
|
TestCfgGroupID,
|
||||||
os.Getenv(EnvCorsoM365TestGroupID),
|
os.Getenv(EnvCorsoM365TestGroupID),
|
||||||
vpr.GetString(TestCfgGroupID),
|
vpr.GetString(TestCfgGroupID),
|
||||||
"6f24b40d-b13d-4752-980f-f5fb9fba7aa0")
|
"87d622a5-fb64-4fa4-a324-3dd620afe0bd") // CINonTeamGroup (create one without teams)
|
||||||
fallbackTo(
|
fallbackTo(
|
||||||
testEnv,
|
testEnv,
|
||||||
TestCfgSecondaryGroupID,
|
TestCfgSecondaryGroupID,
|
||||||
os.Getenv(EnvCorsoSecondaryM365TestGroupID),
|
os.Getenv(EnvCorsoSecondaryM365TestGroupID),
|
||||||
vpr.GetString(TestCfgSecondaryGroupID),
|
vpr.GetString(TestCfgSecondaryGroupID),
|
||||||
"20cda3c0-6f9a-4286-9f2f-bb284e1f79c9")
|
"cd260eff-834f-4cc3-b3bf-0aad1c9b8b7e") // CINonTeamGroup2 (create one without teams)
|
||||||
fallbackTo(
|
fallbackTo(
|
||||||
testEnv,
|
testEnv,
|
||||||
TestCfgSiteURL,
|
TestCfgSiteURL,
|
||||||
|
|||||||
@ -278,9 +278,10 @@ func SecondaryM365TeamID(t *testing.T) string {
|
|||||||
// by either the env var CORSO_M365_TEST_GROUP_ID, the corso_test.toml config
|
// by either the env var CORSO_M365_TEST_GROUP_ID, the corso_test.toml config
|
||||||
// file or the default value (in that order of priority). The default is a
|
// file or the default value (in that order of priority). The default is a
|
||||||
// last-attempt fallback that will only work on alcion's testing org.
|
// last-attempt fallback that will only work on alcion's testing org.
|
||||||
|
// NOTE: This Group will not have a Team associated with it.
|
||||||
func M365GroupID(t *testing.T) string {
|
func M365GroupID(t *testing.T) string {
|
||||||
cfg, err := ReadTestConfig()
|
cfg, err := ReadTestConfig()
|
||||||
require.NoError(t, err, "retrieving m365 group id from test configuration: %+v", clues.ToCore(err))
|
require.NoError(t, err, "retrieving m365 group id from test configuration: %+v", clues.ToCore(err))
|
||||||
|
|
||||||
return strings.ToLower(cfg[TestCfgTeamID])
|
return strings.ToLower(cfg[TestCfgGroupID])
|
||||||
}
|
}
|
||||||
|
|||||||
@ -182,6 +182,19 @@ func (c Groups) GetAllSites(
|
|||||||
|
|
||||||
sites := []models.Siteable{root}
|
sites := []models.Siteable{root}
|
||||||
|
|
||||||
|
group, err := c.Groups().GetByID(
|
||||||
|
ctx,
|
||||||
|
identifier,
|
||||||
|
CallConfig{})
|
||||||
|
if err != nil {
|
||||||
|
return nil, clues.Wrap(err, "getting group").WithClues(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
isTeam := IsTeam(ctx, group)
|
||||||
|
if !isTeam {
|
||||||
|
return sites, nil
|
||||||
|
}
|
||||||
|
|
||||||
channels, err := Channels(c).GetChannels(ctx, identifier)
|
channels, err := Channels(c).GetChannels(ctx, identifier)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, clues.Wrap(err, "getting channels")
|
return nil, clues.Wrap(err, "getting channels")
|
||||||
|
|||||||
@ -137,6 +137,24 @@ func (suite *GroupsIntgSuite) TestGetAllSites() {
|
|||||||
require.Equal(t, siteCount, len(sites), "incorrect number of sites")
|
require.Equal(t, siteCount, len(sites), "incorrect number of sites")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetAllSites for Groups that are not Teams should return just the root site
|
||||||
|
func (suite *GroupsIntgSuite) TestGetAllSitesNonTeam() {
|
||||||
|
t := suite.T()
|
||||||
|
|
||||||
|
ctx, flush := tester.NewContext(t)
|
||||||
|
defer flush()
|
||||||
|
|
||||||
|
group, err := suite.its.ac.Groups().GetByID(ctx, suite.its.nonTeamGroup.id, api.CallConfig{})
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.False(t, api.IsTeam(ctx, group), "group should not be a team for this test")
|
||||||
|
|
||||||
|
sites, err := suite.its.ac.
|
||||||
|
Groups().
|
||||||
|
GetAllSites(ctx, suite.its.nonTeamGroup.id, fault.New(true))
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, 1, len(sites), "incorrect number of sites")
|
||||||
|
}
|
||||||
|
|
||||||
func (suite *GroupsIntgSuite) TestGroups_GetByID() {
|
func (suite *GroupsIntgSuite) TestGroups_GetByID() {
|
||||||
t := suite.T()
|
t := suite.T()
|
||||||
|
|
||||||
|
|||||||
@ -83,11 +83,12 @@ type ids struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type intgTesterSetup struct {
|
type intgTesterSetup struct {
|
||||||
ac api.Client
|
ac api.Client
|
||||||
gockAC api.Client
|
gockAC api.Client
|
||||||
user ids
|
user ids
|
||||||
site ids
|
site ids
|
||||||
group ids
|
group ids
|
||||||
|
nonTeamGroup ids // group which does not have an associated team
|
||||||
}
|
}
|
||||||
|
|
||||||
func newIntegrationTesterSetup(t *testing.T) intgTesterSetup {
|
func newIntegrationTesterSetup(t *testing.T) intgTesterSetup {
|
||||||
@ -142,6 +143,8 @@ func newIntegrationTesterSetup(t *testing.T) intgTesterSetup {
|
|||||||
// the group has full usage of the teams api.
|
// the group has full usage of the teams api.
|
||||||
its.group.id = tconfig.M365TeamID(t)
|
its.group.id = tconfig.M365TeamID(t)
|
||||||
|
|
||||||
|
its.nonTeamGroup.id = tconfig.M365GroupID(t)
|
||||||
|
|
||||||
channel, err := its.ac.Channels().
|
channel, err := its.ac.Channels().
|
||||||
GetChannelByName(
|
GetChannelByName(
|
||||||
ctx,
|
ctx,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user