diff --git a/src/internal/operations/test/group_test.go b/src/internal/operations/test/group_test.go index fc3b1db1c..770267e68 100644 --- a/src/internal/operations/test/group_test.go +++ b/src/internal/operations/test/group_test.go @@ -37,7 +37,6 @@ func (suite *GroupsBackupIntgSuite) SetupSuite() { suite.its = newIntegrationTesterSetup(suite.T()) } -// TODO(v0,v1 restore): Library restore // TODO(v0 export): Channels export func (suite *GroupsBackupIntgSuite) TestBackup_Run_incrementalGroups() { @@ -194,3 +193,51 @@ func (suite *GroupsBackupIntgSuite) TestBackup_Run_groupsExtensions() { } } } + +type GroupsRestoreNightlyIntgSuite struct { + tester.Suite + its intgTesterSetup +} + +func TestGroupsRestoreIntgSuite(t *testing.T) { + suite.Run(t, &GroupsRestoreNightlyIntgSuite{ + Suite: tester.NewNightlySuite( + t, + [][]string{tconfig.M365AcctCredEnvs, storeTD.AWSStorageCredEnvs}), + }) +} + +func (suite *GroupsRestoreNightlyIntgSuite) SetupSuite() { + suite.its = newIntegrationTesterSetup(suite.T()) +} + +func (suite *GroupsRestoreNightlyIntgSuite) TestRestore_Run_groupsWithAdvancedOptions() { + sel := selectors.NewGroupsBackup([]string{suite.its.group.ID}) + sel.Include(selTD.GroupsBackupLibraryFolderScope(sel)) + sel.Filter(sel.Library("documents")) + sel.DiscreteOwner = suite.its.group.ID + + runDriveRestoreWithAdvancedOptions( + suite.T(), + suite, + suite.its.ac, + sel.Selector, + suite.its.group.RootSite.DriveID, + suite.its.group.RootSite.DriveRootFolderID) +} + +func (suite *GroupsRestoreNightlyIntgSuite) TestRestore_Run_groupsAlternateProtectedResource() { + sel := selectors.NewGroupsBackup([]string{suite.its.group.ID}) + sel.Include(selTD.GroupsBackupLibraryFolderScope(sel)) + sel.Filter(sel.Library("documents")) + sel.DiscreteOwner = suite.its.group.ID + + runDriveRestoreToAlternateProtectedResource( + suite.T(), + suite, + suite.its.ac, + sel.Selector, + suite.its.group.RootSite, + suite.its.secondaryGroup.RootSite, + suite.its.secondaryGroup.ID) +} diff --git a/src/internal/operations/test/helper_test.go b/src/internal/operations/test/helper_test.go index 421420a2d..3cc10199a 100644 --- a/src/internal/operations/test/helper_test.go +++ b/src/internal/operations/test/helper_test.go @@ -580,13 +580,14 @@ type gids struct { } type intgTesterSetup struct { - ac api.Client - gockAC api.Client - user ids - secondaryUser ids - site ids - secondarySite ids - group gids + ac api.Client + gockAC api.Client + user ids + secondaryUser ids + site ids + secondarySite ids + group gids + secondaryGroup gids } func newIntegrationTesterSetup(t *testing.T) intgTesterSetup { @@ -614,6 +615,7 @@ func newIntegrationTesterSetup(t *testing.T) intgTesterSetup { // teamID is used here intentionally. We want the group // to have access to teams data its.group = groupIDs(t, tconfig.M365TeamID(t), its.ac) + its.secondaryGroup = groupIDs(t, tconfig.SecondaryM365TeamID(t), its.ac) return its } diff --git a/src/internal/operations/test/onedrive_test.go b/src/internal/operations/test/onedrive_test.go index 384000d19..8b4ac9b81 100644 --- a/src/internal/operations/test/onedrive_test.go +++ b/src/internal/operations/test/onedrive_test.go @@ -1284,7 +1284,8 @@ func (suite *OneDriveRestoreNightlyIntgSuite) TestRestore_Run_onedriveAlternateP suite.its.ac, sel.Selector, suite.its.user, - suite.its.secondaryUser) + suite.its.secondaryUser, + suite.its.secondaryUser.ID) } func runDriveRestoreToAlternateProtectedResource( @@ -1292,7 +1293,8 @@ func runDriveRestoreToAlternateProtectedResource( suite tester.Suite, ac api.Client, sel selectors.Selector, // owner should match 'from', both Restore and Backup types work. - from, to ids, + driveFrom, driveTo ids, + toResource string, ) { ctx, flush := tester.NewContext(t) defer flush() @@ -1321,8 +1323,8 @@ func runDriveRestoreToAlternateProtectedResource( suite.Run("restore original resource", func() { mb = evmock.NewBus() fromCtr := count.New() - driveID := from.DriveID - rootFolderID := from.DriveRootFolderID + driveID := driveFrom.DriveID + rootFolderID := driveFrom.DriveRootFolderID restoreCfg.OnCollision = control.Copy ro, _ := prepNewTestRestoreOp( @@ -1359,9 +1361,9 @@ func runDriveRestoreToAlternateProtectedResource( suite.Run("restore to alternate resource", func() { mb = evmock.NewBus() toCtr := count.New() - driveID := to.DriveID - rootFolderID := to.DriveRootFolderID - restoreCfg.ProtectedResource = to.ID + driveID := driveTo.DriveID + rootFolderID := driveTo.DriveRootFolderID + restoreCfg.ProtectedResource = toResource ro, _ := prepNewTestRestoreOp( t, diff --git a/src/internal/operations/test/sharepoint_test.go b/src/internal/operations/test/sharepoint_test.go index aa1558d07..ec1cb940c 100644 --- a/src/internal/operations/test/sharepoint_test.go +++ b/src/internal/operations/test/sharepoint_test.go @@ -225,7 +225,8 @@ func (suite *SharePointRestoreNightlyIntgSuite) TestRestore_Run_sharepointAltern suite.its.ac, sel.Selector, suite.its.site, - suite.its.secondarySite) + suite.its.secondarySite, + suite.its.secondarySite.ID) } func (suite *SharePointRestoreNightlyIntgSuite) TestRestore_Run_sharepointDeletedDrives() { diff --git a/src/internal/tester/tconfig/config.go b/src/internal/tester/tconfig/config.go index d92918dbb..e122c0ef4 100644 --- a/src/internal/tester/tconfig/config.go +++ b/src/internal/tester/tconfig/config.go @@ -31,6 +31,7 @@ const ( TestCfgUserID = "m365userid" TestCfgSecondaryUserID = "secondarym365userid" TestCfgSecondaryGroupID = "secondarym365groupid" + TestCfgSecondaryTeamID = "secondarym365teamid" TestCfgTertiaryUserID = "tertiarym365userid" TestCfgLoadTestUserID = "loadtestm365userid" TestCfgLoadTestOrgUsers = "loadtestm365orgusers" @@ -45,7 +46,9 @@ const ( EnvCorsoM365TestSiteID = "CORSO_M365_TEST_SITE_ID" EnvCorsoM365TestSiteURL = "CORSO_M365_TEST_SITE_URL" EnvCorsoM365TestTeamID = "CORSO_M365_TEST_TEAM_ID" + EnvCorsoSecondaryM365TestTeamID = "CORSO_SECONDARY_M365_TEST_TEAM_ID" EnvCorsoM365TestGroupID = "CORSO_M365_TEST_GROUP_ID" + EnvCorsoSecondaryM365TestGroupID = "CORSO_SECONDARY_M365_TEST_GROUP_ID" EnvCorsoM365TestUserID = "CORSO_M365_TEST_USER_ID" EnvCorsoSecondaryM365TestSiteID = "CORSO_SECONDARY_M365_TEST_SITE_ID" EnvCorsoSecondaryM365TestUserID = "CORSO_SECONDARY_M365_TEST_USER_ID" @@ -161,12 +164,24 @@ func ReadTestConfig() (map[string]string, error) { os.Getenv(EnvCorsoM365TestTeamID), vpr.GetString(TestCfgTeamID), "6f24b40d-b13d-4752-980f-f5fb9fba7aa0") + fallbackTo( + testEnv, + TestCfgSecondaryTeamID, + os.Getenv(EnvCorsoSecondaryM365TestTeamID), + vpr.GetString(TestCfgSecondaryTeamID), + "20cda3c0-6f9a-4286-9f2f-bb284e1f79c9") fallbackTo( testEnv, TestCfgGroupID, os.Getenv(EnvCorsoM365TestGroupID), vpr.GetString(TestCfgGroupID), "6f24b40d-b13d-4752-980f-f5fb9fba7aa0") + fallbackTo( + testEnv, + TestCfgSecondaryGroupID, + os.Getenv(EnvCorsoSecondaryM365TestGroupID), + vpr.GetString(TestCfgSecondaryGroupID), + "20cda3c0-6f9a-4286-9f2f-bb284e1f79c9") fallbackTo( testEnv, TestCfgSiteURL, diff --git a/src/internal/tester/tconfig/protected_resources.go b/src/internal/tester/tconfig/protected_resources.go index 26c0187ac..2a03ad00a 100644 --- a/src/internal/tester/tconfig/protected_resources.go +++ b/src/internal/tester/tconfig/protected_resources.go @@ -234,6 +234,17 @@ func M365TeamID(t *testing.T) string { return strings.ToLower(cfg[TestCfgTeamID]) } +// SecondaryM365TeamID returns a teamID string representing the secondarym365TeamID described +// by either the env var CORSO_SECONDARY_M365_TEST_TEAM_ID, the corso_test.toml config +// 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. +func SecondaryM365TeamID(t *testing.T) string { + cfg, err := ReadTestConfig() + require.NoError(t, err, "retrieving secondary m365 team id from test configuration: %+v", clues.ToCore(err)) + + return strings.ToLower(cfg[TestCfgSecondaryTeamID]) +} + // Groups // M365GroupID returns a groupID string representing the m365GroupID described