diff --git a/.github/workflows/sanity-test.yaml b/.github/workflows/sanity-test.yaml index 5443320d8..e722d0632 100644 --- a/.github/workflows/sanity-test.yaml +++ b/.github/workflows/sanity-test.yaml @@ -385,8 +385,8 @@ jobs: with: service: groups kind: incremental - backup-args: '--site "${{ vars.CORSO_M365_TEST_GROUPS_SITE_URL }}"' - restore-args: '--folder ${{ env.RESTORE_DEST_PFX }}${{ steps.new-data-creation-groups.outputs.result }}' + backup-args: '--group "${{ vars.CORSO_M365_TEST_TEAM_ID }}"' + restore-args: '--site "${{ vars.CORSO_M365_TEST_GROUPS_SITE_URL }}" --folder ${{ env.RESTORE_DEST_PFX }}${{ steps.new-data-creation-groups.outputs.result }}' restore-container: '${{ env.RESTORE_DEST_PFX }}${{ steps.new-data-creation-groups.outputs.result }}' log-dir: ${{ env.CORSO_LOG_DIR }} with-export: true diff --git a/src/cmd/sanity_test/common/common.go b/src/cmd/sanity_test/common/common.go index 149a6f97e..ec505dbd7 100644 --- a/src/cmd/sanity_test/common/common.go +++ b/src/cmd/sanity_test/common/common.go @@ -31,6 +31,7 @@ type Envs struct { GroupID string SiteID string UserID string + TeamSiteID string } func EnvVars(ctx context.Context) Envs { @@ -43,6 +44,7 @@ func EnvVars(ctx context.Context) Envs { GroupID: tconfig.GetM365TeamID(ctx), SiteID: tconfig.GetM365SiteID(ctx), UserID: tconfig.GetM365UserID(ctx), + TeamSiteID: tconfig.GetM365TeamSiteID(ctx), } if len(os.Getenv(sanityTestUser)) > 0 { diff --git a/src/cmd/sanity_test/export/groups.go b/src/cmd/sanity_test/export/groups.go index 3afef0d6b..1d288c32a 100644 --- a/src/cmd/sanity_test/export/groups.go +++ b/src/cmd/sanity_test/export/groups.go @@ -21,7 +21,7 @@ func CheckGroupsExport( // assumes we only need to sanity check the default site. // should we expand this to check all sites in the group? // are we backing up / restoring more than the default site? - drive, err := ac.Sites().GetDefaultDrive(ctx, envs.SiteID) + drive, err := ac.Sites().GetDefaultDrive(ctx, envs.TeamSiteID) if err != nil { common.Fatal(ctx, "getting the drive:", err) } diff --git a/src/cmd/sanity_test/restore/groups.go b/src/cmd/sanity_test/restore/groups.go index 2501672c2..95d91cee7 100644 --- a/src/cmd/sanity_test/restore/groups.go +++ b/src/cmd/sanity_test/restore/groups.go @@ -15,7 +15,7 @@ func CheckGroupsRestoration( ac api.Client, envs common.Envs, ) { - drive, err := ac.Sites().GetDefaultDrive(ctx, envs.SiteID) + drive, err := ac.Sites().GetDefaultDrive(ctx, envs.TeamSiteID) if err != nil { common.Fatal(ctx, "getting site's default drive:", err) } diff --git a/src/internal/tester/tconfig/config.go b/src/internal/tester/tconfig/config.go index 88dc40365..623dc1282 100644 --- a/src/internal/tester/tconfig/config.go +++ b/src/internal/tester/tconfig/config.go @@ -28,6 +28,7 @@ const ( TestCfgSiteID = "m365siteid" TestCfgSiteURL = "m365siteurl" TestCfgTeamID = "m365teamid" + TestCfgTeamSiteID = "m365teamsiteid" TestCfgGroupID = "m365groupid" TestCfgUserID = "m365userid" TestCfgSecondaryUserID = "secondarym365userid" @@ -47,6 +48,7 @@ const ( EnvCorsoM365TestSiteID = "CORSO_M365_TEST_SITE_ID" EnvCorsoM365TestSiteURL = "CORSO_M365_TEST_SITE_URL" EnvCorsoM365TestTeamID = "CORSO_M365_TEST_TEAM_ID" + EnvCorsoM365TestTeamSiteID = "CORSO_M365_TEST_TEAM_SITE_ID" EnvCorsoSecondaryM365TestTeamID = "CORSO_SECONDARY_M365_TEST_TEAM_ID" EnvCorsoM365TestGroupID = "CORSO_M365_TEST_GROUP_ID" EnvCorsoSecondaryM365TestGroupID = "CORSO_SECONDARY_M365_TEST_GROUP_ID" @@ -165,6 +167,12 @@ func ReadTestConfig() (map[string]string, error) { os.Getenv(EnvCorsoM365TestTeamID), vpr.GetString(TestCfgTeamID), "6f24b40d-b13d-4752-980f-f5fb9fba7aa0") + fallbackTo( + testEnv, + TestCfgTeamSiteID, + os.Getenv(EnvCorsoM365TestTeamSiteID), + vpr.GetString(TestCfgTeamSiteID), + "8df7082a-62eb-4165-97f9-ead8cf04c0d8,11810f05-e8bd-45e2-9728-92e434260750") fallbackTo( testEnv, TestCfgSecondaryTeamID, diff --git a/src/internal/tester/tconfig/protected_resources.go b/src/internal/tester/tconfig/protected_resources.go index 640339158..2bf68a159 100644 --- a/src/internal/tester/tconfig/protected_resources.go +++ b/src/internal/tester/tconfig/protected_resources.go @@ -222,6 +222,20 @@ func GetM365TeamID(ctx context.Context) string { return strings.ToLower(cfg[TestCfgTeamID]) } +// GetM365TeamSiteID returns a site ID string representing the m365TeamSiteID +// described by either the env var CORSO_M365_TEST_TEAM_SITE_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 GetM365TeamSiteID(ctx context.Context) string { + cfg, err := ReadTestConfig() + if err != nil { + logger.Ctx(ctx).Error(err, "retrieving m365 team id from test configuration") + } + + return strings.ToLower(cfg[TestCfgTeamSiteID]) +} + // UnlicensedM365UserID returns an userID string representing the m365UserID // described by either the env var CORSO_M365_TEST_UNLICENSED_USER, the // corso_test.toml config file or the default value (in that order of priority).