introduce intg and unit test setup packages (#5140)
corso has a thousand bespoke approaches to setting the same info in all of its tests. This is a first step towards minimizing and standardizing the lift around that work. Future PRs will distribute these packages through the repo. --- #### Does this PR need a docs update or release note? - [x] ⛔ No #### Type of change - [x] 🤖 Supportability/Tests - [x] 🧹 Tech Debt/Cleanup #### Test Plan - [x] ⚡ Unit test - [x] 💚 E2E
This commit is contained in:
parent
a2d40b4d38
commit
f00dd0f88a
@ -18,6 +18,7 @@ import (
|
||||
"github.com/alcionai/corso/src/internal/common/idname"
|
||||
"github.com/alcionai/corso/src/internal/operations"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/internal/tester/its"
|
||||
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
||||
"github.com/alcionai/corso/src/pkg/config"
|
||||
"github.com/alcionai/corso/src/pkg/path"
|
||||
@ -39,7 +40,7 @@ var (
|
||||
type NoBackupExchangeE2ESuite struct {
|
||||
tester.Suite
|
||||
dpnd dependencies
|
||||
its intgTesterSetup
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestNoBackupExchangeE2ESuite(t *testing.T) {
|
||||
@ -54,7 +55,7 @@ func (suite *NoBackupExchangeE2ESuite) SetupSuite() {
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
suite.its = newIntegrationTesterSetup(t)
|
||||
suite.m365 = its.GetM365(t)
|
||||
suite.dpnd = prepM365Test(t, ctx, path.ExchangeService)
|
||||
}
|
||||
|
||||
@ -93,7 +94,7 @@ func (suite *NoBackupExchangeE2ESuite) TestExchangeBackupListCmd_noBackups() {
|
||||
type BackupExchangeE2ESuite struct {
|
||||
tester.Suite
|
||||
dpnd dependencies
|
||||
its intgTesterSetup
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestBackupExchangeE2ESuite(t *testing.T) {
|
||||
@ -108,7 +109,7 @@ func (suite *BackupExchangeE2ESuite) SetupSuite() {
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
suite.its = newIntegrationTesterSetup(t)
|
||||
suite.m365 = its.GetM365(t)
|
||||
suite.dpnd = prepM365Test(t, ctx, path.ExchangeService)
|
||||
}
|
||||
|
||||
@ -138,7 +139,7 @@ func runExchangeBackupCategoryTest(suite *BackupExchangeE2ESuite, category path.
|
||||
cmd, ctx := buildExchangeBackupCmd(
|
||||
ctx,
|
||||
suite.dpnd.configFilePath,
|
||||
suite.its.user.ID,
|
||||
suite.m365.User.ID,
|
||||
category.String(),
|
||||
&recorder)
|
||||
|
||||
@ -150,7 +151,7 @@ func runExchangeBackupCategoryTest(suite *BackupExchangeE2ESuite, category path.
|
||||
t.Log("backup results", result)
|
||||
|
||||
// as an offhand check: the result should contain the m365 user id
|
||||
assert.Contains(t, result, suite.its.user.ID)
|
||||
assert.Contains(t, result, suite.m365.User.ID)
|
||||
}
|
||||
|
||||
func (suite *BackupExchangeE2ESuite) TestExchangeBackupCmd_ServiceNotEnabled_email() {
|
||||
@ -173,7 +174,7 @@ func runExchangeBackupServiceNotEnabledTest(suite *BackupExchangeE2ESuite, categ
|
||||
cmd, ctx := buildExchangeBackupCmd(
|
||||
ctx,
|
||||
suite.dpnd.configFilePath,
|
||||
fmt.Sprintf("%s,%s", tconfig.UnlicensedM365UserID(suite.T()), suite.its.user.ID),
|
||||
fmt.Sprintf("%s,%s", tconfig.UnlicensedM365UserID(suite.T()), suite.m365.User.ID),
|
||||
category.String(),
|
||||
&recorder)
|
||||
err := cmd.ExecuteContext(ctx)
|
||||
@ -183,7 +184,7 @@ func runExchangeBackupServiceNotEnabledTest(suite *BackupExchangeE2ESuite, categ
|
||||
t.Log("backup results", result)
|
||||
|
||||
// as an offhand check: the result should contain the m365 user id
|
||||
assert.Contains(t, result, suite.its.user.ID)
|
||||
assert.Contains(t, result, suite.m365.User.ID)
|
||||
}
|
||||
|
||||
func (suite *BackupExchangeE2ESuite) TestExchangeBackupCmd_userNotFound_email() {
|
||||
@ -242,7 +243,7 @@ func (suite *BackupExchangeE2ESuite) TestBackupCreateExchange_badAzureClientIDFl
|
||||
|
||||
cmd := cliTD.StubRootCmd(
|
||||
"backup", "create", "exchange",
|
||||
"--user", suite.its.user.ID,
|
||||
"--user", suite.m365.User.ID,
|
||||
"--azure-client-id", "invalid-value")
|
||||
cli.BuildCommandTree(cmd)
|
||||
|
||||
@ -266,7 +267,7 @@ func (suite *BackupExchangeE2ESuite) TestBackupCreateExchange_fromConfigFile() {
|
||||
|
||||
cmd := cliTD.StubRootCmd(
|
||||
"backup", "create", "exchange",
|
||||
"--user", suite.its.user.ID,
|
||||
"--user", suite.m365.User.ID,
|
||||
"--"+flags.ConfigFileFN, suite.dpnd.configFilePath)
|
||||
cli.BuildCommandTree(cmd)
|
||||
|
||||
@ -282,7 +283,7 @@ func (suite *BackupExchangeE2ESuite) TestBackupCreateExchange_fromConfigFile() {
|
||||
t.Log("backup results", result)
|
||||
|
||||
// as an offhand check: the result should contain the m365 user id
|
||||
assert.Contains(t, result, suite.its.user.ID)
|
||||
assert.Contains(t, result, suite.m365.User.ID)
|
||||
}
|
||||
|
||||
// AWS flags
|
||||
@ -296,7 +297,7 @@ func (suite *BackupExchangeE2ESuite) TestBackupCreateExchange_badAWSFlags() {
|
||||
|
||||
cmd := cliTD.StubRootCmd(
|
||||
"backup", "create", "exchange",
|
||||
"--user", suite.its.user.ID,
|
||||
"--user", suite.m365.User.ID,
|
||||
"--aws-access-key", "invalid-value",
|
||||
"--aws-secret-access-key", "some-invalid-value")
|
||||
cli.BuildCommandTree(cmd)
|
||||
@ -319,7 +320,7 @@ type PreparedBackupExchangeE2ESuite struct {
|
||||
tester.Suite
|
||||
dpnd dependencies
|
||||
backupOps map[path.CategoryType]string
|
||||
its intgTesterSetup
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestPreparedBackupExchangeE2ESuite(t *testing.T) {
|
||||
@ -336,13 +337,13 @@ func (suite *PreparedBackupExchangeE2ESuite) SetupSuite() {
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
suite.its = newIntegrationTesterSetup(t)
|
||||
suite.m365 = its.GetM365(t)
|
||||
suite.dpnd = prepM365Test(t, ctx, path.ExchangeService)
|
||||
suite.backupOps = make(map[path.CategoryType]string)
|
||||
|
||||
var (
|
||||
users = []string{suite.its.user.ID}
|
||||
ins = idname.NewCache(map[string]string{suite.its.user.ID: suite.its.user.ID})
|
||||
users = []string{suite.m365.User.ID}
|
||||
ins = idname.NewCache(map[string]string{suite.m365.User.ID: suite.m365.User.ID})
|
||||
)
|
||||
|
||||
for _, set := range []path.CategoryType{email, contacts, events} {
|
||||
|
||||
@ -20,6 +20,7 @@ import (
|
||||
"github.com/alcionai/corso/src/internal/common/idname"
|
||||
"github.com/alcionai/corso/src/internal/operations"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/internal/tester/its"
|
||||
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
||||
"github.com/alcionai/corso/src/pkg/config"
|
||||
"github.com/alcionai/corso/src/pkg/path"
|
||||
@ -35,7 +36,7 @@ import (
|
||||
type NoBackupGroupsE2ESuite struct {
|
||||
tester.Suite
|
||||
dpnd dependencies
|
||||
its intgTesterSetup
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestNoBackupGroupsE2ESuite(t *testing.T) {
|
||||
@ -50,7 +51,7 @@ func (suite *NoBackupGroupsE2ESuite) SetupSuite() {
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
suite.its = newIntegrationTesterSetup(t)
|
||||
suite.m365 = its.GetM365(t)
|
||||
suite.dpnd = prepM365Test(t, ctx, path.GroupsService)
|
||||
}
|
||||
|
||||
@ -89,7 +90,7 @@ func (suite *NoBackupGroupsE2ESuite) TestGroupsBackupListCmd_noBackups() {
|
||||
type BackupGroupsE2ESuite struct {
|
||||
tester.Suite
|
||||
dpnd dependencies
|
||||
its intgTesterSetup
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestBackupGroupsE2ESuite(t *testing.T) {
|
||||
@ -104,7 +105,7 @@ func (suite *BackupGroupsE2ESuite) SetupSuite() {
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
suite.its = newIntegrationTesterSetup(t)
|
||||
suite.m365 = its.GetM365(t)
|
||||
suite.dpnd = prepM365Test(t, ctx, path.GroupsService)
|
||||
}
|
||||
|
||||
@ -134,7 +135,7 @@ func runGroupsBackupCategoryTest(suite *BackupGroupsE2ESuite, category string) {
|
||||
cmd, ctx := buildGroupsBackupCmd(
|
||||
ctx,
|
||||
suite.dpnd.configFilePath,
|
||||
suite.its.group.ID,
|
||||
suite.m365.Group.ID,
|
||||
category,
|
||||
&recorder)
|
||||
|
||||
@ -202,7 +203,7 @@ func (suite *BackupGroupsE2ESuite) TestBackupCreateGroups_badAzureClientIDFlag()
|
||||
|
||||
cmd := cliTD.StubRootCmd(
|
||||
"backup", "create", "groups",
|
||||
"--group", suite.its.group.ID,
|
||||
"--group", suite.m365.Group.ID,
|
||||
"--azure-client-id", "invalid-value")
|
||||
cli.BuildCommandTree(cmd)
|
||||
|
||||
@ -226,7 +227,7 @@ func (suite *BackupGroupsE2ESuite) TestBackupCreateGroups_fromConfigFile() {
|
||||
|
||||
cmd := cliTD.StubRootCmd(
|
||||
"backup", "create", "groups",
|
||||
"--group", suite.its.group.ID,
|
||||
"--group", suite.m365.Group.ID,
|
||||
"--"+flags.ConfigFileFN, suite.dpnd.configFilePath)
|
||||
cli.BuildCommandTree(cmd)
|
||||
|
||||
@ -250,7 +251,7 @@ func (suite *BackupGroupsE2ESuite) TestBackupCreateGroups_badAWSFlags() {
|
||||
|
||||
cmd := cliTD.StubRootCmd(
|
||||
"backup", "create", "groups",
|
||||
"--group", suite.its.group.ID,
|
||||
"--group", suite.m365.Group.ID,
|
||||
"--aws-access-key", "invalid-value",
|
||||
"--aws-secret-access-key", "some-invalid-value")
|
||||
cli.BuildCommandTree(cmd)
|
||||
@ -273,7 +274,7 @@ type PreparedBackupGroupsE2ESuite struct {
|
||||
tester.Suite
|
||||
dpnd dependencies
|
||||
backupOps map[path.CategoryType]string
|
||||
its intgTesterSetup
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestPreparedBackupGroupsE2ESuite(t *testing.T) {
|
||||
@ -290,13 +291,13 @@ func (suite *PreparedBackupGroupsE2ESuite) SetupSuite() {
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
suite.its = newIntegrationTesterSetup(t)
|
||||
suite.m365 = its.GetM365(t)
|
||||
suite.dpnd = prepM365Test(t, ctx, path.GroupsService)
|
||||
suite.backupOps = make(map[path.CategoryType]string)
|
||||
|
||||
var (
|
||||
groups = []string{suite.its.group.ID}
|
||||
ins = idname.NewCache(map[string]string{suite.its.group.ID: suite.its.group.ID})
|
||||
groups = []string{suite.m365.Group.ID}
|
||||
ins = idname.NewCache(map[string]string{suite.m365.Group.ID: suite.m365.Group.ID})
|
||||
cats = []path.CategoryType{
|
||||
path.ChannelMessagesCategory,
|
||||
path.ConversationPostsCategory,
|
||||
|
||||
@ -14,141 +14,16 @@ import (
|
||||
"github.com/alcionai/corso/src/cli/flags"
|
||||
"github.com/alcionai/corso/src/cli/print"
|
||||
cliTD "github.com/alcionai/corso/src/cli/testdata"
|
||||
"github.com/alcionai/corso/src/internal/common/ptr"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
||||
"github.com/alcionai/corso/src/pkg/account"
|
||||
"github.com/alcionai/corso/src/pkg/config"
|
||||
"github.com/alcionai/corso/src/pkg/control"
|
||||
"github.com/alcionai/corso/src/pkg/count"
|
||||
"github.com/alcionai/corso/src/pkg/path"
|
||||
"github.com/alcionai/corso/src/pkg/repository"
|
||||
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
||||
"github.com/alcionai/corso/src/pkg/services/m365/api/graph"
|
||||
"github.com/alcionai/corso/src/pkg/storage"
|
||||
"github.com/alcionai/corso/src/pkg/storage/testdata"
|
||||
)
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Gockable client
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// GockClient produces a new exchange api client that can be
|
||||
// mocked using gock.
|
||||
func gockClient(creds account.M365Config, counter *count.Bus) (api.Client, error) {
|
||||
s, err := graph.NewGockService(creds, counter)
|
||||
if err != nil {
|
||||
return api.Client{}, err
|
||||
}
|
||||
|
||||
li, err := graph.NewGockService(creds, counter, graph.NoTimeout())
|
||||
if err != nil {
|
||||
return api.Client{}, err
|
||||
}
|
||||
|
||||
return api.Client{
|
||||
Credentials: creds,
|
||||
Stable: s,
|
||||
LargeItem: li,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Suite Setup
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
type ids struct {
|
||||
ID string
|
||||
DriveID string
|
||||
DriveRootFolderID string
|
||||
}
|
||||
|
||||
type intgTesterSetup struct {
|
||||
acct account.Account
|
||||
ac api.Client
|
||||
gockAC api.Client
|
||||
user ids
|
||||
site ids
|
||||
group ids
|
||||
team ids
|
||||
}
|
||||
|
||||
func newIntegrationTesterSetup(t *testing.T) intgTesterSetup {
|
||||
its := intgTesterSetup{}
|
||||
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
graph.InitializeConcurrencyLimiter(ctx, true, 4)
|
||||
|
||||
its.acct = tconfig.NewM365Account(t)
|
||||
creds, err := its.acct.M365Config()
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
its.ac, err = api.NewClient(
|
||||
creds,
|
||||
control.DefaultOptions(),
|
||||
count.New())
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
its.gockAC, err = gockClient(creds, count.New())
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
// user drive
|
||||
|
||||
uids := ids{}
|
||||
|
||||
uids.ID = tconfig.M365UserID(t)
|
||||
|
||||
userDrive, err := its.ac.Users().GetDefaultDrive(ctx, uids.ID)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
uids.DriveID = ptr.Val(userDrive.GetId())
|
||||
|
||||
userDriveRootFolder, err := its.ac.Drives().GetRootFolder(ctx, uids.DriveID)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
uids.DriveRootFolderID = ptr.Val(userDriveRootFolder.GetId())
|
||||
|
||||
its.user = uids
|
||||
|
||||
// site
|
||||
|
||||
sids := ids{}
|
||||
|
||||
sids.ID = tconfig.M365SiteID(t)
|
||||
|
||||
siteDrive, err := its.ac.Sites().GetDefaultDrive(ctx, sids.ID)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
sids.DriveID = ptr.Val(siteDrive.GetId())
|
||||
|
||||
siteDriveRootFolder, err := its.ac.Drives().GetRootFolder(ctx, sids.DriveID)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
sids.DriveRootFolderID = ptr.Val(siteDriveRootFolder.GetId())
|
||||
|
||||
its.site = sids
|
||||
|
||||
// group
|
||||
|
||||
gids := ids{}
|
||||
|
||||
// use of the TeamID is intentional here, so that we are assured
|
||||
// the group has full usage of the teams api.
|
||||
gids.ID = tconfig.M365TeamID(t)
|
||||
|
||||
its.group = gids
|
||||
|
||||
// team
|
||||
|
||||
tids := ids{}
|
||||
tids.ID = tconfig.M365TeamID(t)
|
||||
its.team = tids
|
||||
|
||||
return its
|
||||
}
|
||||
|
||||
type dependencies struct {
|
||||
st storage.Storage
|
||||
repo repository.Repositoryer
|
||||
|
||||
@ -20,6 +20,7 @@ import (
|
||||
"github.com/alcionai/corso/src/internal/common/idname"
|
||||
"github.com/alcionai/corso/src/internal/operations"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/internal/tester/its"
|
||||
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
||||
"github.com/alcionai/corso/src/pkg/backup/details"
|
||||
"github.com/alcionai/corso/src/pkg/config"
|
||||
@ -89,7 +90,7 @@ func (suite *NoBackupSharePointE2ESuite) TestSharePointBackupListCmd_empty() {
|
||||
type BackupSharepointE2ESuite struct {
|
||||
tester.Suite
|
||||
dpnd dependencies
|
||||
its intgTesterSetup
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestBackupSharepointE2ESuite(t *testing.T) {
|
||||
@ -104,7 +105,7 @@ func (suite *BackupSharepointE2ESuite) SetupSuite() {
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
suite.its = newIntegrationTesterSetup(t)
|
||||
suite.m365 = its.GetM365(t)
|
||||
suite.dpnd = prepM365Test(t, ctx, path.SharePointService)
|
||||
}
|
||||
|
||||
@ -128,7 +129,7 @@ func runSharepointBackupCategoryTest(suite *BackupSharepointE2ESuite, category s
|
||||
cmd, ctx := buildSharepointBackupCmd(
|
||||
ctx,
|
||||
suite.dpnd.configFilePath,
|
||||
suite.its.site.ID,
|
||||
suite.m365.Site.ID,
|
||||
category,
|
||||
&recorder)
|
||||
|
||||
@ -187,7 +188,7 @@ type PreparedBackupSharepointE2ESuite struct {
|
||||
tester.Suite
|
||||
dpnd dependencies
|
||||
backupOps map[path.CategoryType]string
|
||||
its intgTesterSetup
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestPreparedBackupSharepointE2ESuite(t *testing.T) {
|
||||
@ -204,13 +205,13 @@ func (suite *PreparedBackupSharepointE2ESuite) SetupSuite() {
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
suite.its = newIntegrationTesterSetup(t)
|
||||
suite.m365 = its.GetM365(t)
|
||||
suite.dpnd = prepM365Test(t, ctx, path.SharePointService)
|
||||
suite.backupOps = make(map[path.CategoryType]string)
|
||||
|
||||
var (
|
||||
sites = []string{suite.its.site.ID}
|
||||
ins = idname.NewCache(map[string]string{suite.its.site.ID: suite.its.site.ID})
|
||||
sites = []string{suite.m365.Site.ID}
|
||||
ins = idname.NewCache(map[string]string{suite.m365.Site.ID: suite.m365.Site.ID})
|
||||
cats = []path.CategoryType{
|
||||
path.ListsCategory,
|
||||
}
|
||||
|
||||
@ -20,6 +20,7 @@ import (
|
||||
"github.com/alcionai/corso/src/internal/common/idname"
|
||||
"github.com/alcionai/corso/src/internal/operations"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/internal/tester/its"
|
||||
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
||||
"github.com/alcionai/corso/src/pkg/config"
|
||||
"github.com/alcionai/corso/src/pkg/path"
|
||||
@ -35,7 +36,7 @@ import (
|
||||
type NoBackupTeamsChatsE2ESuite struct {
|
||||
tester.Suite
|
||||
dpnd dependencies
|
||||
its intgTesterSetup
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestNoBackupTeamsChatsE2ESuite(t *testing.T) {
|
||||
@ -51,7 +52,7 @@ func (suite *NoBackupTeamsChatsE2ESuite) SetupSuite() {
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
suite.its = newIntegrationTesterSetup(t)
|
||||
suite.m365 = its.GetM365(t)
|
||||
suite.dpnd = prepM365Test(t, ctx, path.TeamsChatsService)
|
||||
}
|
||||
|
||||
@ -90,7 +91,7 @@ func (suite *NoBackupTeamsChatsE2ESuite) TestTeamsChatsBackupListCmd_noBackups()
|
||||
type BackupTeamsChatsE2ESuite struct {
|
||||
tester.Suite
|
||||
dpnd dependencies
|
||||
its intgTesterSetup
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestBackupTeamsChatsE2ESuite(t *testing.T) {
|
||||
@ -106,7 +107,7 @@ func (suite *BackupTeamsChatsE2ESuite) SetupSuite() {
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
suite.its = newIntegrationTesterSetup(t)
|
||||
suite.m365 = its.GetM365(t)
|
||||
suite.dpnd = prepM365Test(t, ctx, path.TeamsChatsService)
|
||||
}
|
||||
|
||||
@ -128,7 +129,7 @@ func runTeamsChatsBackupCategoryTest(suite *BackupTeamsChatsE2ESuite, category s
|
||||
cmd, ctx := buildTeamsChatsBackupCmd(
|
||||
ctx,
|
||||
suite.dpnd.configFilePath,
|
||||
suite.its.user.ID,
|
||||
suite.m365.User.ID,
|
||||
category,
|
||||
&recorder)
|
||||
|
||||
@ -188,7 +189,7 @@ func (suite *BackupTeamsChatsE2ESuite) TestBackupCreateTeamsChats_badAzureClient
|
||||
|
||||
cmd := cliTD.StubRootCmd(
|
||||
"backup", "create", "chats",
|
||||
"--teamschat", suite.its.user.ID,
|
||||
"--teamschat", suite.m365.User.ID,
|
||||
"--azure-client-id", "invalid-value")
|
||||
cli.BuildCommandTree(cmd)
|
||||
|
||||
@ -212,7 +213,7 @@ func (suite *BackupTeamsChatsE2ESuite) TestBackupCreateTeamsChats_fromConfigFile
|
||||
|
||||
cmd := cliTD.StubRootCmd(
|
||||
"backup", "create", "chats",
|
||||
"--teamschat", suite.its.user.ID,
|
||||
"--teamschat", suite.m365.User.ID,
|
||||
"--"+flags.ConfigFileFN, suite.dpnd.configFilePath)
|
||||
cli.BuildCommandTree(cmd)
|
||||
|
||||
@ -236,7 +237,7 @@ func (suite *BackupTeamsChatsE2ESuite) TestBackupCreateTeamsChats_badAWSFlags()
|
||||
|
||||
cmd := cliTD.StubRootCmd(
|
||||
"backup", "create", "chats",
|
||||
"--teamschat", suite.its.user.ID,
|
||||
"--teamschat", suite.m365.User.ID,
|
||||
"--aws-access-key", "invalid-value",
|
||||
"--aws-secret-access-key", "some-invalid-value")
|
||||
cli.BuildCommandTree(cmd)
|
||||
@ -259,7 +260,7 @@ type PreparedBackupTeamsChatsE2ESuite struct {
|
||||
tester.Suite
|
||||
dpnd dependencies
|
||||
backupOps map[path.CategoryType]string
|
||||
its intgTesterSetup
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestPreparedBackupTeamsChatsE2ESuite(t *testing.T) {
|
||||
@ -277,13 +278,13 @@ func (suite *PreparedBackupTeamsChatsE2ESuite) SetupSuite() {
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
suite.its = newIntegrationTesterSetup(t)
|
||||
suite.m365 = its.GetM365(t)
|
||||
suite.dpnd = prepM365Test(t, ctx, path.TeamsChatsService)
|
||||
suite.backupOps = make(map[path.CategoryType]string)
|
||||
|
||||
var (
|
||||
teamschats = []string{suite.its.user.ID}
|
||||
ins = idname.NewCache(map[string]string{suite.its.user.ID: suite.its.user.ID})
|
||||
teamschats = []string{suite.m365.User.ID}
|
||||
ins = idname.NewCache(map[string]string{suite.m365.User.ID: suite.m365.User.ID})
|
||||
cats = []path.CategoryType{
|
||||
path.ChatsCategory,
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ package m365
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/alcionai/clues"
|
||||
|
||||
@ -109,7 +110,7 @@ func (ctrl *Controller) ProduceBackupCollections(
|
||||
handler = teamschats.NewBackup()
|
||||
|
||||
default:
|
||||
return nil, nil, false, clues.Wrap(clues.NewWC(ctx, service.String()), "service not supported")
|
||||
return nil, nil, false, clues.NewWC(ctx, fmt.Sprintf("service not supported: %s", service.HumanString()))
|
||||
}
|
||||
|
||||
colls, excludeItems, canUsePreviousBackup, err = handler.ProduceBackupCollections(
|
||||
@ -173,7 +174,8 @@ func verifyBackupInputs(sel selectors.Selector, cachedIDs []string) error {
|
||||
}
|
||||
|
||||
if !filters.Contains(ids).Compare(sel.ID()) {
|
||||
return clues.Stack(core.ErrNotFound).With("selector_protected_resource", sel.ID())
|
||||
return clues.Wrap(core.ErrNotFound, "verifying existence of resource").
|
||||
With("selector_protected_resource", sel.ID())
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@ -11,7 +11,6 @@ import (
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
inMock "github.com/alcionai/corso/src/internal/common/idname/mock"
|
||||
"github.com/alcionai/corso/src/internal/common/ptr"
|
||||
"github.com/alcionai/corso/src/internal/data"
|
||||
"github.com/alcionai/corso/src/internal/data/mock"
|
||||
"github.com/alcionai/corso/src/internal/m365/service/exchange"
|
||||
@ -19,6 +18,7 @@ import (
|
||||
"github.com/alcionai/corso/src/internal/m365/service/sharepoint"
|
||||
"github.com/alcionai/corso/src/internal/operations/inject"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/internal/tester/its"
|
||||
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
||||
"github.com/alcionai/corso/src/internal/version"
|
||||
"github.com/alcionai/corso/src/pkg/control"
|
||||
@ -36,10 +36,7 @@ import (
|
||||
|
||||
type DataCollectionIntgSuite struct {
|
||||
tester.Suite
|
||||
user string
|
||||
site string
|
||||
tenantID string
|
||||
ac api.Client
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestDataCollectionIntgSuite(t *testing.T) {
|
||||
@ -51,29 +48,14 @@ func TestDataCollectionIntgSuite(t *testing.T) {
|
||||
}
|
||||
|
||||
func (suite *DataCollectionIntgSuite) SetupSuite() {
|
||||
t := suite.T()
|
||||
|
||||
suite.user = tconfig.M365UserID(t)
|
||||
suite.site = tconfig.M365SiteID(t)
|
||||
|
||||
acct := tconfig.NewM365Account(t)
|
||||
creds, err := acct.M365Config()
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
suite.tenantID = creds.AzureTenantID
|
||||
|
||||
suite.ac, err = api.NewClient(
|
||||
creds,
|
||||
control.DefaultOptions(),
|
||||
count.New())
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
suite.m365 = its.GetM365(suite.T())
|
||||
}
|
||||
|
||||
func (suite *DataCollectionIntgSuite) TestExchangeDataCollection() {
|
||||
ctx, flush := tester.NewContext(suite.T())
|
||||
defer flush()
|
||||
|
||||
selUsers := []string{suite.user}
|
||||
selUsers := []string{suite.m365.User.ID}
|
||||
|
||||
ctrl := newController(ctx, suite.T(), path.ExchangeService)
|
||||
tests := []struct {
|
||||
@ -85,7 +67,7 @@ func (suite *DataCollectionIntgSuite) TestExchangeDataCollection() {
|
||||
getSelector: func(t *testing.T) selectors.Selector {
|
||||
sel := selectors.NewExchangeBackup(selUsers)
|
||||
sel.Include(sel.MailFolders([]string{api.MailInbox}, selectors.PrefixMatch()))
|
||||
sel.DiscreteOwner = suite.user
|
||||
sel.DiscreteOwner = suite.m365.User.ID
|
||||
return sel.Selector
|
||||
},
|
||||
},
|
||||
@ -94,7 +76,7 @@ func (suite *DataCollectionIntgSuite) TestExchangeDataCollection() {
|
||||
getSelector: func(t *testing.T) selectors.Selector {
|
||||
sel := selectors.NewExchangeBackup(selUsers)
|
||||
sel.Include(sel.ContactFolders([]string{api.DefaultContacts}, selectors.PrefixMatch()))
|
||||
sel.DiscreteOwner = suite.user
|
||||
sel.DiscreteOwner = suite.m365.User.ID
|
||||
return sel.Selector
|
||||
},
|
||||
},
|
||||
@ -142,8 +124,8 @@ func (suite *DataCollectionIntgSuite) TestExchangeDataCollection() {
|
||||
collections, excludes, canUsePreviousBackup, err := exchange.NewBackup().ProduceBackupCollections(
|
||||
ctx,
|
||||
bpc,
|
||||
suite.ac,
|
||||
suite.ac.Credentials,
|
||||
suite.m365.AC,
|
||||
suite.m365.Creds,
|
||||
ctrl.UpdateStatus,
|
||||
count.New(),
|
||||
fault.New(true))
|
||||
@ -270,7 +252,7 @@ func (suite *DataCollectionIntgSuite) TestSharePointDataCollection() {
|
||||
ctx, flush := tester.NewContext(suite.T())
|
||||
defer flush()
|
||||
|
||||
selSites := []string{suite.site}
|
||||
selSites := []string{suite.m365.Site.ID}
|
||||
ctrl := newController(ctx, suite.T(), path.SharePointService)
|
||||
tests := []struct {
|
||||
name string
|
||||
@ -312,7 +294,7 @@ func (suite *DataCollectionIntgSuite) TestSharePointDataCollection() {
|
||||
collections, excludes, canUsePreviousBackup, err := sharepoint.NewBackup().ProduceBackupCollections(
|
||||
ctx,
|
||||
bpc,
|
||||
suite.ac,
|
||||
suite.m365.AC,
|
||||
ctrl.credentials,
|
||||
ctrl.UpdateStatus,
|
||||
count.New(),
|
||||
@ -351,8 +333,7 @@ func (suite *DataCollectionIntgSuite) TestSharePointDataCollection() {
|
||||
|
||||
type SPCollectionIntgSuite struct {
|
||||
tester.Suite
|
||||
connector *Controller
|
||||
user string
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestSPCollectionIntgSuite(t *testing.T) {
|
||||
@ -364,13 +345,7 @@ func TestSPCollectionIntgSuite(t *testing.T) {
|
||||
}
|
||||
|
||||
func (suite *SPCollectionIntgSuite) SetupSuite() {
|
||||
ctx, flush := tester.NewContext(suite.T())
|
||||
defer flush()
|
||||
|
||||
suite.connector = newController(ctx, suite.T(), path.SharePointService)
|
||||
suite.user = tconfig.M365UserID(suite.T())
|
||||
|
||||
tester.LogTimeOfTest(suite.T())
|
||||
suite.m365 = its.GetM365(suite.T())
|
||||
}
|
||||
|
||||
func (suite *SPCollectionIntgSuite) TestCreateSharePointCollection_Libraries() {
|
||||
@ -379,25 +354,20 @@ func (suite *SPCollectionIntgSuite) TestCreateSharePointCollection_Libraries() {
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
var (
|
||||
siteID = tconfig.M365SiteID(t)
|
||||
ctrl = newController(ctx, t, path.SharePointService)
|
||||
siteIDs = []string{siteID}
|
||||
)
|
||||
ctrl := newController(ctx, t, path.SharePointService)
|
||||
|
||||
site, err := ctrl.PopulateProtectedResourceIDAndName(ctx, siteID, nil)
|
||||
_, err := ctrl.PopulateProtectedResourceIDAndName(ctx, suite.m365.Site.ID, nil)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
sel := selectors.NewSharePointBackup(siteIDs)
|
||||
sel := selectors.NewSharePointBackup([]string{suite.m365.Site.ID})
|
||||
sel.Include(sel.LibraryFolders([]string{"foo"}, selectors.PrefixMatch()))
|
||||
sel.Include(sel.Library("Documents"))
|
||||
|
||||
sel.SetDiscreteOwnerIDName(site.ID(), site.Name())
|
||||
sel.SetDiscreteOwnerIDName(suite.m365.Site.ID, suite.m365.Site.WebURL)
|
||||
|
||||
bpc := inject.BackupProducerConfig{
|
||||
LastBackupVersion: version.NoBackup,
|
||||
Options: control.DefaultOptions(),
|
||||
ProtectedResource: site,
|
||||
ProtectedResource: suite.m365.Site.Provider,
|
||||
Selector: sel.Selector,
|
||||
}
|
||||
|
||||
@ -415,15 +385,15 @@ func (suite *SPCollectionIntgSuite) TestCreateSharePointCollection_Libraries() {
|
||||
)
|
||||
|
||||
documentsColl, err := path.BuildPrefix(
|
||||
suite.connector.tenant,
|
||||
siteID,
|
||||
suite.m365.TenantID,
|
||||
suite.m365.Site.ID,
|
||||
path.SharePointService,
|
||||
path.LibrariesCategory)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
metadataColl, err := path.BuildMetadata(
|
||||
suite.connector.tenant,
|
||||
siteID,
|
||||
suite.m365.TenantID,
|
||||
suite.m365.Site.ID,
|
||||
path.SharePointService,
|
||||
path.LibrariesCategory,
|
||||
false)
|
||||
@ -450,24 +420,19 @@ func (suite *SPCollectionIntgSuite) TestCreateSharePointCollection_Lists() {
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
var (
|
||||
siteID = tconfig.M365SiteID(t)
|
||||
ctrl = newController(ctx, t, path.SharePointService)
|
||||
siteIDs = []string{siteID}
|
||||
)
|
||||
ctrl := newController(ctx, t, path.SharePointService)
|
||||
|
||||
site, err := ctrl.PopulateProtectedResourceIDAndName(ctx, siteID, nil)
|
||||
_, err := ctrl.PopulateProtectedResourceIDAndName(ctx, suite.m365.Site.ID, nil)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
sel := selectors.NewSharePointBackup(siteIDs)
|
||||
sel := selectors.NewSharePointBackup([]string{suite.m365.Site.ID})
|
||||
sel.Include(sel.Lists(selectors.Any()))
|
||||
|
||||
sel.SetDiscreteOwnerIDName(site.ID(), site.Name())
|
||||
sel.SetDiscreteOwnerIDName(suite.m365.Site.ID, suite.m365.Site.WebURL)
|
||||
|
||||
bpc := inject.BackupProducerConfig{
|
||||
LastBackupVersion: version.NoBackup,
|
||||
Options: control.DefaultOptions(),
|
||||
ProtectedResource: site,
|
||||
ProtectedResource: suite.m365.Site.Provider,
|
||||
Selector: sel.Selector,
|
||||
}
|
||||
|
||||
@ -502,9 +467,7 @@ func (suite *SPCollectionIntgSuite) TestCreateSharePointCollection_Lists() {
|
||||
|
||||
type GroupsCollectionIntgSuite struct {
|
||||
tester.Suite
|
||||
connector *Controller
|
||||
tenantID string
|
||||
user string
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestGroupsCollectionIntgSuite(t *testing.T) {
|
||||
@ -516,21 +479,7 @@ func TestGroupsCollectionIntgSuite(t *testing.T) {
|
||||
}
|
||||
|
||||
func (suite *GroupsCollectionIntgSuite) SetupSuite() {
|
||||
t := suite.T()
|
||||
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
suite.connector = newController(ctx, t, path.GroupsService)
|
||||
suite.user = tconfig.M365UserID(t)
|
||||
|
||||
acct := tconfig.NewM365Account(t)
|
||||
creds, err := acct.M365Config()
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
suite.tenantID = creds.AzureTenantID
|
||||
|
||||
tester.LogTimeOfTest(t)
|
||||
suite.m365 = its.GetM365(suite.T())
|
||||
}
|
||||
|
||||
func (suite *GroupsCollectionIntgSuite) TestCreateGroupsCollection_SharePoint() {
|
||||
@ -539,24 +488,19 @@ func (suite *GroupsCollectionIntgSuite) TestCreateGroupsCollection_SharePoint()
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
var (
|
||||
groupID = tconfig.M365TeamID(t)
|
||||
ctrl = newController(ctx, t, path.GroupsService)
|
||||
groupIDs = []string{groupID}
|
||||
)
|
||||
ctrl := newController(ctx, t, path.GroupsService)
|
||||
|
||||
group, err := ctrl.PopulateProtectedResourceIDAndName(ctx, groupID, nil)
|
||||
_, err := ctrl.PopulateProtectedResourceIDAndName(ctx, suite.m365.Group.ID, nil)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
sel := selectors.NewGroupsBackup(groupIDs)
|
||||
sel := selectors.NewGroupsBackup([]string{suite.m365.Group.ID})
|
||||
sel.Include(sel.LibraryFolders([]string{"test"}, selectors.PrefixMatch()))
|
||||
|
||||
sel.SetDiscreteOwnerIDName(group.ID(), group.Name())
|
||||
sel.SetDiscreteOwnerIDName(suite.m365.Group.ID, suite.m365.Group.DisplayName)
|
||||
|
||||
bpc := inject.BackupProducerConfig{
|
||||
LastBackupVersion: version.NoBackup,
|
||||
Options: control.DefaultOptions(),
|
||||
ProtectedResource: group,
|
||||
ProtectedResource: suite.m365.Group.Provider,
|
||||
Selector: sel.Selector,
|
||||
}
|
||||
|
||||
@ -575,8 +519,8 @@ func (suite *GroupsCollectionIntgSuite) TestCreateGroupsCollection_SharePoint()
|
||||
assert.Greater(t, len(collections), 1)
|
||||
|
||||
p, err := path.BuildMetadata(
|
||||
suite.tenantID,
|
||||
groupID,
|
||||
suite.m365.TenantID,
|
||||
suite.m365.Group.ID,
|
||||
path.GroupsService,
|
||||
path.LibrariesCategory,
|
||||
false)
|
||||
@ -614,31 +558,23 @@ func (suite *GroupsCollectionIntgSuite) TestCreateGroupsCollection_SharePoint_In
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
var (
|
||||
groupID = tconfig.M365TeamID(t)
|
||||
ctrl = newController(ctx, t, path.GroupsService)
|
||||
groupIDs = []string{groupID}
|
||||
)
|
||||
ctrl := newController(ctx, t, path.GroupsService)
|
||||
|
||||
group, err := ctrl.PopulateProtectedResourceIDAndName(ctx, groupID, nil)
|
||||
_, err := ctrl.PopulateProtectedResourceIDAndName(ctx, suite.m365.Group.ID, nil)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
sel := selectors.NewGroupsBackup(groupIDs)
|
||||
sel := selectors.NewGroupsBackup([]string{suite.m365.Group.ID})
|
||||
sel.Include(sel.LibraryFolders([]string{"test"}, selectors.PrefixMatch()))
|
||||
|
||||
sel.SetDiscreteOwnerIDName(group.ID(), group.Name())
|
||||
|
||||
site, err := suite.connector.AC.Groups().GetRootSite(ctx, groupID)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
sel.SetDiscreteOwnerIDName(suite.m365.Group.ID, suite.m365.Group.DisplayName)
|
||||
|
||||
pth, err := path.Build(
|
||||
suite.tenantID,
|
||||
groupID,
|
||||
suite.m365.TenantID,
|
||||
suite.m365.Group.ID,
|
||||
path.GroupsService,
|
||||
path.LibrariesCategory,
|
||||
true,
|
||||
odConsts.SitesPathDir,
|
||||
ptr.Val(site.GetId()))
|
||||
suite.m365.Group.RootSite.ID)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
mmc := []data.RestoreCollection{
|
||||
@ -656,7 +592,7 @@ func (suite *GroupsCollectionIntgSuite) TestCreateGroupsCollection_SharePoint_In
|
||||
bpc := inject.BackupProducerConfig{
|
||||
LastBackupVersion: version.NoBackup,
|
||||
Options: control.DefaultOptions(),
|
||||
ProtectedResource: group,
|
||||
ProtectedResource: suite.m365.Group.Provider,
|
||||
Selector: sel.Selector,
|
||||
MetadataCollections: mmc,
|
||||
}
|
||||
@ -676,8 +612,8 @@ func (suite *GroupsCollectionIntgSuite) TestCreateGroupsCollection_SharePoint_In
|
||||
assert.Greater(t, len(collections), 1)
|
||||
|
||||
p, err := path.BuildMetadata(
|
||||
suite.tenantID,
|
||||
groupID,
|
||||
suite.m365.TenantID,
|
||||
suite.m365.Group.ID,
|
||||
path.GroupsService,
|
||||
path.LibrariesCategory,
|
||||
false)
|
||||
@ -690,13 +626,13 @@ func (suite *GroupsCollectionIntgSuite) TestCreateGroupsCollection_SharePoint_In
|
||||
foundRootTombstone := false
|
||||
|
||||
sp, err := path.BuildPrefix(
|
||||
suite.tenantID,
|
||||
groupID,
|
||||
suite.m365.TenantID,
|
||||
suite.m365.Group.ID,
|
||||
path.GroupsService,
|
||||
path.LibrariesCategory)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
sp, err = sp.Append(false, odConsts.SitesPathDir, ptr.Val(site.GetId()))
|
||||
sp, err = sp.Append(false, odConsts.SitesPathDir, suite.m365.Group.RootSite.ID)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
for _, coll := range collections {
|
||||
|
||||
@ -22,8 +22,6 @@ import (
|
||||
odConsts "github.com/alcionai/corso/src/internal/m365/service/onedrive/consts"
|
||||
"github.com/alcionai/corso/src/internal/m365/support"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
||||
"github.com/alcionai/corso/src/pkg/account"
|
||||
"github.com/alcionai/corso/src/pkg/backup/details"
|
||||
bupMD "github.com/alcionai/corso/src/pkg/backup/metadata"
|
||||
"github.com/alcionai/corso/src/pkg/control"
|
||||
@ -41,50 +39,6 @@ import (
|
||||
|
||||
const defaultFileSize int64 = 42
|
||||
|
||||
// TODO(ashmrtn): Merge with similar structs in graph and exchange packages.
|
||||
type oneDriveService struct {
|
||||
credentials account.M365Config
|
||||
status support.ControllerOperationStatus
|
||||
ac api.Client
|
||||
}
|
||||
|
||||
func newOneDriveService(credentials account.M365Config) (*oneDriveService, error) {
|
||||
ac, err := api.NewClient(
|
||||
credentials,
|
||||
control.DefaultOptions(),
|
||||
count.New())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
service := oneDriveService{
|
||||
ac: ac,
|
||||
credentials: credentials,
|
||||
}
|
||||
|
||||
return &service, nil
|
||||
}
|
||||
|
||||
func (ods *oneDriveService) updateStatus(status *support.ControllerOperationStatus) {
|
||||
if status == nil {
|
||||
return
|
||||
}
|
||||
|
||||
ods.status = support.MergeStatus(ods.status, *status)
|
||||
}
|
||||
|
||||
func loadTestService(t *testing.T) *oneDriveService {
|
||||
a := tconfig.NewM365Account(t)
|
||||
|
||||
creds, err := a.M365Config()
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
service, err := newOneDriveService(creds)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
return service
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// collections
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@ -12,6 +12,7 @@ import (
|
||||
|
||||
"github.com/alcionai/corso/src/internal/common/idname"
|
||||
"github.com/alcionai/corso/src/internal/common/prefixmatcher"
|
||||
"github.com/alcionai/corso/src/internal/m365/support"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
||||
"github.com/alcionai/corso/src/pkg/account"
|
||||
@ -233,6 +234,18 @@ func (suite *OneDriveIntgSuite) SetupSuite() {
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
}
|
||||
|
||||
type stubStatusUpdater struct {
|
||||
status support.ControllerOperationStatus
|
||||
}
|
||||
|
||||
func (ssu *stubStatusUpdater) updateStatus(status *support.ControllerOperationStatus) {
|
||||
if status == nil {
|
||||
return
|
||||
}
|
||||
|
||||
ssu.status = support.MergeStatus(ssu.status, *status)
|
||||
}
|
||||
|
||||
func (suite *OneDriveIntgSuite) TestOneDriveNewCollections() {
|
||||
creds, err := tconfig.NewM365Account(suite.T()).M365Config()
|
||||
require.NoError(suite.T(), err, clues.ToCore(err))
|
||||
@ -258,10 +271,10 @@ func (suite *OneDriveIntgSuite) TestOneDriveNewCollections() {
|
||||
defer flush()
|
||||
|
||||
var (
|
||||
service = loadTestService(t)
|
||||
scope = selectors.
|
||||
NewOneDriveBackup([]string{test.user}).
|
||||
AllData()[0]
|
||||
statusUpdater = stubStatusUpdater{}
|
||||
)
|
||||
|
||||
colls := NewCollections(
|
||||
@ -274,7 +287,7 @@ func (suite *OneDriveIntgSuite) TestOneDriveNewCollections() {
|
||||
},
|
||||
creds.AzureTenantID,
|
||||
idname.NewProvider(test.user, test.user),
|
||||
service.updateStatus,
|
||||
statusUpdater.updateStatus,
|
||||
control.Options{
|
||||
ToggleFeatures: control.Toggles{},
|
||||
},
|
||||
|
||||
@ -17,6 +17,7 @@ import (
|
||||
"github.com/alcionai/corso/src/internal/common/ptr"
|
||||
"github.com/alcionai/corso/src/internal/common/str"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/internal/tester/its"
|
||||
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
||||
"github.com/alcionai/corso/src/pkg/control"
|
||||
"github.com/alcionai/corso/src/pkg/control/testdata"
|
||||
@ -30,9 +31,7 @@ import (
|
||||
|
||||
type ItemIntegrationSuite struct {
|
||||
tester.Suite
|
||||
user string
|
||||
userDriveID string
|
||||
service *oneDriveService
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestItemIntegrationSuite(t *testing.T) {
|
||||
@ -44,25 +43,7 @@ func TestItemIntegrationSuite(t *testing.T) {
|
||||
}
|
||||
|
||||
func (suite *ItemIntegrationSuite) SetupSuite() {
|
||||
t := suite.T()
|
||||
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
suite.service = loadTestService(t)
|
||||
suite.user = tconfig.SecondaryM365UserID(t)
|
||||
|
||||
graph.InitializeConcurrencyLimiter(ctx, true, 4)
|
||||
|
||||
pager := suite.service.ac.Drives().NewUserDrivePager(suite.user, nil)
|
||||
|
||||
odDrives, err := api.GetAllDrives(ctx, pager)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
// Test Requirement 1: Need a drive
|
||||
require.Greaterf(t, len(odDrives), 0, "user %s does not have a drive", suite.user)
|
||||
|
||||
// Pick the first drive
|
||||
suite.userDriveID = ptr.Val(odDrives[0].GetId())
|
||||
suite.m365 = its.GetM365(suite.T())
|
||||
}
|
||||
|
||||
func getOneDriveItem(
|
||||
@ -103,23 +84,27 @@ func (suite *ItemIntegrationSuite) TestItemReader_oneDrive() {
|
||||
defer flush()
|
||||
|
||||
sc := selectors.
|
||||
NewOneDriveBackup([]string{suite.user}).
|
||||
NewOneDriveBackup([]string{suite.m365.User.ID}).
|
||||
AllData()[0]
|
||||
|
||||
driveItem := getOneDriveItem(ctx, t, suite.service.ac, suite.userDriveID)
|
||||
driveItem := getOneDriveItem(
|
||||
ctx,
|
||||
t,
|
||||
suite.m365.AC,
|
||||
suite.m365.User.DriveID)
|
||||
// Test Requirement 2: Need a file
|
||||
require.NotEmpty(
|
||||
t,
|
||||
driveItem,
|
||||
"no file item found for user %s drive %s",
|
||||
suite.user,
|
||||
suite.userDriveID)
|
||||
"no file item found for user %q drive %q",
|
||||
suite.m365.User.ID,
|
||||
suite.m365.User.DriveID)
|
||||
|
||||
bh := &userDriveBackupHandler{
|
||||
baseUserDriveHandler: baseUserDriveHandler{
|
||||
ac: suite.service.ac.Drives(),
|
||||
ac: suite.m365.AC.Drives(),
|
||||
},
|
||||
userID: suite.user,
|
||||
userID: suite.m365.User.ID,
|
||||
scope: sc,
|
||||
}
|
||||
|
||||
@ -142,13 +127,13 @@ func (suite *ItemIntegrationSuite) TestIsURLExpired() {
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
driveItem := getOneDriveItem(ctx, t, suite.service.ac, suite.userDriveID)
|
||||
driveItem := getOneDriveItem(ctx, t, suite.m365.AC, suite.m365.User.DriveID)
|
||||
require.NotEmpty(
|
||||
t,
|
||||
driveItem,
|
||||
"no file item found for user %s drive %s",
|
||||
suite.user,
|
||||
suite.userDriveID)
|
||||
"no file item found for user %q drive %q",
|
||||
suite.m365.User.ID,
|
||||
suite.m365.User.DriveID)
|
||||
|
||||
var url string
|
||||
|
||||
@ -173,7 +158,7 @@ func (suite *ItemIntegrationSuite) TestItemWriter() {
|
||||
}{
|
||||
{
|
||||
name: "",
|
||||
driveID: suite.userDriveID,
|
||||
driveID: suite.m365.User.DriveID,
|
||||
},
|
||||
// {
|
||||
// name: "sharePoint",
|
||||
@ -183,12 +168,12 @@ func (suite *ItemIntegrationSuite) TestItemWriter() {
|
||||
for _, test := range table {
|
||||
suite.Run(test.name, func() {
|
||||
t := suite.T()
|
||||
rh := NewUserDriveRestoreHandler(suite.service.ac)
|
||||
rh := NewUserDriveRestoreHandler(suite.m365.AC)
|
||||
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
root, err := suite.service.ac.Drives().GetRootFolder(ctx, test.driveID)
|
||||
root, err := suite.m365.AC.Drives().GetRootFolder(ctx, test.driveID)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
newFolderName := testdata.DefaultRestoreConfig("folder").Location
|
||||
@ -217,7 +202,7 @@ func (suite *ItemIntegrationSuite) TestItemWriter() {
|
||||
|
||||
// HACK: Leveraging this to test getFolder behavior for a file. `getFolder()` on the
|
||||
// newly created item should fail because it's a file not a folder
|
||||
_, err = suite.service.ac.Drives().GetFolderByName(
|
||||
_, err = suite.m365.AC.Drives().GetFolderByName(
|
||||
ctx,
|
||||
test.driveID,
|
||||
ptr.Val(newFolder.GetId()),
|
||||
@ -261,7 +246,7 @@ func (suite *ItemIntegrationSuite) TestDriveGetFolder() {
|
||||
}{
|
||||
{
|
||||
name: "oneDrive",
|
||||
driveID: suite.userDriveID,
|
||||
driveID: suite.m365.User.DriveID,
|
||||
},
|
||||
// {
|
||||
// name: "sharePoint",
|
||||
@ -275,11 +260,11 @@ func (suite *ItemIntegrationSuite) TestDriveGetFolder() {
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
root, err := suite.service.ac.Drives().GetRootFolder(ctx, test.driveID)
|
||||
root, err := suite.m365.AC.Drives().GetRootFolder(ctx, test.driveID)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
// Lookup a folder that doesn't exist
|
||||
_, err = suite.service.ac.Drives().GetFolderByName(
|
||||
_, err = suite.m365.AC.Drives().GetFolderByName(
|
||||
ctx,
|
||||
test.driveID,
|
||||
ptr.Val(root.GetId()),
|
||||
@ -287,7 +272,7 @@ func (suite *ItemIntegrationSuite) TestDriveGetFolder() {
|
||||
require.ErrorIs(t, err, api.ErrFolderNotFound, clues.ToCore(err))
|
||||
|
||||
// Lookup a folder that does exist
|
||||
_, err = suite.service.ac.Drives().GetFolderByName(
|
||||
_, err = suite.m365.AC.Drives().GetFolderByName(
|
||||
ctx,
|
||||
test.driveID,
|
||||
ptr.Val(root.GetId()),
|
||||
|
||||
@ -18,6 +18,7 @@ import (
|
||||
|
||||
"github.com/alcionai/corso/src/internal/common/ptr"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/internal/tester/its"
|
||||
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
||||
"github.com/alcionai/corso/src/pkg/control"
|
||||
"github.com/alcionai/corso/src/pkg/control/testdata"
|
||||
@ -34,9 +35,7 @@ import (
|
||||
|
||||
type URLCacheIntegrationSuite struct {
|
||||
tester.Suite
|
||||
ac api.Client
|
||||
user string
|
||||
driveID string
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestURLCacheIntegrationSuite(t *testing.T) {
|
||||
@ -49,29 +48,12 @@ func TestURLCacheIntegrationSuite(t *testing.T) {
|
||||
|
||||
func (suite *URLCacheIntegrationSuite) SetupSuite() {
|
||||
t := suite.T()
|
||||
suite.m365 = its.GetM365(t)
|
||||
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
graph.InitializeConcurrencyLimiter(ctx, true, 4)
|
||||
|
||||
suite.user = tconfig.SecondaryM365UserID(t)
|
||||
|
||||
acct := tconfig.NewM365Account(t)
|
||||
|
||||
creds, err := acct.M365Config()
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
suite.ac, err = api.NewClient(
|
||||
creds,
|
||||
control.DefaultOptions(),
|
||||
count.New())
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
drive, err := suite.ac.Users().GetDefaultDrive(ctx, suite.user)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
suite.driveID = ptr.Val(drive.GetId())
|
||||
}
|
||||
|
||||
// Basic test for urlCache. Create some files in onedrive, then access them via
|
||||
@ -79,22 +61,18 @@ func (suite *URLCacheIntegrationSuite) SetupSuite() {
|
||||
func (suite *URLCacheIntegrationSuite) TestURLCacheBasic() {
|
||||
var (
|
||||
t = suite.T()
|
||||
ac = suite.ac.Drives()
|
||||
driveID = suite.driveID
|
||||
ac = suite.m365.AC.Drives()
|
||||
driveID = suite.m365.User.DriveID
|
||||
newFolderName = testdata.DefaultRestoreConfig("folder").Location
|
||||
)
|
||||
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
// Create a new test folder
|
||||
root, err := ac.GetRootFolder(ctx, driveID)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
newFolder, err := ac.PostItemInContainer(
|
||||
ctx,
|
||||
driveID,
|
||||
ptr.Val(root.GetId()),
|
||||
suite.m365.User.DriveRootFolderID,
|
||||
api.NewDriveItem(newFolderName, true),
|
||||
control.Copy)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
@ -105,7 +83,7 @@ func (suite *URLCacheIntegrationSuite) TestURLCacheBasic() {
|
||||
// Get the previous delta to feed into url cache
|
||||
pager := ac.EnumerateDriveItemsDelta(
|
||||
ctx,
|
||||
suite.driveID,
|
||||
driveID,
|
||||
"",
|
||||
api.CallConfig{
|
||||
Select: api.URLCacheDriveItemProps(),
|
||||
@ -142,10 +120,10 @@ func (suite *URLCacheIntegrationSuite) TestURLCacheBasic() {
|
||||
|
||||
// Create a new URL cache with a long TTL
|
||||
uc, err := newURLCache(
|
||||
suite.driveID,
|
||||
driveID,
|
||||
du.URL,
|
||||
1*time.Hour,
|
||||
suite.ac.Drives(),
|
||||
ac,
|
||||
count.New(),
|
||||
fault.New(true))
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
@ -24,6 +24,7 @@ import (
|
||||
"github.com/alcionai/corso/src/internal/m365/support"
|
||||
"github.com/alcionai/corso/src/internal/operations/inject"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/internal/tester/its"
|
||||
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
||||
"github.com/alcionai/corso/src/internal/version"
|
||||
"github.com/alcionai/corso/src/pkg/account"
|
||||
@ -472,10 +473,7 @@ func newStatusUpdater(t *testing.T, wg *sync.WaitGroup) func(status *support.Con
|
||||
|
||||
type BackupIntgSuite struct {
|
||||
tester.Suite
|
||||
user string
|
||||
site string
|
||||
tenantID string
|
||||
ac api.Client
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestBackupIntgSuite(t *testing.T) {
|
||||
@ -488,35 +486,18 @@ func TestBackupIntgSuite(t *testing.T) {
|
||||
|
||||
func (suite *BackupIntgSuite) SetupSuite() {
|
||||
t := suite.T()
|
||||
suite.m365 = its.GetM365(t)
|
||||
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
graph.InitializeConcurrencyLimiter(ctx, true, 4)
|
||||
|
||||
suite.user = tconfig.M365UserID(t)
|
||||
suite.site = tconfig.M365SiteID(t)
|
||||
|
||||
acct := tconfig.NewM365Account(t)
|
||||
creds, err := acct.M365Config()
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
suite.ac, err = api.NewClient(
|
||||
creds,
|
||||
control.DefaultOptions(),
|
||||
count.New())
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
suite.tenantID = creds.AzureTenantID
|
||||
|
||||
tester.LogTimeOfTest(t)
|
||||
}
|
||||
|
||||
func (suite *BackupIntgSuite) TestMailFetch() {
|
||||
var (
|
||||
userID = tconfig.M365UserID(suite.T())
|
||||
users = []string{userID}
|
||||
handlers = BackupHandlers(suite.ac)
|
||||
users = []string{suite.m365.User.ID}
|
||||
handlers = BackupHandlers(suite.m365.AC)
|
||||
)
|
||||
|
||||
tests := []struct {
|
||||
@ -560,14 +541,14 @@ func (suite *BackupIntgSuite) TestMailFetch() {
|
||||
bpc := inject.BackupProducerConfig{
|
||||
LastBackupVersion: version.NoBackup,
|
||||
Options: ctrlOpts,
|
||||
ProtectedResource: inMock.NewProvider(userID, userID),
|
||||
ProtectedResource: suite.m365.User.Provider,
|
||||
}
|
||||
|
||||
collections, err := CreateCollections(
|
||||
ctx,
|
||||
bpc,
|
||||
handlers,
|
||||
suite.tenantID,
|
||||
suite.m365.TenantID,
|
||||
test.scope,
|
||||
metadata.DeltaPaths{},
|
||||
func(status *support.ControllerOperationStatus) {},
|
||||
@ -602,9 +583,8 @@ func (suite *BackupIntgSuite) TestMailFetch() {
|
||||
|
||||
func (suite *BackupIntgSuite) TestDelta() {
|
||||
var (
|
||||
userID = tconfig.M365UserID(suite.T())
|
||||
users = []string{userID}
|
||||
handlers = BackupHandlers(suite.ac)
|
||||
users = []string{suite.m365.User.ID}
|
||||
handlers = BackupHandlers(suite.m365.AC)
|
||||
)
|
||||
|
||||
tests := []struct {
|
||||
@ -640,7 +620,7 @@ func (suite *BackupIntgSuite) TestDelta() {
|
||||
bpc := inject.BackupProducerConfig{
|
||||
LastBackupVersion: version.NoBackup,
|
||||
Options: control.DefaultOptions(),
|
||||
ProtectedResource: inMock.NewProvider(userID, userID),
|
||||
ProtectedResource: suite.m365.User.Provider,
|
||||
}
|
||||
|
||||
// get collections without providing any delta history (ie: full backup)
|
||||
@ -648,7 +628,7 @@ func (suite *BackupIntgSuite) TestDelta() {
|
||||
ctx,
|
||||
bpc,
|
||||
handlers,
|
||||
suite.tenantID,
|
||||
suite.m365.TenantID,
|
||||
test.scope,
|
||||
metadata.DeltaPaths{},
|
||||
func(status *support.ControllerOperationStatus) {},
|
||||
@ -681,7 +661,7 @@ func (suite *BackupIntgSuite) TestDelta() {
|
||||
ctx,
|
||||
bpc,
|
||||
handlers,
|
||||
suite.tenantID,
|
||||
suite.m365.TenantID,
|
||||
test.scope,
|
||||
dps,
|
||||
func(status *support.ControllerOperationStatus) {},
|
||||
@ -703,8 +683,8 @@ func (suite *BackupIntgSuite) TestMailSerializationRegression() {
|
||||
|
||||
var (
|
||||
wg sync.WaitGroup
|
||||
users = []string{suite.user}
|
||||
handlers = BackupHandlers(suite.ac)
|
||||
users = []string{suite.m365.User.ID}
|
||||
handlers = BackupHandlers(suite.m365.AC)
|
||||
)
|
||||
|
||||
sel := selectors.NewExchangeBackup(users)
|
||||
@ -713,7 +693,7 @@ func (suite *BackupIntgSuite) TestMailSerializationRegression() {
|
||||
bpc := inject.BackupProducerConfig{
|
||||
LastBackupVersion: version.NoBackup,
|
||||
Options: control.DefaultOptions(),
|
||||
ProtectedResource: inMock.NewProvider(suite.user, suite.user),
|
||||
ProtectedResource: suite.m365.User.Provider,
|
||||
Selector: sel.Selector,
|
||||
}
|
||||
|
||||
@ -721,7 +701,7 @@ func (suite *BackupIntgSuite) TestMailSerializationRegression() {
|
||||
ctx,
|
||||
bpc,
|
||||
handlers,
|
||||
suite.tenantID,
|
||||
suite.m365.TenantID,
|
||||
sel.Scopes()[0],
|
||||
metadata.DeltaPaths{},
|
||||
newStatusUpdater(t, &wg),
|
||||
@ -773,8 +753,8 @@ func (suite *BackupIntgSuite) TestMailSerializationRegression() {
|
||||
// a regression test to ensure that downloaded items can be uploaded.
|
||||
func (suite *BackupIntgSuite) TestContactSerializationRegression() {
|
||||
var (
|
||||
users = []string{suite.user}
|
||||
handlers = BackupHandlers(suite.ac)
|
||||
users = []string{suite.m365.User.ID}
|
||||
handlers = BackupHandlers(suite.m365.AC)
|
||||
)
|
||||
|
||||
tests := []struct {
|
||||
@ -801,14 +781,14 @@ func (suite *BackupIntgSuite) TestContactSerializationRegression() {
|
||||
bpc := inject.BackupProducerConfig{
|
||||
LastBackupVersion: version.NoBackup,
|
||||
Options: control.DefaultOptions(),
|
||||
ProtectedResource: inMock.NewProvider(suite.user, suite.user),
|
||||
ProtectedResource: suite.m365.User.Provider,
|
||||
}
|
||||
|
||||
edcs, err := CreateCollections(
|
||||
ctx,
|
||||
bpc,
|
||||
handlers,
|
||||
suite.tenantID,
|
||||
suite.m365.TenantID,
|
||||
test.scope,
|
||||
metadata.DeltaPaths{},
|
||||
newStatusUpdater(t, &wg),
|
||||
@ -875,8 +855,8 @@ func (suite *BackupIntgSuite) TestContactSerializationRegression() {
|
||||
// to be able to successfully query, download and restore event objects
|
||||
func (suite *BackupIntgSuite) TestEventsSerializationRegression() {
|
||||
var (
|
||||
users = []string{suite.user}
|
||||
handlers = BackupHandlers(suite.ac)
|
||||
users = []string{suite.m365.User.ID}
|
||||
handlers = BackupHandlers(suite.m365.AC)
|
||||
)
|
||||
|
||||
tests := []struct {
|
||||
@ -911,14 +891,14 @@ func (suite *BackupIntgSuite) TestEventsSerializationRegression() {
|
||||
bpc := inject.BackupProducerConfig{
|
||||
LastBackupVersion: version.NoBackup,
|
||||
Options: control.DefaultOptions(),
|
||||
ProtectedResource: inMock.NewProvider(suite.user, suite.user),
|
||||
ProtectedResource: suite.m365.User.Provider,
|
||||
}
|
||||
|
||||
collections, err := CreateCollections(
|
||||
ctx,
|
||||
bpc,
|
||||
handlers,
|
||||
suite.tenantID,
|
||||
suite.m365.TenantID,
|
||||
test.scope,
|
||||
metadata.DeltaPaths{},
|
||||
newStatusUpdater(t, &wg),
|
||||
|
||||
@ -12,6 +12,7 @@ import (
|
||||
|
||||
"github.com/alcionai/corso/src/internal/m365/service/exchange/mock"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/internal/tester/its"
|
||||
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
||||
"github.com/alcionai/corso/src/pkg/control"
|
||||
"github.com/alcionai/corso/src/pkg/control/testdata"
|
||||
@ -54,7 +55,7 @@ func (m *contactRestoreMock) DeleteItem(
|
||||
|
||||
type ContactsRestoreIntgSuite struct {
|
||||
tester.Suite
|
||||
its intgTesterSetup
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestContactsRestoreIntgSuite(t *testing.T) {
|
||||
@ -66,17 +67,17 @@ func TestContactsRestoreIntgSuite(t *testing.T) {
|
||||
}
|
||||
|
||||
func (suite *ContactsRestoreIntgSuite) SetupSuite() {
|
||||
suite.its = newIntegrationTesterSetup(suite.T())
|
||||
suite.m365 = its.GetM365(suite.T())
|
||||
}
|
||||
|
||||
// Testing to ensure that cache system works for in multiple different environments
|
||||
func (suite *ContactsRestoreIntgSuite) TestCreateContainerDestination() {
|
||||
runCreateDestinationTest(
|
||||
suite.T(),
|
||||
newContactRestoreHandler(suite.its.ac),
|
||||
newContactRestoreHandler(suite.m365.AC),
|
||||
path.ContactsCategory,
|
||||
suite.its.creds.AzureTenantID,
|
||||
suite.its.userID,
|
||||
suite.m365.TenantID,
|
||||
suite.m365.User.ID,
|
||||
testdata.DefaultRestoreConfig("").Location,
|
||||
[]string{"Hufflepuff"},
|
||||
[]string{"Ravenclaw"})
|
||||
@ -207,17 +208,16 @@ func (suite *ContactsRestoreIntgSuite) TestRestoreContact() {
|
||||
for _, test := range table {
|
||||
suite.Run(test.name, func() {
|
||||
t := suite.T()
|
||||
ctr := count.New()
|
||||
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
ctr := count.New()
|
||||
|
||||
_, err := restoreContact(
|
||||
ctx,
|
||||
test.apiMock,
|
||||
body,
|
||||
suite.its.userID,
|
||||
suite.m365.User.ID,
|
||||
"destination",
|
||||
test.collisionMap,
|
||||
test.onCollision,
|
||||
|
||||
@ -16,10 +16,8 @@ import (
|
||||
|
||||
"github.com/alcionai/corso/src/internal/common/ptr"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/internal/tester/its"
|
||||
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
||||
"github.com/alcionai/corso/src/pkg/account"
|
||||
"github.com/alcionai/corso/src/pkg/control"
|
||||
"github.com/alcionai/corso/src/pkg/count"
|
||||
"github.com/alcionai/corso/src/pkg/errs/core"
|
||||
"github.com/alcionai/corso/src/pkg/fault"
|
||||
"github.com/alcionai/corso/src/pkg/path"
|
||||
@ -1019,49 +1017,37 @@ func (suite *ConfiguredFolderCacheUnitSuite) TestAddToCache() {
|
||||
assert.Equal(t, m.expectedLocation, l.String(), "location path")
|
||||
}
|
||||
|
||||
type ContainerResolverSuite struct {
|
||||
type ContainerResolverIntgSuite struct {
|
||||
tester.Suite
|
||||
credentials account.M365Config
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestContainerResolverIntegrationSuite(t *testing.T) {
|
||||
suite.Run(t, &ContainerResolverSuite{
|
||||
func TestContainerResolverIntgSuite(t *testing.T) {
|
||||
suite.Run(t, &ContainerResolverIntgSuite{
|
||||
Suite: tester.NewIntegrationSuite(
|
||||
t,
|
||||
[][]string{tconfig.M365AcctCredEnvs}),
|
||||
})
|
||||
}
|
||||
|
||||
func (suite *ContainerResolverSuite) SetupSuite() {
|
||||
t := suite.T()
|
||||
|
||||
a := tconfig.NewM365Account(t)
|
||||
m365, err := a.M365Config()
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
suite.credentials = m365
|
||||
func (suite *ContainerResolverIntgSuite) SetupSuite() {
|
||||
suite.m365 = its.GetM365(suite.T())
|
||||
}
|
||||
|
||||
func (suite *ContainerResolverSuite) TestPopulate() {
|
||||
ac, err := api.NewClient(
|
||||
suite.credentials,
|
||||
control.DefaultOptions(),
|
||||
count.New())
|
||||
require.NoError(suite.T(), err, clues.ToCore(err))
|
||||
|
||||
func (suite *ContainerResolverIntgSuite) TestPopulate() {
|
||||
eventFunc := func(t *testing.T) graph.ContainerResolver {
|
||||
return &eventContainerCache{
|
||||
userID: tconfig.M365UserID(t),
|
||||
enumer: ac.Events(),
|
||||
getter: ac.Events(),
|
||||
enumer: suite.m365.AC.Events(),
|
||||
getter: suite.m365.AC.Events(),
|
||||
}
|
||||
}
|
||||
|
||||
contactFunc := func(t *testing.T) graph.ContainerResolver {
|
||||
return &contactContainerCache{
|
||||
userID: tconfig.M365UserID(t),
|
||||
enumer: ac.Contacts(),
|
||||
getter: ac.Contacts(),
|
||||
enumer: suite.m365.AC.Contacts(),
|
||||
getter: suite.m365.AC.Contacts(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -13,6 +13,7 @@ import (
|
||||
|
||||
"github.com/alcionai/corso/src/internal/m365/service/exchange/mock"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/internal/tester/its"
|
||||
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
||||
"github.com/alcionai/corso/src/pkg/control"
|
||||
"github.com/alcionai/corso/src/pkg/control/testdata"
|
||||
@ -101,7 +102,7 @@ func (m *eventRestoreMock) PatchItem(
|
||||
|
||||
type EventsRestoreIntgSuite struct {
|
||||
tester.Suite
|
||||
its intgTesterSetup
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestEventsRestoreIntgSuite(t *testing.T) {
|
||||
@ -113,17 +114,17 @@ func TestEventsRestoreIntgSuite(t *testing.T) {
|
||||
}
|
||||
|
||||
func (suite *EventsRestoreIntgSuite) SetupSuite() {
|
||||
suite.its = newIntegrationTesterSetup(suite.T())
|
||||
suite.m365 = its.GetM365(suite.T())
|
||||
}
|
||||
|
||||
// Testing to ensure that cache system works for in multiple different environments
|
||||
func (suite *EventsRestoreIntgSuite) TestCreateContainerDestination() {
|
||||
runCreateDestinationTest(
|
||||
suite.T(),
|
||||
newEventRestoreHandler(suite.its.ac),
|
||||
newEventRestoreHandler(suite.m365.AC),
|
||||
path.EventsCategory,
|
||||
suite.its.creds.AzureTenantID,
|
||||
suite.its.userID,
|
||||
suite.m365.TenantID,
|
||||
suite.m365.User.ID,
|
||||
testdata.DefaultRestoreConfig("").Location,
|
||||
[]string{"Durmstrang"},
|
||||
[]string{"Beauxbatons"})
|
||||
@ -264,7 +265,7 @@ func (suite *EventsRestoreIntgSuite) TestRestoreEvent() {
|
||||
ctx,
|
||||
test.apiMock,
|
||||
body,
|
||||
suite.its.userID,
|
||||
suite.m365.User.ID,
|
||||
"destination",
|
||||
test.collisionMap,
|
||||
test.onCollision,
|
||||
|
||||
@ -1,44 +0,0 @@
|
||||
package exchange
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/alcionai/clues"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
||||
"github.com/alcionai/corso/src/pkg/account"
|
||||
"github.com/alcionai/corso/src/pkg/control"
|
||||
"github.com/alcionai/corso/src/pkg/count"
|
||||
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
||||
)
|
||||
|
||||
type intgTesterSetup struct {
|
||||
ac api.Client
|
||||
creds account.M365Config
|
||||
userID string
|
||||
}
|
||||
|
||||
func newIntegrationTesterSetup(t *testing.T) intgTesterSetup {
|
||||
its := intgTesterSetup{}
|
||||
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
a := tconfig.NewM365Account(t)
|
||||
creds, err := a.M365Config()
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
its.creds = creds
|
||||
|
||||
its.ac, err = api.NewClient(
|
||||
creds,
|
||||
control.DefaultOptions(),
|
||||
count.New())
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
its.userID = tconfig.GetM365UserID(ctx)
|
||||
|
||||
return its
|
||||
}
|
||||
@ -10,10 +10,8 @@ import (
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/internal/tester/its"
|
||||
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
||||
"github.com/alcionai/corso/src/pkg/account"
|
||||
"github.com/alcionai/corso/src/pkg/control"
|
||||
"github.com/alcionai/corso/src/pkg/count"
|
||||
"github.com/alcionai/corso/src/pkg/fault"
|
||||
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
||||
)
|
||||
@ -30,30 +28,24 @@ const (
|
||||
expectedFolderPath = "toplevel/subFolder/subsubfolder"
|
||||
)
|
||||
|
||||
type MailFolderCacheIntegrationSuite struct {
|
||||
type MailFolderCacheIntgSuite struct {
|
||||
tester.Suite
|
||||
credentials account.M365Config
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestMailFolderCacheIntegrationSuite(t *testing.T) {
|
||||
suite.Run(t, &MailFolderCacheIntegrationSuite{
|
||||
suite.Run(t, &MailFolderCacheIntgSuite{
|
||||
Suite: tester.NewIntegrationSuite(
|
||||
t,
|
||||
[][]string{tconfig.M365AcctCredEnvs}),
|
||||
})
|
||||
}
|
||||
|
||||
func (suite *MailFolderCacheIntegrationSuite) SetupSuite() {
|
||||
t := suite.T()
|
||||
|
||||
a := tconfig.NewM365Account(t)
|
||||
m365, err := a.M365Config()
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
suite.credentials = m365
|
||||
func (suite *MailFolderCacheIntgSuite) SetupSuite() {
|
||||
suite.m365 = its.GetM365(suite.T())
|
||||
}
|
||||
|
||||
func (suite *MailFolderCacheIntegrationSuite) TestDeltaFetch() {
|
||||
func (suite *MailFolderCacheIntgSuite) TestDeltaFetch() {
|
||||
suite.T().Skipf("Test depends on hardcoded folder names. Skipping till that is fixed")
|
||||
|
||||
tests := []struct {
|
||||
@ -75,7 +67,6 @@ func (suite *MailFolderCacheIntegrationSuite) TestDeltaFetch() {
|
||||
path: []string{"some", "leading", "path"},
|
||||
},
|
||||
}
|
||||
userID := tconfig.M365UserID(suite.T())
|
||||
|
||||
for _, test := range tests {
|
||||
suite.Run(test.name, func() {
|
||||
@ -84,21 +75,15 @@ func (suite *MailFolderCacheIntegrationSuite) TestDeltaFetch() {
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
ac, err := api.NewClient(
|
||||
suite.credentials,
|
||||
control.DefaultOptions(),
|
||||
count.New())
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
acm := ac.Mail()
|
||||
acm := suite.m365.AC.Mail()
|
||||
|
||||
mfc := mailContainerCache{
|
||||
userID: userID,
|
||||
userID: suite.m365.User.ID,
|
||||
enumer: acm,
|
||||
getter: acm,
|
||||
}
|
||||
|
||||
err = mfc.Populate(ctx, fault.New(true), test.root, test.path...)
|
||||
err := mfc.Populate(ctx, fault.New(true), test.root, test.path...)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
p, l, err := mfc.IDToPath(ctx, testFolderID)
|
||||
|
||||
@ -13,6 +13,7 @@ import (
|
||||
|
||||
"github.com/alcionai/corso/src/internal/m365/service/exchange/mock"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/internal/tester/its"
|
||||
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
||||
"github.com/alcionai/corso/src/pkg/control"
|
||||
"github.com/alcionai/corso/src/pkg/control/testdata"
|
||||
@ -72,7 +73,7 @@ func (m *mailRestoreMock) PostLargeAttachment(
|
||||
|
||||
type MailRestoreIntgSuite struct {
|
||||
tester.Suite
|
||||
its intgTesterSetup
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestMailRestoreIntgSuite(t *testing.T) {
|
||||
@ -84,16 +85,16 @@ func TestMailRestoreIntgSuite(t *testing.T) {
|
||||
}
|
||||
|
||||
func (suite *MailRestoreIntgSuite) SetupSuite() {
|
||||
suite.its = newIntegrationTesterSetup(suite.T())
|
||||
suite.m365 = its.GetM365(suite.T())
|
||||
}
|
||||
|
||||
func (suite *MailRestoreIntgSuite) TestCreateContainerDestination() {
|
||||
runCreateDestinationTest(
|
||||
suite.T(),
|
||||
newMailRestoreHandler(suite.its.ac),
|
||||
newMailRestoreHandler(suite.m365.AC),
|
||||
path.EmailCategory,
|
||||
suite.its.creds.AzureTenantID,
|
||||
suite.its.userID,
|
||||
suite.m365.TenantID,
|
||||
suite.m365.User.ID,
|
||||
testdata.DefaultRestoreConfig("").Location,
|
||||
[]string{"Griffindor", "Croix"},
|
||||
[]string{"Griffindor", "Felicius"})
|
||||
@ -234,7 +235,7 @@ func (suite *MailRestoreIntgSuite) TestRestoreMail() {
|
||||
ctx,
|
||||
test.apiMock,
|
||||
body,
|
||||
suite.its.userID,
|
||||
suite.m365.User.ID,
|
||||
"destination",
|
||||
test.collisionMap,
|
||||
test.onCollision,
|
||||
|
||||
@ -12,8 +12,8 @@ import (
|
||||
"github.com/alcionai/corso/src/internal/common/ptr"
|
||||
exchMock "github.com/alcionai/corso/src/internal/m365/service/exchange/mock"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/internal/tester/its"
|
||||
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
||||
"github.com/alcionai/corso/src/pkg/account"
|
||||
"github.com/alcionai/corso/src/pkg/control"
|
||||
"github.com/alcionai/corso/src/pkg/control/testdata"
|
||||
"github.com/alcionai/corso/src/pkg/count"
|
||||
@ -24,8 +24,7 @@ import (
|
||||
|
||||
type RestoreIntgSuite struct {
|
||||
tester.Suite
|
||||
credentials account.M365Config
|
||||
ac api.Client
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestRestoreIntgSuite(t *testing.T) {
|
||||
@ -37,18 +36,7 @@ func TestRestoreIntgSuite(t *testing.T) {
|
||||
}
|
||||
|
||||
func (suite *RestoreIntgSuite) SetupSuite() {
|
||||
t := suite.T()
|
||||
|
||||
a := tconfig.NewM365Account(t)
|
||||
m365, err := a.M365Config()
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
suite.credentials = m365
|
||||
suite.ac, err = api.NewClient(
|
||||
m365,
|
||||
control.DefaultOptions(),
|
||||
count.New())
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
suite.m365 = its.GetM365(suite.T())
|
||||
}
|
||||
|
||||
// TestRestoreContact ensures contact object can be created, placed into
|
||||
@ -60,26 +48,26 @@ func (suite *RestoreIntgSuite) TestRestoreContact() {
|
||||
defer flush()
|
||||
|
||||
var (
|
||||
userID = tconfig.M365UserID(t)
|
||||
folderName = testdata.DefaultRestoreConfig("contact").Location
|
||||
handler = newContactRestoreHandler(suite.ac)
|
||||
handler = newContactRestoreHandler(suite.m365.AC)
|
||||
)
|
||||
|
||||
aFolder, err := handler.ac.CreateContainer(ctx, userID, "", folderName)
|
||||
aFolder, err := handler.ac.CreateContainer(ctx, suite.m365.User.ID, "", folderName)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
folderID := ptr.Val(aFolder.GetId())
|
||||
|
||||
defer func() {
|
||||
// Remove the folder containing contact prior to exiting test
|
||||
err = suite.ac.Contacts().DeleteContainer(ctx, userID, folderID)
|
||||
err = suite.m365.AC.Contacts().DeleteContainer(ctx, suite.m365.User.ID, folderID)
|
||||
assert.NoError(t, err, clues.ToCore(err))
|
||||
}()
|
||||
|
||||
info, err := handler.restore(
|
||||
ctx,
|
||||
exchMock.ContactBytes("Corso TestContact"),
|
||||
userID, folderID,
|
||||
suite.m365.User.ID,
|
||||
folderID,
|
||||
nil,
|
||||
control.Copy,
|
||||
fault.New(true),
|
||||
@ -97,19 +85,18 @@ func (suite *RestoreIntgSuite) TestRestoreEvent() {
|
||||
defer flush()
|
||||
|
||||
var (
|
||||
userID = tconfig.M365UserID(t)
|
||||
subject = testdata.DefaultRestoreConfig("event").Location
|
||||
handler = newEventRestoreHandler(suite.ac)
|
||||
handler = newEventRestoreHandler(suite.m365.AC)
|
||||
)
|
||||
|
||||
calendar, err := handler.ac.CreateContainer(ctx, userID, "", subject)
|
||||
calendar, err := handler.ac.CreateContainer(ctx, suite.m365.User.ID, "", subject)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
calendarID := ptr.Val(calendar.GetId())
|
||||
|
||||
defer func() {
|
||||
// Removes calendar containing events created during the test
|
||||
err = suite.ac.Events().DeleteContainer(ctx, userID, calendarID)
|
||||
err = suite.m365.AC.Events().DeleteContainer(ctx, suite.m365.User.ID, calendarID)
|
||||
assert.NoError(t, err, clues.ToCore(err))
|
||||
}()
|
||||
|
||||
@ -154,7 +141,8 @@ func (suite *RestoreIntgSuite) TestRestoreEvent() {
|
||||
info, err := handler.restore(
|
||||
ctx,
|
||||
test.bytes,
|
||||
userID, calendarID,
|
||||
suite.m365.User.ID,
|
||||
calendarID,
|
||||
nil,
|
||||
control.Copy,
|
||||
fault.New(true),
|
||||
@ -168,10 +156,7 @@ func (suite *RestoreIntgSuite) TestRestoreEvent() {
|
||||
// TestRestoreExchangeObject verifies path.Category usage for restored objects
|
||||
func (suite *RestoreIntgSuite) TestRestoreExchangeObject() {
|
||||
t := suite.T()
|
||||
|
||||
handlers := RestoreHandlers(suite.ac)
|
||||
|
||||
userID := tconfig.M365UserID(suite.T())
|
||||
handlers := RestoreHandlers(suite.m365.AC)
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
@ -186,7 +171,7 @@ func (suite *RestoreIntgSuite) TestRestoreExchangeObject() {
|
||||
destination: func(t *testing.T, ctx context.Context) string {
|
||||
folderName := testdata.DefaultRestoreConfig("mailobj").Location
|
||||
folder, err := handlers[path.EmailCategory].
|
||||
CreateContainer(ctx, userID, "", folderName)
|
||||
CreateContainer(ctx, suite.m365.User.ID, "", folderName)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
return ptr.Val(folder.GetId())
|
||||
@ -199,7 +184,7 @@ func (suite *RestoreIntgSuite) TestRestoreExchangeObject() {
|
||||
destination: func(t *testing.T, ctx context.Context) string {
|
||||
folderName := testdata.DefaultRestoreConfig("mailwattch").Location
|
||||
folder, err := handlers[path.EmailCategory].
|
||||
CreateContainer(ctx, userID, "", folderName)
|
||||
CreateContainer(ctx, suite.m365.User.ID, "", folderName)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
return ptr.Val(folder.GetId())
|
||||
@ -212,7 +197,7 @@ func (suite *RestoreIntgSuite) TestRestoreExchangeObject() {
|
||||
destination: func(t *testing.T, ctx context.Context) string {
|
||||
folderName := testdata.DefaultRestoreConfig("eventwattch").Location
|
||||
folder, err := handlers[path.EmailCategory].
|
||||
CreateContainer(ctx, userID, "", folderName)
|
||||
CreateContainer(ctx, suite.m365.User.ID, "", folderName)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
return ptr.Val(folder.GetId())
|
||||
@ -225,7 +210,7 @@ func (suite *RestoreIntgSuite) TestRestoreExchangeObject() {
|
||||
destination: func(t *testing.T, ctx context.Context) string {
|
||||
folderName := testdata.DefaultRestoreConfig("mailitemattch").Location
|
||||
folder, err := handlers[path.EmailCategory].
|
||||
CreateContainer(ctx, userID, "", folderName)
|
||||
CreateContainer(ctx, suite.m365.User.ID, "", folderName)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
return ptr.Val(folder.GetId())
|
||||
@ -240,7 +225,7 @@ func (suite *RestoreIntgSuite) TestRestoreExchangeObject() {
|
||||
destination: func(t *testing.T, ctx context.Context) string {
|
||||
folderName := testdata.DefaultRestoreConfig("mailbasicattch").Location
|
||||
folder, err := handlers[path.EmailCategory].
|
||||
CreateContainer(ctx, userID, "", folderName)
|
||||
CreateContainer(ctx, suite.m365.User.ID, "", folderName)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
return ptr.Val(folder.GetId())
|
||||
@ -255,7 +240,7 @@ func (suite *RestoreIntgSuite) TestRestoreExchangeObject() {
|
||||
destination: func(t *testing.T, ctx context.Context) string {
|
||||
folderName := testdata.DefaultRestoreConfig("mailnestattch").Location
|
||||
folder, err := handlers[path.EmailCategory].
|
||||
CreateContainer(ctx, userID, "", folderName)
|
||||
CreateContainer(ctx, suite.m365.User.ID, "", folderName)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
return ptr.Val(folder.GetId())
|
||||
@ -270,7 +255,7 @@ func (suite *RestoreIntgSuite) TestRestoreExchangeObject() {
|
||||
destination: func(t *testing.T, ctx context.Context) string {
|
||||
folderName := testdata.DefaultRestoreConfig("mailcontactattch").Location
|
||||
folder, err := handlers[path.EmailCategory].
|
||||
CreateContainer(ctx, userID, "", folderName)
|
||||
CreateContainer(ctx, suite.m365.User.ID, "", folderName)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
return ptr.Val(folder.GetId())
|
||||
@ -283,7 +268,7 @@ func (suite *RestoreIntgSuite) TestRestoreExchangeObject() {
|
||||
destination: func(t *testing.T, ctx context.Context) string {
|
||||
folderName := testdata.DefaultRestoreConfig("nestedattch").Location
|
||||
folder, err := handlers[path.EmailCategory].
|
||||
CreateContainer(ctx, userID, "", folderName)
|
||||
CreateContainer(ctx, suite.m365.User.ID, "", folderName)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
return ptr.Val(folder.GetId())
|
||||
@ -296,7 +281,7 @@ func (suite *RestoreIntgSuite) TestRestoreExchangeObject() {
|
||||
destination: func(t *testing.T, ctx context.Context) string {
|
||||
folderName := testdata.DefaultRestoreConfig("maillargeattch").Location
|
||||
folder, err := handlers[path.EmailCategory].
|
||||
CreateContainer(ctx, userID, "", folderName)
|
||||
CreateContainer(ctx, suite.m365.User.ID, "", folderName)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
return ptr.Val(folder.GetId())
|
||||
@ -309,7 +294,7 @@ func (suite *RestoreIntgSuite) TestRestoreExchangeObject() {
|
||||
destination: func(t *testing.T, ctx context.Context) string {
|
||||
folderName := testdata.DefaultRestoreConfig("mailtwoattch").Location
|
||||
folder, err := handlers[path.EmailCategory].
|
||||
CreateContainer(ctx, userID, "", folderName)
|
||||
CreateContainer(ctx, suite.m365.User.ID, "", folderName)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
return ptr.Val(folder.GetId())
|
||||
@ -322,7 +307,7 @@ func (suite *RestoreIntgSuite) TestRestoreExchangeObject() {
|
||||
destination: func(t *testing.T, ctx context.Context) string {
|
||||
folderName := testdata.DefaultRestoreConfig("mailrefattch").Location
|
||||
folder, err := handlers[path.EmailCategory].
|
||||
CreateContainer(ctx, userID, "", folderName)
|
||||
CreateContainer(ctx, suite.m365.User.ID, "", folderName)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
return ptr.Val(folder.GetId())
|
||||
@ -335,7 +320,7 @@ func (suite *RestoreIntgSuite) TestRestoreExchangeObject() {
|
||||
destination: func(t *testing.T, ctx context.Context) string {
|
||||
folderName := testdata.DefaultRestoreConfig("contact").Location
|
||||
folder, err := handlers[path.ContactsCategory].
|
||||
CreateContainer(ctx, userID, "", folderName)
|
||||
CreateContainer(ctx, suite.m365.User.ID, "", folderName)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
return ptr.Val(folder.GetId())
|
||||
@ -348,7 +333,7 @@ func (suite *RestoreIntgSuite) TestRestoreExchangeObject() {
|
||||
destination: func(t *testing.T, ctx context.Context) string {
|
||||
folderName := testdata.DefaultRestoreConfig("event").Location
|
||||
calendar, err := handlers[path.EventsCategory].
|
||||
CreateContainer(ctx, userID, "", folderName)
|
||||
CreateContainer(ctx, suite.m365.User.ID, "", folderName)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
return ptr.Val(calendar.GetId())
|
||||
@ -361,7 +346,7 @@ func (suite *RestoreIntgSuite) TestRestoreExchangeObject() {
|
||||
destination: func(t *testing.T, ctx context.Context) string {
|
||||
folderName := testdata.DefaultRestoreConfig("eventobj").Location
|
||||
calendar, err := handlers[path.EventsCategory].
|
||||
CreateContainer(ctx, userID, "", folderName)
|
||||
CreateContainer(ctx, suite.m365.User.ID, "", folderName)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
return ptr.Val(calendar.GetId())
|
||||
@ -380,7 +365,8 @@ func (suite *RestoreIntgSuite) TestRestoreExchangeObject() {
|
||||
info, err := handlers[test.category].restore(
|
||||
ctx,
|
||||
test.bytes,
|
||||
userID, destination,
|
||||
suite.m365.User.ID,
|
||||
destination,
|
||||
nil,
|
||||
control.Copy,
|
||||
fault.New(true),
|
||||
@ -400,12 +386,11 @@ func (suite *RestoreIntgSuite) TestRestoreAndBackupEvent_recurringInstancesWithA
|
||||
defer flush()
|
||||
|
||||
var (
|
||||
userID = tconfig.M365UserID(t)
|
||||
subject = testdata.DefaultRestoreConfig("event").Location
|
||||
handler = newEventRestoreHandler(suite.ac)
|
||||
handler = newEventRestoreHandler(suite.m365.AC)
|
||||
)
|
||||
|
||||
calendar, err := handler.ac.CreateContainer(ctx, userID, "", subject)
|
||||
calendar, err := handler.ac.CreateContainer(ctx, suite.m365.User.ID, "", subject)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
calendarID := ptr.Val(calendar.GetId())
|
||||
@ -414,7 +399,8 @@ func (suite *RestoreIntgSuite) TestRestoreAndBackupEvent_recurringInstancesWithA
|
||||
info, err := handler.restore(
|
||||
ctx,
|
||||
bytes,
|
||||
userID, calendarID,
|
||||
suite.m365.User.ID,
|
||||
calendarID,
|
||||
nil,
|
||||
control.Copy,
|
||||
fault.New(true),
|
||||
@ -425,7 +411,7 @@ func (suite *RestoreIntgSuite) TestRestoreAndBackupEvent_recurringInstancesWithA
|
||||
ec, err := handler.ac.Stable.
|
||||
Client().
|
||||
Users().
|
||||
ByUserId(userID).
|
||||
ByUserId(suite.m365.User.ID).
|
||||
Calendars().
|
||||
ByCalendarId(calendarID).
|
||||
Events().
|
||||
@ -435,17 +421,25 @@ func (suite *RestoreIntgSuite) TestRestoreAndBackupEvent_recurringInstancesWithA
|
||||
evts := ec.GetValue()
|
||||
assert.Len(t, evts, 1, "count of events")
|
||||
|
||||
sp, info, err := suite.ac.Events().GetItem(ctx, userID, ptr.Val(evts[0].GetId()), fault.New(true))
|
||||
sp, info, err := suite.m365.AC.Events().GetItem(
|
||||
ctx,
|
||||
suite.m365.User.ID,
|
||||
ptr.Val(evts[0].GetId()),
|
||||
fault.New(true))
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
assert.NotNil(t, info, "event item info")
|
||||
|
||||
body, err := suite.ac.Events().Serialize(ctx, sp, userID, ptr.Val(evts[0].GetId()))
|
||||
body, err := suite.m365.AC.Events().Serialize(
|
||||
ctx,
|
||||
sp,
|
||||
suite.m365.User.ID,
|
||||
ptr.Val(evts[0].GetId()))
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
event, err := api.BytesToEventable(body)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
assert.NotNil(t, event.GetRecurrence(), "recurrence")
|
||||
|
||||
eo := event.GetAdditionalData()["exceptionOccurrences"]
|
||||
assert.NotNil(t, eo, "exceptionOccurrences")
|
||||
|
||||
|
||||
@ -18,6 +18,7 @@ import (
|
||||
"github.com/alcionai/corso/src/internal/m365/support"
|
||||
"github.com/alcionai/corso/src/internal/operations/inject"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/internal/tester/its"
|
||||
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
||||
"github.com/alcionai/corso/src/internal/version"
|
||||
"github.com/alcionai/corso/src/pkg/account"
|
||||
@ -964,9 +965,7 @@ func (suite *BackupUnitSuite) TestPopulateCollections_ConversationsIncremental()
|
||||
|
||||
type BackupIntgSuite struct {
|
||||
tester.Suite
|
||||
resource string
|
||||
tenantID string
|
||||
ac api.Client
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestBackupIntgSuite(t *testing.T) {
|
||||
@ -979,32 +978,19 @@ func TestBackupIntgSuite(t *testing.T) {
|
||||
|
||||
func (suite *BackupIntgSuite) SetupSuite() {
|
||||
t := suite.T()
|
||||
suite.m365 = its.GetM365(t)
|
||||
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
graph.InitializeConcurrencyLimiter(ctx, true, 4)
|
||||
|
||||
suite.resource = tconfig.M365TeamID(t)
|
||||
|
||||
acct := tconfig.NewM365Account(t)
|
||||
creds, err := acct.M365Config()
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
suite.ac, err = api.NewClient(
|
||||
creds,
|
||||
control.DefaultOptions(),
|
||||
count.New())
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
suite.tenantID = creds.AzureTenantID
|
||||
}
|
||||
|
||||
func (suite *BackupIntgSuite) TestCreateCollections() {
|
||||
var (
|
||||
protectedResource = tconfig.M365TeamID(suite.T())
|
||||
resources = []string{protectedResource}
|
||||
handler = NewChannelBackupHandler(protectedResource, suite.ac.Channels())
|
||||
protectedResource = suite.m365.Group.ID
|
||||
resources = []string{suite.m365.Group.ID}
|
||||
handler = NewChannelBackupHandler(protectedResource, suite.m365.AC.Channels())
|
||||
)
|
||||
|
||||
tests := []struct {
|
||||
@ -1030,13 +1016,13 @@ func (suite *BackupIntgSuite) TestCreateCollections() {
|
||||
|
||||
ctrlOpts := control.DefaultOptions()
|
||||
|
||||
sel := selectors.NewGroupsBackup([]string{protectedResource})
|
||||
sel := selectors.NewGroupsBackup([]string{suite.m365.Group.ID})
|
||||
sel.Include(selTD.GroupsBackupChannelScope(sel))
|
||||
|
||||
bpc := inject.BackupProducerConfig{
|
||||
LastBackupVersion: version.NoBackup,
|
||||
Options: ctrlOpts,
|
||||
ProtectedResource: inMock.NewProvider(protectedResource, protectedResource),
|
||||
ProtectedResource: suite.m365.Group.Provider,
|
||||
Selector: sel.Selector,
|
||||
}
|
||||
|
||||
@ -1044,7 +1030,7 @@ func (suite *BackupIntgSuite) TestCreateCollections() {
|
||||
ctx,
|
||||
bpc,
|
||||
handler,
|
||||
suite.tenantID,
|
||||
suite.m365.TenantID,
|
||||
test.scope,
|
||||
func(status *support.ControllerOperationStatus) {},
|
||||
false,
|
||||
|
||||
@ -18,6 +18,7 @@ import (
|
||||
"github.com/alcionai/corso/src/internal/m365/support"
|
||||
"github.com/alcionai/corso/src/internal/operations/inject"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/internal/tester/its"
|
||||
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
||||
"github.com/alcionai/corso/src/internal/version"
|
||||
"github.com/alcionai/corso/src/pkg/account"
|
||||
@ -328,59 +329,49 @@ func (suite *SharePointBackupUnitSuite) TestPopulateListsCollections_incremental
|
||||
}
|
||||
}
|
||||
|
||||
type SharePointSuite struct {
|
||||
type SharePointBackupIntgSuite struct {
|
||||
tester.Suite
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestSharePointSuite(t *testing.T) {
|
||||
suite.Run(t, &SharePointSuite{
|
||||
suite.Run(t, &SharePointBackupIntgSuite{
|
||||
Suite: tester.NewIntegrationSuite(
|
||||
t,
|
||||
[][]string{tconfig.M365AcctCredEnvs}),
|
||||
})
|
||||
}
|
||||
|
||||
func (suite *SharePointSuite) SetupSuite() {
|
||||
ctx, flush := tester.NewContext(suite.T())
|
||||
func (suite *SharePointBackupIntgSuite) SetupSuite() {
|
||||
t := suite.T()
|
||||
suite.m365 = its.GetM365(t)
|
||||
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
graph.InitializeConcurrencyLimiter(ctx, false, 4)
|
||||
}
|
||||
|
||||
func (suite *SharePointSuite) TestCollectPages() {
|
||||
func (suite *SharePointBackupIntgSuite) TestCollectPages() {
|
||||
t := suite.T()
|
||||
counter := count.New()
|
||||
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
var (
|
||||
siteID = tconfig.M365SiteID(t)
|
||||
a = tconfig.NewM365Account(t)
|
||||
counter = count.New()
|
||||
)
|
||||
|
||||
creds, err := a.M365Config()
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
ac, err := api.NewClient(
|
||||
creds,
|
||||
control.DefaultOptions(),
|
||||
counter)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
bpc := inject.BackupProducerConfig{
|
||||
LastBackupVersion: version.NoBackup,
|
||||
Options: control.DefaultOptions(),
|
||||
ProtectedResource: mock.NewProvider(siteID, siteID),
|
||||
ProtectedResource: suite.m365.Site.Provider,
|
||||
}
|
||||
|
||||
sel := selectors.NewSharePointBackup([]string{siteID})
|
||||
sel := selectors.NewSharePointBackup([]string{suite.m365.Site.ID})
|
||||
|
||||
col, err := CollectPages(
|
||||
ctx,
|
||||
bpc,
|
||||
creds,
|
||||
ac,
|
||||
suite.m365.Creds,
|
||||
suite.m365.AC,
|
||||
sel.Lists(selectors.Any())[0],
|
||||
(&MockGraphService{}).UpdateStatus,
|
||||
counter,
|
||||
@ -389,43 +380,27 @@ func (suite *SharePointSuite) TestCollectPages() {
|
||||
assert.NotEmpty(t, col)
|
||||
}
|
||||
|
||||
func (suite *SharePointSuite) TestCollectLists() {
|
||||
func (suite *SharePointBackupIntgSuite) TestCollectLists() {
|
||||
t := suite.T()
|
||||
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
var (
|
||||
siteID = tconfig.M365SiteID(t)
|
||||
a = tconfig.NewM365Account(t)
|
||||
counter = count.New()
|
||||
)
|
||||
|
||||
creds, err := a.M365Config()
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
ac, err := api.NewClient(
|
||||
creds,
|
||||
control.DefaultOptions(),
|
||||
counter)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
bpc := inject.BackupProducerConfig{
|
||||
LastBackupVersion: version.NoBackup,
|
||||
Options: control.DefaultOptions(),
|
||||
ProtectedResource: mock.NewProvider(siteID, siteID),
|
||||
ProtectedResource: suite.m365.Site.Provider,
|
||||
}
|
||||
|
||||
sel := selectors.NewSharePointBackup([]string{siteID})
|
||||
|
||||
bh := NewListsBackupHandler(bpc.ProtectedResource.ID(), ac.Lists())
|
||||
sel := selectors.NewSharePointBackup([]string{suite.m365.Site.ID})
|
||||
bh := NewListsBackupHandler(suite.m365.Site.ID, suite.m365.AC.Lists())
|
||||
|
||||
col, _, err := CollectLists(
|
||||
ctx,
|
||||
bh,
|
||||
bpc,
|
||||
ac,
|
||||
creds.AzureTenantID,
|
||||
suite.m365.AC,
|
||||
suite.m365.Creds.AzureTenantID,
|
||||
sel.Lists(selectors.Any())[0],
|
||||
(&MockGraphService{}).UpdateStatus,
|
||||
count.New(),
|
||||
@ -445,7 +420,7 @@ func (suite *SharePointSuite) TestCollectLists() {
|
||||
assert.True(t, metadataFound)
|
||||
}
|
||||
|
||||
func (suite *SharePointSuite) TestParseListsMetadataCollections() {
|
||||
func (suite *SharePointBackupIntgSuite) TestParseListsMetadataCollections() {
|
||||
type fileValues struct {
|
||||
fileName string
|
||||
value string
|
||||
@ -580,7 +555,7 @@ func (f failingColl) FetchItemByName(context.Context, string) (data.Item, error)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (suite *SharePointSuite) TestParseListsMetadataCollections_ReadFailure() {
|
||||
func (suite *SharePointBackupIntgSuite) TestParseListsMetadataCollections_ReadFailure() {
|
||||
t := suite.T()
|
||||
|
||||
ctx, flush := tester.NewContext(t)
|
||||
|
||||
@ -20,6 +20,7 @@ import (
|
||||
spMock "github.com/alcionai/corso/src/internal/m365/service/sharepoint/mock"
|
||||
"github.com/alcionai/corso/src/internal/m365/support"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/internal/tester/its"
|
||||
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
||||
"github.com/alcionai/corso/src/pkg/account"
|
||||
"github.com/alcionai/corso/src/pkg/backup/details"
|
||||
@ -113,34 +114,17 @@ func (suite *SharePointCollectionUnitSuite) TestPrefetchCollection_state() {
|
||||
}
|
||||
}
|
||||
|
||||
type SharePointCollectionSuite struct {
|
||||
type SharePointCollIntgSuite struct {
|
||||
tester.Suite
|
||||
siteID string
|
||||
creds account.M365Config
|
||||
ac api.Client
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func (suite *SharePointCollectionSuite) SetupSuite() {
|
||||
t := suite.T()
|
||||
|
||||
suite.siteID = tconfig.M365SiteID(t)
|
||||
a := tconfig.NewM365Account(t)
|
||||
m365, err := a.M365Config()
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
suite.creds = m365
|
||||
|
||||
ac, err := api.NewClient(
|
||||
m365,
|
||||
control.DefaultOptions(),
|
||||
count.New())
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
suite.ac = ac
|
||||
func (suite *SharePointCollIntgSuite) SetupSuite() {
|
||||
suite.m365 = its.GetM365(suite.T())
|
||||
}
|
||||
|
||||
func TestSharePointCollectionSuite(t *testing.T) {
|
||||
suite.Run(t, &SharePointCollectionSuite{
|
||||
suite.Run(t, &SharePointCollIntgSuite{
|
||||
Suite: tester.NewIntegrationSuite(
|
||||
t,
|
||||
[][]string{tconfig.M365AcctCredEnvs}),
|
||||
@ -149,15 +133,13 @@ func TestSharePointCollectionSuite(t *testing.T) {
|
||||
|
||||
// TestListCollection tests basic functionality to create
|
||||
// SharePoint collection and to use the data stream channel.
|
||||
func (suite *SharePointCollectionSuite) TestPrefetchCollection_Items() {
|
||||
func (suite *SharePointCollIntgSuite) TestPrefetchCollection_Items() {
|
||||
var (
|
||||
tenant = "some"
|
||||
user = "user"
|
||||
prevRoot = "prev"
|
||||
dirRoot = "directory"
|
||||
)
|
||||
|
||||
sel := selectors.NewSharePointBackup([]string{"site"})
|
||||
sel := selectors.NewSharePointBackup([]string{suite.m365.Site.ID})
|
||||
|
||||
tables := []struct {
|
||||
name, itemName string
|
||||
@ -183,8 +165,8 @@ func (suite *SharePointCollectionSuite) TestPrefetchCollection_Items() {
|
||||
getter: &mock.ListHandler{},
|
||||
getDir: func(t *testing.T, root string) path.Path {
|
||||
dir, err := path.Build(
|
||||
tenant,
|
||||
user,
|
||||
suite.m365.TenantID,
|
||||
suite.m365.User.ID,
|
||||
path.SharePointService,
|
||||
path.ListsCategory,
|
||||
false,
|
||||
@ -232,8 +214,8 @@ func (suite *SharePointCollectionSuite) TestPrefetchCollection_Items() {
|
||||
getter: nil,
|
||||
getDir: func(t *testing.T, root string) path.Path {
|
||||
dir, err := path.Build(
|
||||
tenant,
|
||||
user,
|
||||
suite.m365.TenantID,
|
||||
suite.m365.User.ID,
|
||||
path.SharePointService,
|
||||
path.PagesCategory,
|
||||
false,
|
||||
@ -270,7 +252,7 @@ func (suite *SharePointCollectionSuite) TestPrefetchCollection_Items() {
|
||||
test.getDir(t, test.curr),
|
||||
test.getDir(t, test.prev),
|
||||
test.locPb,
|
||||
suite.ac,
|
||||
suite.m365.AC,
|
||||
test.scope,
|
||||
nil,
|
||||
control.DefaultOptions(),
|
||||
@ -306,7 +288,7 @@ func (suite *SharePointCollectionSuite) TestPrefetchCollection_Items() {
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *SharePointCollectionSuite) TestLazyCollection_Items() {
|
||||
func (suite *SharePointCollIntgSuite) TestLazyCollection_Items() {
|
||||
var (
|
||||
t = suite.T()
|
||||
errs = fault.New(true)
|
||||
@ -416,7 +398,7 @@ func (suite *SharePointCollectionSuite) TestLazyCollection_Items() {
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *SharePointCollectionSuite) TestLazyItem() {
|
||||
func (suite *SharePointCollIntgSuite) TestLazyItem() {
|
||||
var (
|
||||
t = suite.T()
|
||||
now = time.Now()
|
||||
@ -460,7 +442,7 @@ func (suite *SharePointCollectionSuite) TestLazyItem() {
|
||||
assert.Equal(t, now, info.Modified())
|
||||
}
|
||||
|
||||
func (suite *SharePointCollectionSuite) TestLazyItem_ReturnsEmptyReaderOnDeletedInFlight() {
|
||||
func (suite *SharePointCollIntgSuite) TestLazyItem_ReturnsEmptyReaderOnDeletedInFlight() {
|
||||
var (
|
||||
t = suite.T()
|
||||
now = time.Now()
|
||||
|
||||
@ -21,8 +21,8 @@ import (
|
||||
siteMock "github.com/alcionai/corso/src/internal/m365/collection/site/mock"
|
||||
spMock "github.com/alcionai/corso/src/internal/m365/service/sharepoint/mock"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/internal/tester/its"
|
||||
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
||||
"github.com/alcionai/corso/src/pkg/account"
|
||||
"github.com/alcionai/corso/src/pkg/backup/details"
|
||||
"github.com/alcionai/corso/src/pkg/control"
|
||||
"github.com/alcionai/corso/src/pkg/control/testdata"
|
||||
@ -87,32 +87,17 @@ func (suite *SharePointCollectionUnitSuite) TestFormatListsRestoreDestination()
|
||||
|
||||
type SharePointRestoreSuite struct {
|
||||
tester.Suite
|
||||
siteID string
|
||||
creds account.M365Config
|
||||
ac api.Client
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func (suite *SharePointRestoreSuite) SetupSuite() {
|
||||
t := suite.T()
|
||||
suite.m365 = its.GetM365(t)
|
||||
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
graph.InitializeConcurrencyLimiter(ctx, false, 4)
|
||||
|
||||
suite.siteID = tconfig.M365SiteID(t)
|
||||
a := tconfig.NewM365Account(t)
|
||||
m365, err := a.M365Config()
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
suite.creds = m365
|
||||
|
||||
ac, err := api.NewClient(
|
||||
m365,
|
||||
control.DefaultOptions(),
|
||||
count.New())
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
suite.ac = ac
|
||||
}
|
||||
|
||||
func TestSharePointRestoreSuite(t *testing.T) {
|
||||
@ -135,8 +120,8 @@ func (suite *SharePointRestoreSuite) TestListCollection_Restore() {
|
||||
listTemplate = "genericList"
|
||||
restoreCfg = testdata.DefaultRestoreConfig("")
|
||||
destName = restoreCfg.Location
|
||||
lrh = NewListsRestoreHandler(suite.siteID, suite.ac.Lists())
|
||||
service = createTestService(t, suite.creds)
|
||||
lrh = NewListsRestoreHandler(suite.m365.Site.ID, suite.m365.AC.Lists())
|
||||
service = createTestService(t, suite.m365.Creds)
|
||||
list = stubList(listTemplate, listName)
|
||||
mockData = generateListData(t, service, list)
|
||||
)
|
||||
@ -147,7 +132,7 @@ func (suite *SharePointRestoreSuite) TestListCollection_Restore() {
|
||||
ctx,
|
||||
lrh,
|
||||
mockData,
|
||||
suite.siteID,
|
||||
suite.m365.Site.ID,
|
||||
restoreCfg,
|
||||
nil,
|
||||
count.New(),
|
||||
@ -156,7 +141,7 @@ func (suite *SharePointRestoreSuite) TestListCollection_Restore() {
|
||||
assert.Equal(t, fmt.Sprintf("%s_%s", destName, listName), deets.SharePoint.List.Name)
|
||||
|
||||
// Clean-Up
|
||||
deleteList(ctx, t, suite.siteID, lrh, deets)
|
||||
deleteList(ctx, t, suite.m365.Site.ID, lrh, deets)
|
||||
}
|
||||
|
||||
func (suite *SharePointRestoreSuite) TestListCollection_Restore_invalidListTemplate() {
|
||||
@ -166,10 +151,10 @@ func (suite *SharePointRestoreSuite) TestListCollection_Restore_invalidListTempl
|
||||
defer flush()
|
||||
|
||||
var (
|
||||
lrh = NewListsRestoreHandler(suite.siteID, suite.ac.Lists())
|
||||
lrh = NewListsRestoreHandler(suite.m365.Site.ID, suite.m365.AC.Lists())
|
||||
listName = "MockListing"
|
||||
restoreCfg = testdata.DefaultRestoreConfig("")
|
||||
service = createTestService(t, suite.creds)
|
||||
service = createTestService(t, suite.m365.Creds)
|
||||
)
|
||||
|
||||
restoreCfg.OnCollision = control.Copy
|
||||
@ -201,7 +186,7 @@ func (suite *SharePointRestoreSuite) TestListCollection_Restore_invalidListTempl
|
||||
ctx,
|
||||
lrh,
|
||||
listData,
|
||||
suite.siteID,
|
||||
suite.m365.Site.ID,
|
||||
restoreCfg,
|
||||
nil,
|
||||
count.New(),
|
||||
@ -222,8 +207,8 @@ func (suite *SharePointRestoreSuite) TestListCollection_RestoreInPlace_skip() {
|
||||
listName = "MockListing"
|
||||
listTemplate = "genericList"
|
||||
restoreCfg = testdata.DefaultRestoreConfig("")
|
||||
lrh = NewListsRestoreHandler(suite.siteID, suite.ac.Lists())
|
||||
service = createTestService(t, suite.creds)
|
||||
lrh = NewListsRestoreHandler(suite.m365.Site.ID, suite.m365.AC.Lists())
|
||||
service = createTestService(t, suite.m365.Creds)
|
||||
list = stubList(listTemplate, listName)
|
||||
newList = stubList(listTemplate, listName)
|
||||
cl = count.New()
|
||||
@ -239,7 +224,7 @@ func (suite *SharePointRestoreSuite) TestListCollection_RestoreInPlace_skip() {
|
||||
ctx,
|
||||
lrh,
|
||||
mockData,
|
||||
suite.siteID,
|
||||
suite.m365.Site.ID,
|
||||
restoreCfg, // OnCollision is skip by default
|
||||
collisionKeyToItemID,
|
||||
cl,
|
||||
@ -261,7 +246,7 @@ func (suite *SharePointRestoreSuite) TestListCollection_RestoreInPlace_copy() {
|
||||
listTemplate = "genericList"
|
||||
listID = "some-list-id"
|
||||
restoreCfg = testdata.DefaultRestoreConfig("")
|
||||
service = createTestService(t, suite.creds)
|
||||
service = createTestService(t, suite.m365.Creds)
|
||||
|
||||
policyToKey = map[control.CollisionPolicy]count.Key{
|
||||
control.Replace: count.CollisionReplace,
|
||||
@ -354,7 +339,7 @@ func (suite *SharePointRestoreSuite) TestListCollection_RestoreInPlace_copy() {
|
||||
ctx,
|
||||
test.lrh,
|
||||
mockData,
|
||||
suite.siteID,
|
||||
suite.m365.Site.ID,
|
||||
restoreCfg,
|
||||
collisionKeyToItemID,
|
||||
cl,
|
||||
|
||||
@ -17,6 +17,7 @@ import (
|
||||
"github.com/alcionai/corso/src/internal/m365/support"
|
||||
"github.com/alcionai/corso/src/internal/operations/inject"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/internal/tester/its"
|
||||
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
||||
"github.com/alcionai/corso/src/internal/version"
|
||||
"github.com/alcionai/corso/src/pkg/account"
|
||||
@ -255,9 +256,7 @@ func (suite *BackupUnitSuite) TestPopulateCollections() {
|
||||
|
||||
type BackupIntgSuite struct {
|
||||
tester.Suite
|
||||
resource string
|
||||
tenantID string
|
||||
ac api.Client
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestBackupIntgSuite(t *testing.T) {
|
||||
@ -270,33 +269,20 @@ func TestBackupIntgSuite(t *testing.T) {
|
||||
|
||||
func (suite *BackupIntgSuite) SetupSuite() {
|
||||
t := suite.T()
|
||||
suite.m365 = its.GetM365(t)
|
||||
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
graph.InitializeConcurrencyLimiter(ctx, true, 4)
|
||||
|
||||
suite.resource = tconfig.M365TeamID(t)
|
||||
|
||||
acct := tconfig.NewM365Account(t)
|
||||
creds, err := acct.M365Config()
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
suite.ac, err = api.NewClient(
|
||||
creds,
|
||||
control.DefaultOptions(),
|
||||
count.New())
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
suite.tenantID = creds.AzureTenantID
|
||||
}
|
||||
|
||||
func (suite *BackupIntgSuite) TestCreateCollections() {
|
||||
var (
|
||||
tenant = tconfig.M365TenantID(suite.T())
|
||||
protectedResource = tconfig.M365TeamID(suite.T())
|
||||
tenant = suite.m365.TenantID
|
||||
protectedResource = suite.m365.Group.ID
|
||||
resources = []string{protectedResource}
|
||||
handler = NewUsersChatsBackupHandler(tenant, protectedResource, suite.ac.Chats())
|
||||
handler = NewUsersChatsBackupHandler(tenant, protectedResource, suite.m365.AC.Chats())
|
||||
)
|
||||
|
||||
tests := []struct {
|
||||
@ -322,13 +308,13 @@ func (suite *BackupIntgSuite) TestCreateCollections() {
|
||||
|
||||
ctrlOpts := control.DefaultOptions()
|
||||
|
||||
sel := selectors.NewTeamsChatsBackup([]string{protectedResource})
|
||||
sel := selectors.NewTeamsChatsBackup([]string{suite.m365.Group.ID})
|
||||
sel.Include(selTD.TeamsChatsBackupChatScope(sel))
|
||||
|
||||
bpc := inject.BackupProducerConfig{
|
||||
LastBackupVersion: version.NoBackup,
|
||||
Options: ctrlOpts,
|
||||
ProtectedResource: inMock.NewProvider(protectedResource, protectedResource),
|
||||
ProtectedResource: suite.m365.Group.Provider,
|
||||
Selector: sel.Selector,
|
||||
}
|
||||
|
||||
@ -336,7 +322,7 @@ func (suite *BackupIntgSuite) TestCreateCollections() {
|
||||
ctx,
|
||||
bpc,
|
||||
handler,
|
||||
suite.tenantID,
|
||||
suite.m365.TenantID,
|
||||
test.scope,
|
||||
func(status *support.ControllerOperationStatus) {},
|
||||
false,
|
||||
|
||||
@ -23,6 +23,7 @@ import (
|
||||
"github.com/alcionai/corso/src/internal/m365/support"
|
||||
"github.com/alcionai/corso/src/internal/operations/inject"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/internal/tester/its"
|
||||
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
||||
"github.com/alcionai/corso/src/internal/version"
|
||||
"github.com/alcionai/corso/src/pkg/backup/details"
|
||||
@ -414,8 +415,7 @@ func (suite *ControllerUnitSuite) TestController_CacheItemInfo() {
|
||||
type ControllerIntegrationSuite struct {
|
||||
tester.Suite
|
||||
ctrl *Controller
|
||||
user string
|
||||
secondaryUser string
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestControllerIntegrationSuite(t *testing.T) {
|
||||
@ -428,15 +428,12 @@ func TestControllerIntegrationSuite(t *testing.T) {
|
||||
|
||||
func (suite *ControllerIntegrationSuite) SetupSuite() {
|
||||
t := suite.T()
|
||||
suite.m365 = its.GetM365(t)
|
||||
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
suite.ctrl = newController(ctx, t, path.ExchangeService)
|
||||
suite.user = tconfig.M365UserID(t)
|
||||
suite.secondaryUser = tconfig.SecondaryM365UserID(t)
|
||||
|
||||
tester.LogTimeOfTest(t)
|
||||
}
|
||||
|
||||
func (suite *ControllerIntegrationSuite) TestEmptyCollections() {
|
||||
@ -1064,7 +1061,7 @@ func (suite *ControllerIntegrationSuite) TestRestoreAndBackup_core() {
|
||||
suite.Run(test.name, func() {
|
||||
cfg := stub.ConfigInfo{
|
||||
Tenant: suite.ctrl.tenant,
|
||||
ResourceOwners: []string{suite.user},
|
||||
ResourceOwners: []string{suite.m365.User.ID},
|
||||
Service: test.service,
|
||||
Opts: control.DefaultOptions(),
|
||||
RestoreCfg: control.DefaultRestoreConfig(dttm.SafeForTesting),
|
||||
@ -1143,7 +1140,7 @@ func (suite *ControllerIntegrationSuite) TestMultiFolderBackupDifferentNames() {
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
restoreSel := getSelectorWith(t, test.service, []string{suite.user}, true)
|
||||
restoreSel := getSelectorWith(t, test.service, []string{suite.m365.User.ID}, true)
|
||||
expectedDests := make([]destAndCats, 0, len(test.collections))
|
||||
allItems := 0
|
||||
allExpectedData := map[string]map[string][]byte{}
|
||||
@ -1154,7 +1151,7 @@ func (suite *ControllerIntegrationSuite) TestMultiFolderBackupDifferentNames() {
|
||||
restoreCfg.IncludePermissions = true
|
||||
|
||||
expectedDests = append(expectedDests, destAndCats{
|
||||
resourceOwner: suite.user,
|
||||
resourceOwner: suite.m365.User.ID,
|
||||
dest: restoreCfg.Location,
|
||||
cats: map[path.CategoryType]struct{}{
|
||||
collection.Category: {},
|
||||
@ -1164,7 +1161,7 @@ func (suite *ControllerIntegrationSuite) TestMultiFolderBackupDifferentNames() {
|
||||
totalItems, _, collections, expectedData, err := stub.CollectionsForInfo(
|
||||
test.service,
|
||||
suite.ctrl.tenant,
|
||||
suite.user,
|
||||
suite.m365.User.ID,
|
||||
restoreCfg,
|
||||
[]stub.ColInfo{collection},
|
||||
version.Backup)
|
||||
@ -1289,7 +1286,7 @@ func (suite *ControllerIntegrationSuite) TestRestoreAndBackup_largeMailAttachmen
|
||||
|
||||
cfg := stub.ConfigInfo{
|
||||
Tenant: suite.ctrl.tenant,
|
||||
ResourceOwners: []string{suite.user},
|
||||
ResourceOwners: []string{suite.m365.User.ID},
|
||||
Service: test.service,
|
||||
Opts: control.DefaultOptions(),
|
||||
RestoreCfg: restoreCfg,
|
||||
@ -1310,7 +1307,7 @@ func (suite *ControllerIntegrationSuite) TestProduceBackupCollections_createsPre
|
||||
name: "Exchange",
|
||||
resourceCat: resource.Users,
|
||||
selectorFunc: func(t *testing.T) selectors.Selector {
|
||||
sel := selectors.NewExchangeBackup([]string{suite.user})
|
||||
sel := selectors.NewExchangeBackup([]string{suite.m365.User.ID})
|
||||
sel.Include(
|
||||
sel.ContactFolders(selectors.None()),
|
||||
sel.EventCalendars(selectors.None()),
|
||||
@ -1329,7 +1326,7 @@ func (suite *ControllerIntegrationSuite) TestProduceBackupCollections_createsPre
|
||||
name: "OneDrive",
|
||||
resourceCat: resource.Users,
|
||||
selectorFunc: func(t *testing.T) selectors.Selector {
|
||||
sel := selectors.NewOneDriveBackup([]string{suite.user})
|
||||
sel := selectors.NewOneDriveBackup([]string{suite.m365.User.ID})
|
||||
sel.Include(sel.Folders(selectors.None()))
|
||||
|
||||
return sel.Selector
|
||||
|
||||
@ -1,30 +1,26 @@
|
||||
package m365
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/alcionai/clues"
|
||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"github.com/alcionai/corso/src/internal/common/ptr"
|
||||
"github.com/alcionai/corso/src/internal/m365/collection/drive/metadata"
|
||||
odConsts "github.com/alcionai/corso/src/internal/m365/service/onedrive/consts"
|
||||
"github.com/alcionai/corso/src/internal/m365/service/onedrive/stub"
|
||||
m365Stub "github.com/alcionai/corso/src/internal/m365/stub"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/internal/tester/its"
|
||||
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
||||
"github.com/alcionai/corso/src/internal/version"
|
||||
"github.com/alcionai/corso/src/pkg/control"
|
||||
"github.com/alcionai/corso/src/pkg/control/testdata"
|
||||
"github.com/alcionai/corso/src/pkg/dttm"
|
||||
"github.com/alcionai/corso/src/pkg/path"
|
||||
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -44,119 +40,6 @@ var (
|
||||
readPerm = []string{"read"}
|
||||
)
|
||||
|
||||
func mustGetDefaultDriveID(
|
||||
t *testing.T,
|
||||
ctx context.Context, //revive:disable-line:context-as-argument
|
||||
ac api.Client,
|
||||
service path.ServiceType,
|
||||
resourceOwner string,
|
||||
) string {
|
||||
var (
|
||||
err error
|
||||
d models.Driveable
|
||||
)
|
||||
|
||||
switch service {
|
||||
case path.OneDriveService:
|
||||
d, err = ac.Users().GetDefaultDrive(ctx, resourceOwner)
|
||||
case path.SharePointService:
|
||||
d, err = ac.Sites().GetDefaultDrive(ctx, resourceOwner)
|
||||
default:
|
||||
assert.FailNowf(t, "unknown service type %s", service.String())
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
err = clues.Wrap(err, "retrieving drive")
|
||||
}
|
||||
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
id := ptr.Val(d.GetId())
|
||||
require.NotEmpty(t, id)
|
||||
|
||||
return id
|
||||
}
|
||||
|
||||
type suiteInfo interface {
|
||||
APIClient() api.Client
|
||||
Tenant() string
|
||||
// Returns (username, user ID) for the user. These values are used for
|
||||
// permissions.
|
||||
PrimaryUser() (string, string)
|
||||
SecondaryUser() (string, string)
|
||||
TertiaryUser() (string, string)
|
||||
// ResourceOwner returns the resource owner to run the backup/restore
|
||||
// with. This can be different from the values used for permissions and it can
|
||||
// also be a site.
|
||||
ResourceOwner() string
|
||||
Service() path.ServiceType
|
||||
}
|
||||
|
||||
type oneDriveSuite interface {
|
||||
tester.Suite
|
||||
suiteInfo
|
||||
}
|
||||
|
||||
type suiteInfoImpl struct {
|
||||
ac api.Client
|
||||
controller *Controller
|
||||
resourceOwner string
|
||||
secondaryUser string
|
||||
secondaryUserID string
|
||||
service path.ServiceType
|
||||
tertiaryUser string
|
||||
tertiaryUserID string
|
||||
user string
|
||||
userID string
|
||||
}
|
||||
|
||||
func NewSuiteInfoImpl(
|
||||
t *testing.T,
|
||||
ctx context.Context, //revive:disable-line:context-as-argument
|
||||
resourceOwner string,
|
||||
service path.ServiceType,
|
||||
) suiteInfoImpl {
|
||||
ctrl := newController(ctx, t, path.OneDriveService)
|
||||
|
||||
return suiteInfoImpl{
|
||||
ac: ctrl.AC,
|
||||
controller: ctrl,
|
||||
resourceOwner: resourceOwner,
|
||||
secondaryUser: tconfig.SecondaryM365UserID(t),
|
||||
service: service,
|
||||
tertiaryUser: tconfig.TertiaryM365UserID(t),
|
||||
user: tconfig.M365UserID(t),
|
||||
}
|
||||
}
|
||||
|
||||
func (si suiteInfoImpl) APIClient() api.Client {
|
||||
return si.ac
|
||||
}
|
||||
|
||||
func (si suiteInfoImpl) Tenant() string {
|
||||
return si.controller.tenant
|
||||
}
|
||||
|
||||
func (si suiteInfoImpl) PrimaryUser() (string, string) {
|
||||
return si.user, si.userID
|
||||
}
|
||||
|
||||
func (si suiteInfoImpl) SecondaryUser() (string, string) {
|
||||
return si.secondaryUser, si.secondaryUserID
|
||||
}
|
||||
|
||||
func (si suiteInfoImpl) TertiaryUser() (string, string) {
|
||||
return si.tertiaryUser, si.tertiaryUserID
|
||||
}
|
||||
|
||||
func (si suiteInfoImpl) ResourceOwner() string {
|
||||
return si.resourceOwner
|
||||
}
|
||||
|
||||
func (si suiteInfoImpl) Service() path.ServiceType {
|
||||
return si.service
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// SharePoint Libraries
|
||||
// ---------------------------------------------------------------------------
|
||||
@ -166,7 +49,8 @@ func (si suiteInfoImpl) Service() path.ServiceType {
|
||||
|
||||
type SharePointIntegrationSuite struct {
|
||||
tester.Suite
|
||||
suiteInfo
|
||||
m365 its.M365IntgTestSetup
|
||||
resourceAndSvc its.ResourceServicer
|
||||
}
|
||||
|
||||
func TestSharePointIntegrationSuite(t *testing.T) {
|
||||
@ -178,57 +62,38 @@ func TestSharePointIntegrationSuite(t *testing.T) {
|
||||
}
|
||||
|
||||
func (suite *SharePointIntegrationSuite) SetupSuite() {
|
||||
t := suite.T()
|
||||
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
si := NewSuiteInfoImpl(suite.T(), ctx, tconfig.M365SiteID(suite.T()), path.SharePointService)
|
||||
|
||||
// users needed for permissions
|
||||
user, err := si.controller.AC.Users().GetByID(ctx, si.user, api.CallConfig{})
|
||||
require.NoError(t, err, "fetching user", si.user, clues.ToCore(err))
|
||||
si.userID = ptr.Val(user.GetId())
|
||||
|
||||
secondaryUser, err := si.controller.AC.Users().GetByID(ctx, si.secondaryUser, api.CallConfig{})
|
||||
require.NoError(t, err, "fetching user", si.secondaryUser, clues.ToCore(err))
|
||||
si.secondaryUserID = ptr.Val(secondaryUser.GetId())
|
||||
|
||||
tertiaryUser, err := si.controller.AC.Users().GetByID(ctx, si.tertiaryUser, api.CallConfig{})
|
||||
require.NoError(t, err, "fetching user", si.tertiaryUser, clues.ToCore(err))
|
||||
si.tertiaryUserID = ptr.Val(tertiaryUser.GetId())
|
||||
|
||||
suite.suiteInfo = si
|
||||
suite.m365 = its.GetM365(suite.T())
|
||||
suite.resourceAndSvc = its.NewResourceService(suite.m365.Site, path.SharePointService)
|
||||
}
|
||||
|
||||
func (suite *SharePointIntegrationSuite) TestRestoreAndBackup_MultipleFilesAndFolders_NoPermissions() {
|
||||
testRestoreAndBackupMultipleFilesAndFoldersNoPermissions(suite, version.Backup)
|
||||
testRestoreAndBackupMultipleFilesAndFoldersNoPermissions(suite, suite.m365, suite.resourceAndSvc, version.Backup)
|
||||
}
|
||||
|
||||
// TODO: Re-enable these tests (disabled as it currently acting up CI)
|
||||
func (suite *SharePointIntegrationSuite) TestPermissionsRestoreAndBackup() {
|
||||
suite.T().Skip("Temporarily disabled due to CI issues")
|
||||
testPermissionsRestoreAndBackup(suite, version.Backup)
|
||||
testPermissionsRestoreAndBackup(suite, suite.m365, suite.resourceAndSvc, version.Backup)
|
||||
}
|
||||
|
||||
func (suite *SharePointIntegrationSuite) TestRestoreNoPermissionsAndBackup() {
|
||||
suite.T().Skip("Temporarily disabled due to CI issues")
|
||||
testRestoreNoPermissionsAndBackup(suite, version.Backup)
|
||||
testRestoreNoPermissionsAndBackup(suite, suite.m365, suite.resourceAndSvc, version.Backup)
|
||||
}
|
||||
|
||||
func (suite *SharePointIntegrationSuite) TestPermissionsInheritanceRestoreAndBackup() {
|
||||
suite.T().Skip("Temporarily disabled due to CI issues")
|
||||
testPermissionsInheritanceRestoreAndBackup(suite, version.Backup)
|
||||
testPermissionsInheritanceRestoreAndBackup(suite, suite.m365, suite.resourceAndSvc, version.Backup)
|
||||
}
|
||||
|
||||
func (suite *SharePointIntegrationSuite) TestLinkSharesInheritanceRestoreAndBackup() {
|
||||
suite.T().Skip("Temporarily disabled due to CI issues")
|
||||
testLinkSharesInheritanceRestoreAndBackup(suite, version.Backup)
|
||||
testLinkSharesInheritanceRestoreAndBackup(suite, suite.m365, suite.resourceAndSvc, version.Backup)
|
||||
}
|
||||
|
||||
func (suite *SharePointIntegrationSuite) TestRestoreFolderNamedFolderRegression() {
|
||||
// No reason why it couldn't work with previous versions, but this is when it got introduced.
|
||||
testRestoreFolderNamedFolderRegression(suite, version.All8MigrateUserPNToID)
|
||||
testRestoreFolderNamedFolderRegression(suite, suite.m365, suite.resourceAndSvc, version.All8MigrateUserPNToID)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@ -236,7 +101,8 @@ func (suite *SharePointIntegrationSuite) TestRestoreFolderNamedFolderRegression(
|
||||
// ---------------------------------------------------------------------------
|
||||
type OneDriveIntegrationSuite struct {
|
||||
tester.Suite
|
||||
suiteInfo
|
||||
m365 its.M365IntgTestSetup
|
||||
resourceAndSvc its.ResourceServicer
|
||||
}
|
||||
|
||||
func TestOneDriveIntegrationSuite(t *testing.T) {
|
||||
@ -248,51 +114,33 @@ func TestOneDriveIntegrationSuite(t *testing.T) {
|
||||
}
|
||||
|
||||
func (suite *OneDriveIntegrationSuite) SetupSuite() {
|
||||
t := suite.T()
|
||||
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
si := NewSuiteInfoImpl(t, ctx, tconfig.M365UserID(t), path.OneDriveService)
|
||||
|
||||
user, err := si.controller.AC.Users().GetByID(ctx, si.user, api.CallConfig{})
|
||||
require.NoError(t, err, "fetching user", si.user, clues.ToCore(err))
|
||||
si.userID = ptr.Val(user.GetId())
|
||||
|
||||
secondaryUser, err := si.controller.AC.Users().GetByID(ctx, si.secondaryUser, api.CallConfig{})
|
||||
require.NoError(t, err, "fetching user", si.secondaryUser, clues.ToCore(err))
|
||||
si.secondaryUserID = ptr.Val(secondaryUser.GetId())
|
||||
|
||||
tertiaryUser, err := si.controller.AC.Users().GetByID(ctx, si.tertiaryUser, api.CallConfig{})
|
||||
require.NoError(t, err, "fetching user", si.tertiaryUser, clues.ToCore(err))
|
||||
si.tertiaryUserID = ptr.Val(tertiaryUser.GetId())
|
||||
|
||||
suite.suiteInfo = si
|
||||
suite.m365 = its.GetM365(suite.T())
|
||||
suite.resourceAndSvc = its.NewResourceService(suite.m365.User, path.OneDriveService)
|
||||
}
|
||||
|
||||
func (suite *OneDriveIntegrationSuite) TestRestoreAndBackup_MultipleFilesAndFolders_NoPermissions() {
|
||||
testRestoreAndBackupMultipleFilesAndFoldersNoPermissions(suite, version.Backup)
|
||||
testRestoreAndBackupMultipleFilesAndFoldersNoPermissions(suite, suite.m365, suite.resourceAndSvc, version.Backup)
|
||||
}
|
||||
|
||||
func (suite *OneDriveIntegrationSuite) TestPermissionsRestoreAndBackup() {
|
||||
testPermissionsRestoreAndBackup(suite, version.Backup)
|
||||
testPermissionsRestoreAndBackup(suite, suite.m365, suite.resourceAndSvc, version.Backup)
|
||||
}
|
||||
|
||||
func (suite *OneDriveIntegrationSuite) TestRestoreNoPermissionsAndBackup() {
|
||||
testRestoreNoPermissionsAndBackup(suite, version.Backup)
|
||||
testRestoreNoPermissionsAndBackup(suite, suite.m365, suite.resourceAndSvc, version.Backup)
|
||||
}
|
||||
|
||||
func (suite *OneDriveIntegrationSuite) TestPermissionsInheritanceRestoreAndBackup() {
|
||||
testPermissionsInheritanceRestoreAndBackup(suite, version.Backup)
|
||||
testPermissionsInheritanceRestoreAndBackup(suite, suite.m365, suite.resourceAndSvc, version.Backup)
|
||||
}
|
||||
|
||||
func (suite *OneDriveIntegrationSuite) TestLinkSharesInheritanceRestoreAndBackup() {
|
||||
testLinkSharesInheritanceRestoreAndBackup(suite, version.Backup)
|
||||
testLinkSharesInheritanceRestoreAndBackup(suite, suite.m365, suite.resourceAndSvc, version.Backup)
|
||||
}
|
||||
|
||||
func (suite *OneDriveIntegrationSuite) TestRestoreFolderNamedFolderRegression() {
|
||||
// No reason why it couldn't work with previous versions, but this is when it got introduced.
|
||||
testRestoreFolderNamedFolderRegression(suite, version.All8MigrateUserPNToID)
|
||||
testRestoreFolderNamedFolderRegression(suite, suite.m365, suite.resourceAndSvc, version.All8MigrateUserPNToID)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@ -300,7 +148,8 @@ func (suite *OneDriveIntegrationSuite) TestRestoreFolderNamedFolderRegression()
|
||||
// ---------------------------------------------------------------------------
|
||||
type OneDriveNightlySuite struct {
|
||||
tester.Suite
|
||||
suiteInfo
|
||||
m365 its.M365IntgTestSetup
|
||||
resourceAndSvc its.ResourceServicer
|
||||
}
|
||||
|
||||
func TestOneDriveNightlySuite(t *testing.T) {
|
||||
@ -312,70 +161,48 @@ func TestOneDriveNightlySuite(t *testing.T) {
|
||||
}
|
||||
|
||||
func (suite *OneDriveNightlySuite) SetupSuite() {
|
||||
t := suite.T()
|
||||
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
si := NewSuiteInfoImpl(t, ctx, tconfig.M365UserID(t), path.OneDriveService)
|
||||
|
||||
user, err := si.controller.AC.Users().GetByID(ctx, si.user, api.CallConfig{})
|
||||
require.NoError(t, err, "fetching user", si.user, clues.ToCore(err))
|
||||
si.userID = ptr.Val(user.GetId())
|
||||
|
||||
secondaryUser, err := si.controller.AC.Users().GetByID(ctx, si.secondaryUser, api.CallConfig{})
|
||||
require.NoError(t, err, "fetching user", si.secondaryUser, clues.ToCore(err))
|
||||
si.secondaryUserID = ptr.Val(secondaryUser.GetId())
|
||||
|
||||
tertiaryUser, err := si.controller.AC.Users().GetByID(ctx, si.tertiaryUser, api.CallConfig{})
|
||||
require.NoError(t, err, "fetching user", si.tertiaryUser, clues.ToCore(err))
|
||||
si.tertiaryUserID = ptr.Val(tertiaryUser.GetId())
|
||||
|
||||
suite.suiteInfo = si
|
||||
suite.m365 = its.GetM365(suite.T())
|
||||
suite.resourceAndSvc = its.NewResourceService(suite.m365.User, path.OneDriveService)
|
||||
}
|
||||
|
||||
func (suite *OneDriveNightlySuite) TestRestoreAndBackup_MultipleFilesAndFolders_NoPermissions() {
|
||||
testRestoreAndBackupMultipleFilesAndFoldersNoPermissions(suite, 0)
|
||||
testRestoreAndBackupMultipleFilesAndFoldersNoPermissions(suite, suite.m365, suite.resourceAndSvc, 0)
|
||||
}
|
||||
|
||||
func (suite *OneDriveNightlySuite) TestPermissionsRestoreAndBackup() {
|
||||
testPermissionsRestoreAndBackup(suite, version.OneDrive1DataAndMetaFiles)
|
||||
testPermissionsRestoreAndBackup(suite, suite.m365, suite.resourceAndSvc, version.OneDrive1DataAndMetaFiles)
|
||||
}
|
||||
|
||||
func (suite *OneDriveNightlySuite) TestRestoreNoPermissionsAndBackup() {
|
||||
testRestoreNoPermissionsAndBackup(suite, version.OneDrive1DataAndMetaFiles)
|
||||
testRestoreNoPermissionsAndBackup(suite, suite.m365, suite.resourceAndSvc, version.OneDrive1DataAndMetaFiles)
|
||||
}
|
||||
|
||||
func (suite *OneDriveNightlySuite) TestPermissionsInheritanceRestoreAndBackup() {
|
||||
// No reason why it couldn't work with previous versions, but this is when it got introduced.
|
||||
testPermissionsInheritanceRestoreAndBackup(suite, version.OneDrive4DirIncludesPermissions)
|
||||
testPermissionsInheritanceRestoreAndBackup(
|
||||
suite,
|
||||
suite.m365,
|
||||
suite.resourceAndSvc,
|
||||
version.OneDrive4DirIncludesPermissions)
|
||||
}
|
||||
|
||||
func (suite *OneDriveNightlySuite) TestLinkSharesInheritanceRestoreAndBackup() {
|
||||
testLinkSharesInheritanceRestoreAndBackup(suite, version.Backup)
|
||||
testLinkSharesInheritanceRestoreAndBackup(suite, suite.m365, suite.resourceAndSvc, version.Backup)
|
||||
}
|
||||
|
||||
func (suite *OneDriveNightlySuite) TestRestoreFolderNamedFolderRegression() {
|
||||
// No reason why it couldn't work with previous versions, but this is when it got introduced.
|
||||
testRestoreFolderNamedFolderRegression(suite, version.All8MigrateUserPNToID)
|
||||
testRestoreFolderNamedFolderRegression(suite, suite.m365, suite.resourceAndSvc, version.All8MigrateUserPNToID)
|
||||
}
|
||||
|
||||
func testRestoreAndBackupMultipleFilesAndFoldersNoPermissions(
|
||||
suite oneDriveSuite,
|
||||
suite tester.Suite,
|
||||
m365 its.M365IntgTestSetup,
|
||||
resourceAndSvc its.ResourceServicer,
|
||||
startVersion int,
|
||||
) {
|
||||
t := suite.T()
|
||||
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
// Get the default drive ID for the test user.
|
||||
driveID := mustGetDefaultDriveID(
|
||||
t,
|
||||
ctx,
|
||||
suite.APIClient(),
|
||||
suite.Service(),
|
||||
suite.ResourceOwner())
|
||||
driveID := resourceAndSvc.Resource().DriveID
|
||||
|
||||
rootPath := []string{
|
||||
odConsts.DrivesPathDir,
|
||||
@ -488,17 +315,17 @@ func testRestoreAndBackupMultipleFilesAndFoldersNoPermissions(
|
||||
},
|
||||
}
|
||||
|
||||
expected, err := stub.DataForInfo(suite.Service(), cols, version.Backup)
|
||||
expected, err := stub.DataForInfo(resourceAndSvc.Service(), cols, version.Backup)
|
||||
require.NoError(suite.T(), err)
|
||||
|
||||
for vn := startVersion; vn <= version.Backup; vn++ {
|
||||
suite.Run(fmt.Sprintf("Version%d", vn), func() {
|
||||
t := suite.T()
|
||||
input, err := stub.DataForInfo(suite.Service(), cols, vn)
|
||||
input, err := stub.DataForInfo(resourceAndSvc.Service(), cols, vn)
|
||||
require.NoError(suite.T(), err)
|
||||
|
||||
testData := restoreBackupInfoMultiVersion{
|
||||
service: suite.Service(),
|
||||
service: resourceAndSvc.Service(),
|
||||
backupVersion: vn,
|
||||
collectionsPrevious: input,
|
||||
collectionsLatest: expected,
|
||||
@ -511,8 +338,8 @@ func testRestoreAndBackupMultipleFilesAndFoldersNoPermissions(
|
||||
opts := control.DefaultOptions()
|
||||
|
||||
cfg := m365Stub.ConfigInfo{
|
||||
Tenant: suite.Tenant(),
|
||||
ResourceOwners: []string{suite.ResourceOwner()},
|
||||
Tenant: m365.TenantID,
|
||||
ResourceOwners: []string{resourceAndSvc.Resource().ID},
|
||||
Service: testData.service,
|
||||
Opts: opts,
|
||||
RestoreCfg: restoreCfg,
|
||||
@ -523,21 +350,14 @@ func testRestoreAndBackupMultipleFilesAndFoldersNoPermissions(
|
||||
}
|
||||
}
|
||||
|
||||
func testPermissionsRestoreAndBackup(suite oneDriveSuite, startVersion int) {
|
||||
t := suite.T()
|
||||
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
secondaryUserName, secondaryUserID := suite.SecondaryUser()
|
||||
|
||||
func testPermissionsRestoreAndBackup(
|
||||
suite tester.Suite,
|
||||
m365 its.M365IntgTestSetup,
|
||||
resourceAndSvc its.ResourceServicer,
|
||||
startVersion int,
|
||||
) {
|
||||
// Get the default drive ID for the test user.
|
||||
driveID := mustGetDefaultDriveID(
|
||||
t,
|
||||
ctx,
|
||||
suite.APIClient(),
|
||||
suite.Service(),
|
||||
suite.ResourceOwner())
|
||||
driveID := resourceAndSvc.Resource().DriveID
|
||||
|
||||
fileName2 := "test-file2.txt"
|
||||
folderCName := "folder-c"
|
||||
@ -587,8 +407,8 @@ func testPermissionsRestoreAndBackup(suite oneDriveSuite, startVersion int) {
|
||||
Data: fileAData,
|
||||
Meta: stub.MetaData{
|
||||
Perms: stub.PermData{
|
||||
User: secondaryUserName,
|
||||
EntityID: secondaryUserID,
|
||||
User: m365.SecondaryUser.Email,
|
||||
EntityID: m365.SecondaryUser.ID,
|
||||
Roles: writePerm,
|
||||
},
|
||||
},
|
||||
@ -614,8 +434,8 @@ func testPermissionsRestoreAndBackup(suite oneDriveSuite, startVersion int) {
|
||||
Name: folderAName,
|
||||
Meta: stub.MetaData{
|
||||
Perms: stub.PermData{
|
||||
User: secondaryUserName,
|
||||
EntityID: secondaryUserID,
|
||||
User: m365.SecondaryUser.Email,
|
||||
EntityID: m365.SecondaryUser.ID,
|
||||
Roles: readPerm,
|
||||
},
|
||||
},
|
||||
@ -624,8 +444,8 @@ func testPermissionsRestoreAndBackup(suite oneDriveSuite, startVersion int) {
|
||||
Name: folderCName,
|
||||
Meta: stub.MetaData{
|
||||
Perms: stub.PermData{
|
||||
User: secondaryUserName,
|
||||
EntityID: secondaryUserID,
|
||||
User: m365.SecondaryUser.Email,
|
||||
EntityID: m365.SecondaryUser.ID,
|
||||
Roles: readPerm,
|
||||
},
|
||||
},
|
||||
@ -645,8 +465,8 @@ func testPermissionsRestoreAndBackup(suite oneDriveSuite, startVersion int) {
|
||||
Data: fileBData,
|
||||
Meta: stub.MetaData{
|
||||
Perms: stub.PermData{
|
||||
User: secondaryUserName,
|
||||
EntityID: secondaryUserID,
|
||||
User: m365.SecondaryUser.Email,
|
||||
EntityID: m365.SecondaryUser.ID,
|
||||
Roles: writePerm,
|
||||
},
|
||||
},
|
||||
@ -657,8 +477,8 @@ func testPermissionsRestoreAndBackup(suite oneDriveSuite, startVersion int) {
|
||||
Name: folderAName,
|
||||
Meta: stub.MetaData{
|
||||
Perms: stub.PermData{
|
||||
User: secondaryUserName,
|
||||
EntityID: secondaryUserID,
|
||||
User: m365.SecondaryUser.Email,
|
||||
EntityID: m365.SecondaryUser.ID,
|
||||
Roles: readPerm,
|
||||
},
|
||||
},
|
||||
@ -676,15 +496,15 @@ func testPermissionsRestoreAndBackup(suite oneDriveSuite, startVersion int) {
|
||||
// name: fileName,
|
||||
// data: fileDData,
|
||||
// perms: stub.PermData{
|
||||
// user: secondaryUserName,
|
||||
// entityID: secondaryUserID,
|
||||
// user: m365.SecondaryUser.Email,
|
||||
// entityID: m365.SecondaryUser.ID,
|
||||
// roles: readPerm,
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// Perms: stub.PermData{
|
||||
// User: secondaryUserName,
|
||||
// EntityID: secondaryUserID,
|
||||
// User: m365.SecondaryUser.Email,
|
||||
// EntityID: m365.SecondaryUser.ID,
|
||||
// Roles: readPerm,
|
||||
// },
|
||||
// },
|
||||
@ -698,8 +518,8 @@ func testPermissionsRestoreAndBackup(suite oneDriveSuite, startVersion int) {
|
||||
Data: fileEData,
|
||||
Meta: stub.MetaData{
|
||||
Perms: stub.PermData{
|
||||
User: secondaryUserName,
|
||||
EntityID: secondaryUserID,
|
||||
User: m365.SecondaryUser.Email,
|
||||
EntityID: m365.SecondaryUser.ID,
|
||||
Roles: writePerm,
|
||||
},
|
||||
},
|
||||
@ -707,8 +527,8 @@ func testPermissionsRestoreAndBackup(suite oneDriveSuite, startVersion int) {
|
||||
},
|
||||
Meta: stub.MetaData{
|
||||
Perms: stub.PermData{
|
||||
User: secondaryUserName,
|
||||
EntityID: secondaryUserID,
|
||||
User: m365.SecondaryUser.Email,
|
||||
EntityID: m365.SecondaryUser.ID,
|
||||
Roles: readPerm,
|
||||
},
|
||||
},
|
||||
@ -728,17 +548,18 @@ func testPermissionsRestoreAndBackup(suite oneDriveSuite, startVersion int) {
|
||||
},
|
||||
Meta: stub.MetaData{
|
||||
Perms: stub.PermData{
|
||||
User: secondaryUserName,
|
||||
EntityID: secondaryUserID,
|
||||
User: m365.SecondaryUser.Email,
|
||||
EntityID: m365.SecondaryUser.ID,
|
||||
Roles: readPerm,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
expected, err := stub.DataForInfo(suite.Service(), cols, version.Backup)
|
||||
expected, err := stub.DataForInfo(resourceAndSvc.Service(), cols, version.Backup)
|
||||
require.NoError(suite.T(), err)
|
||||
bss := suite.Service().String()
|
||||
|
||||
bss := resourceAndSvc.Service().String()
|
||||
|
||||
for vn := startVersion; vn <= version.Backup; vn++ {
|
||||
suite.Run(fmt.Sprintf("%s-Version%d", bss, vn), func() {
|
||||
@ -746,11 +567,11 @@ func testPermissionsRestoreAndBackup(suite oneDriveSuite, startVersion int) {
|
||||
// Ideally this can always be true or false and still
|
||||
// work, but limiting older versions to use emails so as
|
||||
// to validate that flow as well.
|
||||
input, err := stub.DataForInfo(suite.Service(), cols, vn)
|
||||
input, err := stub.DataForInfo(resourceAndSvc.Service(), cols, vn)
|
||||
require.NoError(suite.T(), err)
|
||||
|
||||
testData := restoreBackupInfoMultiVersion{
|
||||
service: suite.Service(),
|
||||
service: resourceAndSvc.Service(),
|
||||
backupVersion: vn,
|
||||
collectionsPrevious: input,
|
||||
collectionsLatest: expected,
|
||||
@ -763,8 +584,8 @@ func testPermissionsRestoreAndBackup(suite oneDriveSuite, startVersion int) {
|
||||
opts := control.DefaultOptions()
|
||||
|
||||
cfg := m365Stub.ConfigInfo{
|
||||
Tenant: suite.Tenant(),
|
||||
ResourceOwners: []string{suite.ResourceOwner()},
|
||||
Tenant: m365.TenantID,
|
||||
ResourceOwners: []string{resourceAndSvc.Resource().ID},
|
||||
Service: testData.service,
|
||||
Opts: opts,
|
||||
RestoreCfg: restoreCfg,
|
||||
@ -775,21 +596,14 @@ func testPermissionsRestoreAndBackup(suite oneDriveSuite, startVersion int) {
|
||||
}
|
||||
}
|
||||
|
||||
func testRestoreNoPermissionsAndBackup(suite oneDriveSuite, startVersion int) {
|
||||
t := suite.T()
|
||||
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
secondaryUserName, secondaryUserID := suite.SecondaryUser()
|
||||
|
||||
func testRestoreNoPermissionsAndBackup(
|
||||
suite tester.Suite,
|
||||
m365 its.M365IntgTestSetup,
|
||||
resourceAndSvc its.ResourceServicer,
|
||||
startVersion int,
|
||||
) {
|
||||
// Get the default drive ID for the test user.
|
||||
driveID := mustGetDefaultDriveID(
|
||||
t,
|
||||
ctx,
|
||||
suite.APIClient(),
|
||||
suite.Service(),
|
||||
suite.ResourceOwner())
|
||||
driveID := resourceAndSvc.Resource().DriveID
|
||||
|
||||
inputCols := []stub.ColInfo{
|
||||
{
|
||||
@ -804,8 +618,8 @@ func testRestoreNoPermissionsAndBackup(suite oneDriveSuite, startVersion int) {
|
||||
Data: fileAData,
|
||||
Meta: stub.MetaData{
|
||||
Perms: stub.PermData{
|
||||
User: secondaryUserName,
|
||||
EntityID: secondaryUserID,
|
||||
User: m365.SecondaryUser.Email,
|
||||
EntityID: m365.SecondaryUser.ID,
|
||||
Roles: writePerm,
|
||||
},
|
||||
SharingMode: metadata.SharingModeCustom,
|
||||
@ -832,18 +646,20 @@ func testRestoreNoPermissionsAndBackup(suite oneDriveSuite, startVersion int) {
|
||||
},
|
||||
}
|
||||
|
||||
expected, err := stub.DataForInfo(suite.Service(), expectedCols, version.Backup)
|
||||
require.NoError(suite.T(), err)
|
||||
bss := suite.Service().String()
|
||||
expected, err := stub.DataForInfo(resourceAndSvc.Service(), expectedCols, version.Backup)
|
||||
require.NoError(suite.T(), err, clues.ToCore(err))
|
||||
|
||||
bss := resourceAndSvc.Service().String()
|
||||
|
||||
for vn := startVersion; vn <= version.Backup; vn++ {
|
||||
suite.Run(fmt.Sprintf("%s-Version%d", bss, vn), func() {
|
||||
t := suite.T()
|
||||
input, err := stub.DataForInfo(suite.Service(), inputCols, vn)
|
||||
require.NoError(suite.T(), err)
|
||||
|
||||
input, err := stub.DataForInfo(resourceAndSvc.Service(), inputCols, vn)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
testData := restoreBackupInfoMultiVersion{
|
||||
service: suite.Service(),
|
||||
service: resourceAndSvc.Service(),
|
||||
backupVersion: vn,
|
||||
collectionsPrevious: input,
|
||||
collectionsLatest: expected,
|
||||
@ -856,8 +672,8 @@ func testRestoreNoPermissionsAndBackup(suite oneDriveSuite, startVersion int) {
|
||||
opts := control.DefaultOptions()
|
||||
|
||||
cfg := m365Stub.ConfigInfo{
|
||||
Tenant: suite.Tenant(),
|
||||
ResourceOwners: []string{suite.ResourceOwner()},
|
||||
Tenant: m365.TenantID,
|
||||
ResourceOwners: []string{resourceAndSvc.Resource().ID},
|
||||
Service: testData.service,
|
||||
Opts: opts,
|
||||
RestoreCfg: restoreCfg,
|
||||
@ -870,22 +686,14 @@ func testRestoreNoPermissionsAndBackup(suite oneDriveSuite, startVersion int) {
|
||||
|
||||
// This is similar to TestPermissionsRestoreAndBackup but tests purely
|
||||
// for inheritance and that too only with newer versions
|
||||
func testPermissionsInheritanceRestoreAndBackup(suite oneDriveSuite, startVersion int) {
|
||||
t := suite.T()
|
||||
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
secondaryUserName, secondaryUserID := suite.SecondaryUser()
|
||||
tertiaryUserName, tertiaryUserID := suite.TertiaryUser()
|
||||
|
||||
func testPermissionsInheritanceRestoreAndBackup(
|
||||
suite tester.Suite,
|
||||
m365 its.M365IntgTestSetup,
|
||||
resourceAndSvc its.ResourceServicer,
|
||||
startVersion int,
|
||||
) {
|
||||
// Get the default drive ID for the test user.
|
||||
driveID := mustGetDefaultDriveID(
|
||||
t,
|
||||
ctx,
|
||||
suite.APIClient(),
|
||||
suite.Service(),
|
||||
suite.ResourceOwner())
|
||||
driveID := resourceAndSvc.Resource().DriveID
|
||||
|
||||
folderAName := "custom"
|
||||
folderBName := "inherited"
|
||||
@ -929,8 +737,8 @@ func testPermissionsInheritanceRestoreAndBackup(suite oneDriveSuite, startVersio
|
||||
Data: fileAData,
|
||||
Meta: stub.MetaData{
|
||||
Perms: stub.PermData{
|
||||
User: secondaryUserName,
|
||||
EntityID: secondaryUserID,
|
||||
User: m365.SecondaryUser.Email,
|
||||
EntityID: m365.SecondaryUser.ID,
|
||||
Roles: writePerm,
|
||||
},
|
||||
SharingMode: metadata.SharingModeCustom,
|
||||
@ -1002,8 +810,8 @@ func testPermissionsInheritanceRestoreAndBackup(suite oneDriveSuite, startVersio
|
||||
},
|
||||
Meta: stub.MetaData{
|
||||
Perms: stub.PermData{
|
||||
User: tertiaryUserName,
|
||||
EntityID: tertiaryUserID,
|
||||
User: m365.TertiaryUser.Email,
|
||||
EntityID: m365.TertiaryUser.ID,
|
||||
Roles: readPerm,
|
||||
},
|
||||
SharingMode: metadata.SharingModeCustom,
|
||||
@ -1014,8 +822,8 @@ func testPermissionsInheritanceRestoreAndBackup(suite oneDriveSuite, startVersio
|
||||
Files: fileSet,
|
||||
Meta: stub.MetaData{
|
||||
Perms: stub.PermData{
|
||||
User: tertiaryUserName,
|
||||
EntityID: tertiaryUserID,
|
||||
User: m365.TertiaryUser.Email,
|
||||
EntityID: m365.TertiaryUser.ID,
|
||||
Roles: writePerm,
|
||||
},
|
||||
SharingMode: metadata.SharingModeCustom,
|
||||
@ -1037,9 +845,10 @@ func testPermissionsInheritanceRestoreAndBackup(suite oneDriveSuite, startVersio
|
||||
},
|
||||
}
|
||||
|
||||
expected, err := stub.DataForInfo(suite.Service(), cols, version.Backup)
|
||||
expected, err := stub.DataForInfo(resourceAndSvc.Service(), cols, version.Backup)
|
||||
require.NoError(suite.T(), err)
|
||||
bss := suite.Service().String()
|
||||
|
||||
bss := resourceAndSvc.Service().String()
|
||||
|
||||
for vn := startVersion; vn <= version.Backup; vn++ {
|
||||
suite.Run(fmt.Sprintf("%s-Version%d", bss, vn), func() {
|
||||
@ -1047,11 +856,11 @@ func testPermissionsInheritanceRestoreAndBackup(suite oneDriveSuite, startVersio
|
||||
// Ideally this can always be true or false and still
|
||||
// work, but limiting older versions to use emails so as
|
||||
// to validate that flow as well.
|
||||
input, err := stub.DataForInfo(suite.Service(), cols, vn)
|
||||
input, err := stub.DataForInfo(resourceAndSvc.Service(), cols, vn)
|
||||
require.NoError(suite.T(), err)
|
||||
|
||||
testData := restoreBackupInfoMultiVersion{
|
||||
service: suite.Service(),
|
||||
service: resourceAndSvc.Service(),
|
||||
backupVersion: vn,
|
||||
collectionsPrevious: input,
|
||||
collectionsLatest: expected,
|
||||
@ -1064,8 +873,8 @@ func testPermissionsInheritanceRestoreAndBackup(suite oneDriveSuite, startVersio
|
||||
opts := control.DefaultOptions()
|
||||
|
||||
cfg := m365Stub.ConfigInfo{
|
||||
Tenant: suite.Tenant(),
|
||||
ResourceOwners: []string{suite.ResourceOwner()},
|
||||
Tenant: m365.TenantID,
|
||||
ResourceOwners: []string{resourceAndSvc.Resource().ID},
|
||||
Service: testData.service,
|
||||
Opts: opts,
|
||||
RestoreCfg: restoreCfg,
|
||||
@ -1076,33 +885,26 @@ func testPermissionsInheritanceRestoreAndBackup(suite oneDriveSuite, startVersio
|
||||
}
|
||||
}
|
||||
|
||||
func testLinkSharesInheritanceRestoreAndBackup(suite oneDriveSuite, startVersion int) {
|
||||
t := suite.T()
|
||||
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
secondaryUserName, secondaryUserID := suite.SecondaryUser()
|
||||
func testLinkSharesInheritanceRestoreAndBackup(
|
||||
suite tester.Suite,
|
||||
m365 its.M365IntgTestSetup,
|
||||
resourceAndSvc its.ResourceServicer,
|
||||
startVersion int,
|
||||
) {
|
||||
secondaryUser := metadata.Entity{
|
||||
ID: secondaryUserID,
|
||||
Email: secondaryUserName,
|
||||
ID: m365.SecondaryUser.ID,
|
||||
Email: m365.SecondaryUser.Email,
|
||||
EntityType: metadata.GV2User,
|
||||
}
|
||||
|
||||
tertiaryUserName, tertiaryUserID := suite.TertiaryUser()
|
||||
tertiaryUser := metadata.Entity{
|
||||
ID: tertiaryUserID,
|
||||
Email: tertiaryUserName,
|
||||
ID: m365.TertiaryUser.ID,
|
||||
Email: m365.TertiaryUser.Email,
|
||||
EntityType: metadata.GV2User,
|
||||
}
|
||||
|
||||
// Get the default drive ID for the test user.
|
||||
driveID := mustGetDefaultDriveID(
|
||||
t,
|
||||
ctx,
|
||||
suite.APIClient(),
|
||||
suite.Service(),
|
||||
suite.ResourceOwner())
|
||||
driveID := resourceAndSvc.Resource().DriveID
|
||||
|
||||
folderAName := "custom"
|
||||
folderBName := "inherited"
|
||||
@ -1246,9 +1048,10 @@ func testLinkSharesInheritanceRestoreAndBackup(suite oneDriveSuite, startVersion
|
||||
},
|
||||
}
|
||||
|
||||
expected, err := stub.DataForInfo(suite.Service(), cols, version.Backup)
|
||||
expected, err := stub.DataForInfo(resourceAndSvc.Service(), cols, version.Backup)
|
||||
require.NoError(suite.T(), err)
|
||||
bss := suite.Service().String()
|
||||
|
||||
bss := resourceAndSvc.Service().String()
|
||||
|
||||
for vn := startVersion; vn <= version.Backup; vn++ {
|
||||
suite.Run(fmt.Sprintf("%s-Version%d", bss, vn), func() {
|
||||
@ -1256,11 +1059,11 @@ func testLinkSharesInheritanceRestoreAndBackup(suite oneDriveSuite, startVersion
|
||||
// Ideally this can always be true or false and still
|
||||
// work, but limiting older versions to use emails so as
|
||||
// to validate that flow as well.
|
||||
input, err := stub.DataForInfo(suite.Service(), cols, vn)
|
||||
input, err := stub.DataForInfo(resourceAndSvc.Service(), cols, vn)
|
||||
require.NoError(suite.T(), err)
|
||||
|
||||
testData := restoreBackupInfoMultiVersion{
|
||||
service: suite.Service(),
|
||||
service: resourceAndSvc.Service(),
|
||||
backupVersion: vn,
|
||||
collectionsPrevious: input,
|
||||
collectionsLatest: expected,
|
||||
@ -1273,8 +1076,8 @@ func testLinkSharesInheritanceRestoreAndBackup(suite oneDriveSuite, startVersion
|
||||
opts := control.DefaultOptions()
|
||||
|
||||
cfg := m365Stub.ConfigInfo{
|
||||
Tenant: suite.Tenant(),
|
||||
ResourceOwners: []string{suite.ResourceOwner()},
|
||||
Tenant: m365.TenantID,
|
||||
ResourceOwners: []string{resourceAndSvc.Resource().ID},
|
||||
Service: testData.service,
|
||||
Opts: opts,
|
||||
RestoreCfg: restoreCfg,
|
||||
@ -1286,21 +1089,13 @@ func testLinkSharesInheritanceRestoreAndBackup(suite oneDriveSuite, startVersion
|
||||
}
|
||||
|
||||
func testRestoreFolderNamedFolderRegression(
|
||||
suite oneDriveSuite,
|
||||
suite tester.Suite,
|
||||
m365 its.M365IntgTestSetup,
|
||||
resourceAndSvc its.ResourceServicer,
|
||||
startVersion int,
|
||||
) {
|
||||
t := suite.T()
|
||||
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
// Get the default drive ID for the test user.
|
||||
driveID := mustGetDefaultDriveID(
|
||||
suite.T(),
|
||||
ctx,
|
||||
suite.APIClient(),
|
||||
suite.Service(),
|
||||
suite.ResourceOwner())
|
||||
driveID := resourceAndSvc.Resource().DriveID
|
||||
|
||||
rootPath := []string{
|
||||
odConsts.DrivesPathDir,
|
||||
@ -1369,18 +1164,19 @@ func testRestoreFolderNamedFolderRegression(
|
||||
},
|
||||
}
|
||||
|
||||
expected, err := stub.DataForInfo(suite.Service(), cols, version.Backup)
|
||||
expected, err := stub.DataForInfo(resourceAndSvc.Service(), cols, version.Backup)
|
||||
require.NoError(suite.T(), err)
|
||||
bss := suite.Service().String()
|
||||
|
||||
bss := resourceAndSvc.Service().String()
|
||||
|
||||
for vn := startVersion; vn <= version.Backup; vn++ {
|
||||
suite.Run(fmt.Sprintf("%s-Version%d", bss, vn), func() {
|
||||
t := suite.T()
|
||||
input, err := stub.DataForInfo(suite.Service(), cols, vn)
|
||||
input, err := stub.DataForInfo(resourceAndSvc.Service(), cols, vn)
|
||||
require.NoError(suite.T(), err)
|
||||
|
||||
testData := restoreBackupInfoMultiVersion{
|
||||
service: suite.Service(),
|
||||
service: resourceAndSvc.Service(),
|
||||
backupVersion: vn,
|
||||
collectionsPrevious: input,
|
||||
collectionsLatest: expected,
|
||||
@ -1392,8 +1188,8 @@ func testRestoreFolderNamedFolderRegression(
|
||||
opts := control.DefaultOptions()
|
||||
|
||||
cfg := m365Stub.ConfigInfo{
|
||||
Tenant: suite.Tenant(),
|
||||
ResourceOwners: []string{suite.ResourceOwner()},
|
||||
Tenant: m365.TenantID,
|
||||
ResourceOwners: []string{resourceAndSvc.Resource().ID},
|
||||
Service: testData.service,
|
||||
Opts: opts,
|
||||
RestoreCfg: restoreCfg,
|
||||
|
||||
@ -9,14 +9,12 @@ import (
|
||||
"github.com/stretchr/testify/suite"
|
||||
"golang.org/x/exp/slices"
|
||||
|
||||
"github.com/alcionai/corso/src/internal/common/ptr"
|
||||
"github.com/alcionai/corso/src/internal/data"
|
||||
"github.com/alcionai/corso/src/internal/data/mock"
|
||||
"github.com/alcionai/corso/src/internal/operations/inject"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/internal/tester/its"
|
||||
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
||||
"github.com/alcionai/corso/src/pkg/control"
|
||||
"github.com/alcionai/corso/src/pkg/count"
|
||||
"github.com/alcionai/corso/src/pkg/fault"
|
||||
"github.com/alcionai/corso/src/pkg/path"
|
||||
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
||||
@ -64,9 +62,7 @@ func (suite *GroupsUnitSuite) TestConsumeRestoreCollections_noErrorOnGroups() {
|
||||
|
||||
type groupsIntegrationSuite struct {
|
||||
tester.Suite
|
||||
resource string
|
||||
tenantID string
|
||||
ac api.Client
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestGroupsIntegrationSuite(t *testing.T) {
|
||||
@ -79,25 +75,12 @@ func TestGroupsIntegrationSuite(t *testing.T) {
|
||||
|
||||
func (suite *groupsIntegrationSuite) SetupSuite() {
|
||||
t := suite.T()
|
||||
suite.m365 = its.GetM365(t)
|
||||
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
graph.InitializeConcurrencyLimiter(ctx, true, 4)
|
||||
|
||||
suite.resource = tconfig.M365TeamID(t)
|
||||
|
||||
acct := tconfig.NewM365Account(t)
|
||||
creds, err := acct.M365Config()
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
suite.ac, err = api.NewClient(
|
||||
creds,
|
||||
control.DefaultOptions(),
|
||||
count.New())
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
suite.tenantID = creds.AzureTenantID
|
||||
}
|
||||
|
||||
// test for getSiteName
|
||||
@ -107,12 +90,9 @@ func (suite *groupsIntegrationSuite) TestGetSiteName() {
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
rootSite, err := suite.ac.Groups().GetRootSite(ctx, suite.resource)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
// Generate a fake site ID that appears valid to graph API but doesn't actually exist.
|
||||
// This "could" be flaky, but highly unlikely
|
||||
unavailableSiteID := []rune(ptr.Val(rootSite.GetId()))
|
||||
unavailableSiteID := []rune(suite.m365.Group.RootSite.ID)
|
||||
firstIDChar := slices.Index(unavailableSiteID, ',') + 1
|
||||
|
||||
if unavailableSiteID[firstIDChar] != '2' {
|
||||
@ -131,9 +111,9 @@ func (suite *groupsIntegrationSuite) TestGetSiteName() {
|
||||
}{
|
||||
{
|
||||
name: "valid",
|
||||
siteID: ptr.Val(rootSite.GetId()),
|
||||
webURL: ptr.Val(rootSite.GetWebUrl()),
|
||||
siteName: *rootSite.GetDisplayName(),
|
||||
siteID: suite.m365.Group.RootSite.ID,
|
||||
webURL: suite.m365.Group.RootSite.WebURL,
|
||||
siteName: suite.m365.Group.RootSite.DisplayName,
|
||||
webURLToSiteNames: map[string]string{},
|
||||
expectErr: assert.NoError,
|
||||
},
|
||||
@ -163,7 +143,7 @@ func (suite *groupsIntegrationSuite) TestGetSiteName() {
|
||||
ctx,
|
||||
test.siteID,
|
||||
test.webURL,
|
||||
suite.ac.Sites(),
|
||||
suite.m365.AC.Sites(),
|
||||
test.webURLToSiteNames)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
|
||||
@ -32,6 +32,7 @@ import (
|
||||
"github.com/alcionai/corso/src/internal/streamstore"
|
||||
ssmock "github.com/alcionai/corso/src/internal/streamstore/mock"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/internal/tester/its"
|
||||
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
||||
"github.com/alcionai/corso/src/pkg/account"
|
||||
"github.com/alcionai/corso/src/pkg/backup"
|
||||
@ -47,7 +48,6 @@ import (
|
||||
"github.com/alcionai/corso/src/pkg/path"
|
||||
"github.com/alcionai/corso/src/pkg/selectors"
|
||||
selTD "github.com/alcionai/corso/src/pkg/selectors/testdata"
|
||||
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
||||
"github.com/alcionai/corso/src/pkg/services/m365/api/graph"
|
||||
storeTD "github.com/alcionai/corso/src/pkg/storage/testdata"
|
||||
"github.com/alcionai/corso/src/pkg/store"
|
||||
@ -1506,8 +1506,7 @@ func withoutModified(de details.Entry) details.Entry {
|
||||
|
||||
type BackupOpIntegrationSuite struct {
|
||||
tester.Suite
|
||||
user, site string
|
||||
ac api.Client
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestBackupOpIntegrationSuite(t *testing.T) {
|
||||
@ -1520,25 +1519,12 @@ func TestBackupOpIntegrationSuite(t *testing.T) {
|
||||
|
||||
func (suite *BackupOpIntegrationSuite) SetupSuite() {
|
||||
t := suite.T()
|
||||
suite.m365 = its.GetM365(t)
|
||||
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
graph.InitializeConcurrencyLimiter(ctx, true, 4)
|
||||
|
||||
suite.user = tconfig.M365UserID(t)
|
||||
suite.site = tconfig.M365SiteID(t)
|
||||
|
||||
a := tconfig.NewM365Account(t)
|
||||
|
||||
creds, err := a.M365Config()
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
suite.ac, err = api.NewClient(
|
||||
creds,
|
||||
control.DefaultOptions(),
|
||||
count.New())
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
}
|
||||
|
||||
func (suite *BackupOpIntegrationSuite) TestNewBackupOperation() {
|
||||
@ -1546,8 +1532,8 @@ func (suite *BackupOpIntegrationSuite) TestNewBackupOperation() {
|
||||
kw = &kopia.Wrapper{}
|
||||
sw = store.NewWrapper(&kopia.ModelStore{})
|
||||
ctrl = &mock.Controller{}
|
||||
acct = tconfig.NewM365Account(suite.T())
|
||||
opts = control.DefaultOptions()
|
||||
acct = suite.m365.Acct
|
||||
)
|
||||
|
||||
table := []struct {
|
||||
@ -1745,7 +1731,7 @@ func makeMockItem(
|
||||
func (suite *AssistBackupIntegrationSuite) TestBackupTypesForFailureModes() {
|
||||
var (
|
||||
acct = tconfig.NewM365Account(suite.T())
|
||||
tenantID = acct.Config[account.AzureTenantIDKey]
|
||||
tenantID = acct.ID()
|
||||
osel = selectors.NewOneDriveBackup([]string{userID})
|
||||
)
|
||||
|
||||
@ -2074,7 +2060,7 @@ func selectFilesFromDeets(d details.Details) map[string]details.Entry {
|
||||
func (suite *AssistBackupIntegrationSuite) TestExtensionsIncrementals() {
|
||||
var (
|
||||
acct = tconfig.NewM365Account(suite.T())
|
||||
tenantID = acct.Config[account.AzureTenantIDKey]
|
||||
tenantID = acct.ID()
|
||||
opts = control.DefaultOptions()
|
||||
osel = selectors.NewOneDriveBackup([]string{userID})
|
||||
// Default policy used by SDK clients
|
||||
|
||||
@ -24,6 +24,7 @@ import (
|
||||
"github.com/alcionai/corso/src/internal/m365/collection/drive/metadata"
|
||||
odConsts "github.com/alcionai/corso/src/internal/m365/service/onedrive/consts"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/internal/tester/its"
|
||||
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
||||
"github.com/alcionai/corso/src/internal/version"
|
||||
"github.com/alcionai/corso/src/pkg/backup/details"
|
||||
@ -988,7 +989,7 @@ func RunDriveRestoreToAlternateProtectedResource(
|
||||
suite tester.Suite,
|
||||
ac api.Client,
|
||||
sel selectors.Selector, // owner should match 'from', both Restore and Backup types work.
|
||||
driveFrom, driveTo IDs,
|
||||
driveFrom, driveTo its.IDs,
|
||||
toResource string,
|
||||
) {
|
||||
ctx, flush := tester.NewContext(t)
|
||||
|
||||
@ -21,6 +21,7 @@ import (
|
||||
exchTD "github.com/alcionai/corso/src/internal/m365/service/exchange/testdata"
|
||||
. "github.com/alcionai/corso/src/internal/operations/test/m365"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/internal/tester/its"
|
||||
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
||||
"github.com/alcionai/corso/src/internal/version"
|
||||
"github.com/alcionai/corso/src/pkg/backup/details"
|
||||
@ -41,7 +42,7 @@ import (
|
||||
|
||||
type ExchangeBackupIntgSuite struct {
|
||||
tester.Suite
|
||||
its IntgTesterSetup
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestExchangeBackupIntgSuite(t *testing.T) {
|
||||
@ -53,7 +54,7 @@ func TestExchangeBackupIntgSuite(t *testing.T) {
|
||||
}
|
||||
|
||||
func (suite *ExchangeBackupIntgSuite) SetupSuite() {
|
||||
suite.its = NewIntegrationTesterSetup(suite.T())
|
||||
suite.m365 = its.GetM365(suite.T())
|
||||
}
|
||||
|
||||
// MetadataFileNames produces the category-specific set of filenames used to
|
||||
@ -80,9 +81,9 @@ func (suite *ExchangeBackupIntgSuite) TestBackup_Run_exchange() {
|
||||
{
|
||||
name: "Mail",
|
||||
selector: func() *selectors.ExchangeBackup {
|
||||
sel := selectors.NewExchangeBackup([]string{suite.its.User.ID})
|
||||
sel := selectors.NewExchangeBackup([]string{suite.m365.User.ID})
|
||||
sel.Include(sel.MailFolders([]string{api.MailInbox}, selectors.PrefixMatch()))
|
||||
sel.DiscreteOwner = suite.its.User.ID
|
||||
sel.DiscreteOwner = suite.m365.User.ID
|
||||
|
||||
return sel
|
||||
},
|
||||
@ -92,7 +93,7 @@ func (suite *ExchangeBackupIntgSuite) TestBackup_Run_exchange() {
|
||||
{
|
||||
name: "Contacts",
|
||||
selector: func() *selectors.ExchangeBackup {
|
||||
sel := selectors.NewExchangeBackup([]string{suite.its.User.ID})
|
||||
sel := selectors.NewExchangeBackup([]string{suite.m365.User.ID})
|
||||
sel.Include(sel.ContactFolders([]string{api.DefaultContacts}, selectors.PrefixMatch()))
|
||||
return sel
|
||||
},
|
||||
@ -102,7 +103,7 @@ func (suite *ExchangeBackupIntgSuite) TestBackup_Run_exchange() {
|
||||
{
|
||||
name: "Calendar Events",
|
||||
selector: func() *selectors.ExchangeBackup {
|
||||
sel := selectors.NewExchangeBackup([]string{suite.its.User.ID})
|
||||
sel := selectors.NewExchangeBackup([]string{suite.m365.User.ID})
|
||||
sel.Include(sel.EventCalendars([]string{api.DefaultCalendar}, selectors.PrefixMatch()))
|
||||
return sel
|
||||
},
|
||||
@ -270,7 +271,7 @@ func testExchangeContinuousBackups(suite *ExchangeBackupIntgSuite, toggles contr
|
||||
// later on during the tests. Putting their identifiers into the selector
|
||||
// at this point is harmless.
|
||||
containers = []string{container1, container2, container3, containerRename}
|
||||
sel = selectors.NewExchangeBackup([]string{suite.its.User.ID})
|
||||
sel = selectors.NewExchangeBackup([]string{suite.m365.User.ID})
|
||||
whatSet = deeTD.CategoryFromRepoRef
|
||||
opts = control.DefaultOptions()
|
||||
)
|
||||
@ -310,7 +311,7 @@ func testExchangeContinuousBackups(suite *ExchangeBackupIntgSuite, toggles contr
|
||||
|
||||
mailDBF := func(id, timeStamp, subject, body string) []byte {
|
||||
return exchMock.MessageWith(
|
||||
suite.its.User.ID, suite.its.User.ID, suite.its.User.ID,
|
||||
suite.m365.User.ID, suite.m365.User.ID, suite.m365.User.ID,
|
||||
subject, body, body,
|
||||
now, now, now, now)
|
||||
}
|
||||
@ -327,7 +328,7 @@ func testExchangeContinuousBackups(suite *ExchangeBackupIntgSuite, toggles contr
|
||||
|
||||
eventDBF := func(id, timeStamp, subject, body string) []byte {
|
||||
return exchMock.EventWith(
|
||||
suite.its.User.ID, subject, body, body,
|
||||
suite.m365.User.ID, subject, body, body,
|
||||
exchMock.NoOriginalStartDate, now, now,
|
||||
exchMock.NoRecurrence, exchMock.NoAttendees,
|
||||
exchMock.NoAttachments, exchMock.NoCancelledOccurrences,
|
||||
@ -596,7 +597,7 @@ func testExchangeContinuousBackups(suite *ExchangeBackupIntgSuite, toggles contr
|
||||
service,
|
||||
category,
|
||||
selectors.NewExchangeRestore([]string{uidn.ID()}).Selector,
|
||||
creds.AzureTenantID, suite.its.User.ID, "", "", container3,
|
||||
creds.AzureTenantID, suite.m365.User.ID, "", "", container3,
|
||||
2,
|
||||
version.Backup,
|
||||
gen.dbf)
|
||||
@ -889,7 +890,7 @@ func testExchangeContinuousBackups(suite *ExchangeBackupIntgSuite, toggles contr
|
||||
|
||||
type ExchangeBackupNightlyIntgSuite struct {
|
||||
tester.Suite
|
||||
its IntgTesterSetup
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestExchangeBackupNightlyIntgSuite(t *testing.T) {
|
||||
@ -901,11 +902,11 @@ func TestExchangeBackupNightlyIntgSuite(t *testing.T) {
|
||||
}
|
||||
|
||||
func (suite *ExchangeBackupNightlyIntgSuite) SetupSuite() {
|
||||
suite.its = NewIntegrationTesterSetup(suite.T())
|
||||
suite.m365 = its.GetM365(suite.T())
|
||||
}
|
||||
|
||||
func (suite *ExchangeBackupNightlyIntgSuite) TestBackup_Run_exchangeVersion9MergeBase() {
|
||||
sel := selectors.NewExchangeBackup([]string{suite.its.User.ID})
|
||||
sel := selectors.NewExchangeBackup([]string{suite.m365.User.ID})
|
||||
sel.Include(
|
||||
sel.ContactFolders([]string{api.DefaultContacts}, selectors.PrefixMatch()),
|
||||
// sel.EventCalendars([]string{api.DefaultCalendar}, selectors.PrefixMatch()),
|
||||
@ -916,7 +917,7 @@ func (suite *ExchangeBackupNightlyIntgSuite) TestBackup_Run_exchangeVersion9Merg
|
||||
|
||||
type ExchangeRestoreNightlyIntgSuite struct {
|
||||
tester.Suite
|
||||
its IntgTesterSetup
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestExchangeRestoreIntgSuite(t *testing.T) {
|
||||
@ -928,7 +929,7 @@ func TestExchangeRestoreIntgSuite(t *testing.T) {
|
||||
}
|
||||
|
||||
func (suite *ExchangeRestoreNightlyIntgSuite) SetupSuite() {
|
||||
suite.its = NewIntegrationTesterSetup(suite.T())
|
||||
suite.m365 = its.GetM365(suite.T())
|
||||
}
|
||||
|
||||
type clientItemPager interface {
|
||||
@ -959,7 +960,7 @@ func (suite *ExchangeRestoreNightlyIntgSuite) TestRestore_Run_exchangeWithAdvanc
|
||||
|
||||
// a backup is required to run restores
|
||||
|
||||
baseSel := selectors.NewExchangeBackup([]string{suite.its.User.ID})
|
||||
baseSel := selectors.NewExchangeBackup([]string{suite.m365.User.ID})
|
||||
baseSel.Include(
|
||||
// events cannot be run, for the same reason as incremental backups: the user needs
|
||||
// to have their account recycled.
|
||||
@ -967,7 +968,7 @@ func (suite *ExchangeRestoreNightlyIntgSuite) TestRestore_Run_exchangeWithAdvanc
|
||||
baseSel.ContactFolders([]string{api.DefaultContacts}, selectors.PrefixMatch()),
|
||||
baseSel.MailFolders([]string{api.MailInbox}, selectors.PrefixMatch()))
|
||||
|
||||
baseSel.DiscreteOwner = suite.its.User.ID
|
||||
baseSel.DiscreteOwner = suite.m365.User.ID
|
||||
|
||||
var (
|
||||
mb = evmock.NewBus()
|
||||
@ -1002,8 +1003,8 @@ func (suite *ExchangeRestoreNightlyIntgSuite) TestRestore_Run_exchangeWithAdvanc
|
||||
}
|
||||
|
||||
testCategories = map[path.CategoryType]clientItemPager{
|
||||
path.ContactsCategory: suite.its.AC.Contacts(),
|
||||
path.EmailCategory: suite.its.AC.Mail(),
|
||||
path.ContactsCategory: suite.m365.AC.Contacts(),
|
||||
path.EmailCategory: suite.m365.AC.Mail(),
|
||||
// path.EventsCategory: suite.its.ac.Events(),
|
||||
}
|
||||
)
|
||||
@ -1276,7 +1277,7 @@ func (suite *ExchangeRestoreNightlyIntgSuite) TestRestore_Run_exchangeAlternateP
|
||||
|
||||
// a backup is required to run restores
|
||||
|
||||
baseSel := selectors.NewExchangeBackup([]string{suite.its.User.ID})
|
||||
baseSel := selectors.NewExchangeBackup([]string{suite.m365.User.ID})
|
||||
baseSel.Include(
|
||||
// events cannot be run, for the same reason as incremental backups: the user needs
|
||||
// to have their account recycled.
|
||||
@ -1284,7 +1285,7 @@ func (suite *ExchangeRestoreNightlyIntgSuite) TestRestore_Run_exchangeAlternateP
|
||||
baseSel.ContactFolders([]string{api.DefaultContacts}, selectors.PrefixMatch()),
|
||||
baseSel.MailFolders([]string{api.MailInbox}, selectors.PrefixMatch()))
|
||||
|
||||
baseSel.DiscreteOwner = suite.its.User.ID
|
||||
baseSel.DiscreteOwner = suite.m365.User.ID
|
||||
|
||||
var (
|
||||
mb = evmock.NewBus()
|
||||
@ -1303,11 +1304,11 @@ func (suite *ExchangeRestoreNightlyIntgSuite) TestRestore_Run_exchangeAlternateP
|
||||
var (
|
||||
restoreCfg = ctrlTD.DefaultRestoreConfig("exchange_restore_to_user")
|
||||
sel = rsel.Selector
|
||||
userID = suite.its.User.ID
|
||||
secondaryUserID = suite.its.SecondaryUser.ID
|
||||
userID = suite.m365.User.ID
|
||||
secondaryUserID = suite.m365.SecondaryUser.ID
|
||||
uid = userID
|
||||
acCont = suite.its.AC.Contacts()
|
||||
acMail = suite.its.AC.Mail()
|
||||
acCont = suite.m365.AC.Contacts()
|
||||
acMail = suite.m365.AC.Mail()
|
||||
// acEvts = suite.its.ac.Events()
|
||||
firstCtr = count.New()
|
||||
)
|
||||
|
||||
@ -14,6 +14,7 @@ import (
|
||||
"github.com/alcionai/corso/src/internal/m365/collection/drive"
|
||||
. "github.com/alcionai/corso/src/internal/operations/test/m365"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/internal/tester/its"
|
||||
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
||||
"github.com/alcionai/corso/src/internal/version"
|
||||
deeTD "github.com/alcionai/corso/src/pkg/backup/details/testdata"
|
||||
@ -28,7 +29,7 @@ import (
|
||||
|
||||
type GroupsBackupIntgSuite struct {
|
||||
tester.Suite
|
||||
its IntgTesterSetup
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestGroupsBackupIntgSuite(t *testing.T) {
|
||||
@ -40,12 +41,12 @@ func TestGroupsBackupIntgSuite(t *testing.T) {
|
||||
}
|
||||
|
||||
func (suite *GroupsBackupIntgSuite) SetupSuite() {
|
||||
suite.its = NewIntegrationTesterSetup(suite.T())
|
||||
suite.m365 = its.GetM365(suite.T())
|
||||
}
|
||||
|
||||
func (suite *GroupsBackupIntgSuite) TestBackup_Run_groups() {
|
||||
var (
|
||||
resourceID = suite.its.Group.ID
|
||||
resourceID = suite.m365.Group.ID
|
||||
sel = selectors.NewGroupsBackup([]string{resourceID})
|
||||
)
|
||||
|
||||
@ -59,12 +60,12 @@ func (suite *GroupsBackupIntgSuite) TestBackup_Run_groups() {
|
||||
}
|
||||
|
||||
func (suite *GroupsBackupIntgSuite) TestBackup_Run_incrementalGroups() {
|
||||
runGroupsIncrementalBackupTests(suite, suite.its, control.DefaultOptions())
|
||||
runGroupsIncrementalBackupTests(suite, suite.m365, control.DefaultOptions())
|
||||
}
|
||||
|
||||
func (suite *GroupsBackupIntgSuite) TestBackup_Run_extensionsGroups() {
|
||||
var (
|
||||
resourceID = suite.its.Group.ID
|
||||
resourceID = suite.m365.Group.ID
|
||||
sel = selectors.NewGroupsBackup([]string{resourceID})
|
||||
)
|
||||
|
||||
@ -84,7 +85,7 @@ func (suite *GroupsBackupIntgSuite) TestBackup_Run_extensionsGroups() {
|
||||
|
||||
type GroupsBackupTreeIntgSuite struct {
|
||||
tester.Suite
|
||||
its IntgTesterSetup
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestGroupsBackupTreeIntgSuite(t *testing.T) {
|
||||
@ -96,12 +97,12 @@ func TestGroupsBackupTreeIntgSuite(t *testing.T) {
|
||||
}
|
||||
|
||||
func (suite *GroupsBackupTreeIntgSuite) SetupSuite() {
|
||||
suite.its = NewIntegrationTesterSetup(suite.T())
|
||||
suite.m365 = its.GetM365(suite.T())
|
||||
}
|
||||
|
||||
func (suite *GroupsBackupTreeIntgSuite) TestBackup_Run_treeGroups() {
|
||||
var (
|
||||
resourceID = suite.its.Group.ID
|
||||
resourceID = suite.m365.Group.ID
|
||||
sel = selectors.NewGroupsBackup([]string{resourceID})
|
||||
opts = control.DefaultOptions()
|
||||
)
|
||||
@ -117,12 +118,12 @@ func (suite *GroupsBackupTreeIntgSuite) TestBackup_Run_treeGroups() {
|
||||
|
||||
func (suite *GroupsBackupTreeIntgSuite) TestBackup_Run_treeIncrementalGroups() {
|
||||
opts := control.DefaultOptions()
|
||||
runGroupsIncrementalBackupTests(suite, suite.its, opts)
|
||||
runGroupsIncrementalBackupTests(suite, suite.m365, opts)
|
||||
}
|
||||
|
||||
func (suite *GroupsBackupTreeIntgSuite) TestBackup_Run_treeExtensionsGroups() {
|
||||
var (
|
||||
resourceID = suite.its.Group.ID
|
||||
resourceID = suite.m365.Group.ID
|
||||
sel = selectors.NewGroupsBackup([]string{resourceID})
|
||||
opts = control.DefaultOptions()
|
||||
)
|
||||
@ -142,10 +143,10 @@ func (suite *GroupsBackupTreeIntgSuite) TestBackup_Run_treeExtensionsGroups() {
|
||||
|
||||
func runGroupsIncrementalBackupTests(
|
||||
suite tester.Suite,
|
||||
its IntgTesterSetup,
|
||||
m365 its.M365IntgTestSetup,
|
||||
opts control.Options,
|
||||
) {
|
||||
sel := selectors.NewGroupsRestore([]string{its.Group.ID})
|
||||
sel := selectors.NewGroupsRestore([]string{m365.Group.ID})
|
||||
|
||||
ic := func(cs []string) selectors.Selector {
|
||||
sel.Include(sel.LibraryFolders(cs, selectors.PrefixMatch()))
|
||||
@ -156,14 +157,14 @@ func runGroupsIncrementalBackupTests(
|
||||
t *testing.T,
|
||||
ctx context.Context,
|
||||
) string {
|
||||
return its.Group.RootSite.DriveID
|
||||
return m365.Group.RootSite.DriveID
|
||||
}
|
||||
|
||||
gtsi := func(
|
||||
t *testing.T,
|
||||
ctx context.Context,
|
||||
) string {
|
||||
return its.Group.RootSite.ID
|
||||
return m365.Group.RootSite.ID
|
||||
}
|
||||
|
||||
grh := func(ac api.Client) drive.RestoreHandler {
|
||||
@ -173,8 +174,8 @@ func runGroupsIncrementalBackupTests(
|
||||
RunIncrementalDriveishBackupTest(
|
||||
suite,
|
||||
opts,
|
||||
its.Group.ID,
|
||||
its.User.ID,
|
||||
m365.Group.ID,
|
||||
m365.User.ID,
|
||||
path.GroupsService,
|
||||
path.LibrariesCategory,
|
||||
ic,
|
||||
@ -193,7 +194,7 @@ func (suite *GroupsBackupIntgSuite) TestBackup_Run_groupsBasic() {
|
||||
var (
|
||||
mb = evmock.NewBus()
|
||||
counter = count.New()
|
||||
sel = selectors.NewGroupsBackup([]string{suite.its.Group.ID})
|
||||
sel = selectors.NewGroupsBackup([]string{suite.m365.Group.ID})
|
||||
opts = control.DefaultOptions()
|
||||
whatSet = deeTD.CategoryFromRepoRef
|
||||
)
|
||||
@ -306,7 +307,7 @@ func (suite *GroupsBackupIntgSuite) TestBackup_Run_groupsBasic() {
|
||||
|
||||
type GroupsBackupNightlyIntgSuite struct {
|
||||
tester.Suite
|
||||
its IntgTesterSetup
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestGroupsBackupNightlyIntgSuite(t *testing.T) {
|
||||
@ -318,11 +319,11 @@ func TestGroupsBackupNightlyIntgSuite(t *testing.T) {
|
||||
}
|
||||
|
||||
func (suite *GroupsBackupNightlyIntgSuite) SetupSuite() {
|
||||
suite.its = NewIntegrationTesterSetup(suite.T())
|
||||
suite.m365 = its.GetM365(suite.T())
|
||||
}
|
||||
|
||||
func (suite *GroupsBackupNightlyIntgSuite) TestBackup_Run_groupsVersion9MergeBase() {
|
||||
sel := selectors.NewGroupsBackup([]string{suite.its.Group.ID})
|
||||
sel := selectors.NewGroupsBackup([]string{suite.m365.Group.ID})
|
||||
sel.Include(
|
||||
selTD.GroupsBackupLibraryFolderScope(sel),
|
||||
selTD.GroupsBackupChannelScope(sel),
|
||||
@ -332,7 +333,7 @@ func (suite *GroupsBackupNightlyIntgSuite) TestBackup_Run_groupsVersion9MergeBas
|
||||
}
|
||||
|
||||
func (suite *GroupsBackupNightlyIntgSuite) TestBackup_Run_groupsVersion9AssistBases() {
|
||||
sel := selectors.NewGroupsBackup([]string{suite.its.Group.ID})
|
||||
sel := selectors.NewGroupsBackup([]string{suite.m365.Group.ID})
|
||||
sel.Include(
|
||||
selTD.GroupsBackupLibraryFolderScope(sel),
|
||||
selTD.GroupsBackupChannelScope(sel),
|
||||
@ -343,7 +344,7 @@ func (suite *GroupsBackupNightlyIntgSuite) TestBackup_Run_groupsVersion9AssistBa
|
||||
|
||||
type GroupsRestoreNightlyIntgSuite struct {
|
||||
tester.Suite
|
||||
its IntgTesterSetup
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestGroupsRestoreIntgSuite(t *testing.T) {
|
||||
@ -355,20 +356,20 @@ func TestGroupsRestoreIntgSuite(t *testing.T) {
|
||||
}
|
||||
|
||||
func (suite *GroupsRestoreNightlyIntgSuite) SetupSuite() {
|
||||
suite.its = NewIntegrationTesterSetup(suite.T())
|
||||
suite.m365 = its.GetM365(suite.T())
|
||||
}
|
||||
|
||||
func (suite *GroupsRestoreNightlyIntgSuite) TestRestore_Run_groupsWithAdvancedOptions() {
|
||||
sel := selectors.NewGroupsBackup([]string{suite.its.Group.ID})
|
||||
sel := selectors.NewGroupsBackup([]string{suite.m365.Group.ID})
|
||||
sel.Include(selTD.GroupsBackupLibraryFolderScope(sel))
|
||||
sel.Filter(sel.Library("documents"))
|
||||
sel.DiscreteOwner = suite.its.Group.ID
|
||||
sel.DiscreteOwner = suite.m365.Group.ID
|
||||
|
||||
RunDriveRestoreWithAdvancedOptions(
|
||||
suite.T(),
|
||||
suite,
|
||||
suite.its.AC,
|
||||
suite.m365.AC,
|
||||
sel.Selector,
|
||||
suite.its.Group.RootSite.DriveID,
|
||||
suite.its.Group.RootSite.DriveRootFolderID)
|
||||
suite.m365.Group.RootSite.DriveID,
|
||||
suite.m365.Group.RootSite.DriveRootFolderID)
|
||||
}
|
||||
|
||||
@ -11,7 +11,6 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/alcionai/corso/src/internal/common/idname"
|
||||
"github.com/alcionai/corso/src/internal/common/ptr"
|
||||
"github.com/alcionai/corso/src/internal/data"
|
||||
"github.com/alcionai/corso/src/internal/kopia"
|
||||
"github.com/alcionai/corso/src/internal/m365"
|
||||
@ -19,8 +18,6 @@ import (
|
||||
odConsts "github.com/alcionai/corso/src/internal/m365/service/onedrive/consts"
|
||||
"github.com/alcionai/corso/src/internal/model"
|
||||
"github.com/alcionai/corso/src/internal/operations/inject"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
||||
"github.com/alcionai/corso/src/pkg/account"
|
||||
"github.com/alcionai/corso/src/pkg/backup"
|
||||
"github.com/alcionai/corso/src/pkg/backup/details"
|
||||
@ -357,125 +354,6 @@ func ControllerWithSelector(
|
||||
// Suite Setup
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
type IDs struct {
|
||||
ID string
|
||||
DriveID string
|
||||
DriveRootFolderID string
|
||||
}
|
||||
|
||||
type GIDs struct {
|
||||
ID string
|
||||
RootSite IDs
|
||||
}
|
||||
|
||||
type IntgTesterSetup struct {
|
||||
AC api.Client
|
||||
GockAC api.Client
|
||||
User IDs
|
||||
SecondaryUser IDs
|
||||
Site IDs
|
||||
SecondarySite IDs
|
||||
Group GIDs
|
||||
SecondaryGroup GIDs
|
||||
}
|
||||
|
||||
func NewIntegrationTesterSetup(t *testing.T) IntgTesterSetup {
|
||||
its := IntgTesterSetup{}
|
||||
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
graph.InitializeConcurrencyLimiter(ctx, true, 4)
|
||||
|
||||
a := tconfig.NewM365Account(t)
|
||||
creds, err := a.M365Config()
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
counter := count.New()
|
||||
|
||||
its.AC, err = api.NewClient(
|
||||
creds,
|
||||
control.DefaultOptions(),
|
||||
counter)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
its.GockAC, err = GockClient(creds, counter)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
its.User = userIDs(t, tconfig.M365UserID(t), its.AC)
|
||||
its.SecondaryUser = userIDs(t, tconfig.SecondaryM365UserID(t), its.AC)
|
||||
its.Site = siteIDs(t, tconfig.M365SiteID(t), its.AC)
|
||||
its.SecondarySite = siteIDs(t, tconfig.SecondaryM365SiteID(t), its.AC)
|
||||
// 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
|
||||
}
|
||||
|
||||
func userIDs(t *testing.T, id string, ac api.Client) IDs {
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
r := IDs{ID: id}
|
||||
|
||||
drive, err := ac.Users().GetDefaultDrive(ctx, id)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
r.DriveID = ptr.Val(drive.GetId())
|
||||
|
||||
driveRootFolder, err := ac.Drives().GetRootFolder(ctx, r.DriveID)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
r.DriveRootFolderID = ptr.Val(driveRootFolder.GetId())
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
func siteIDs(t *testing.T, id string, ac api.Client) IDs {
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
r := IDs{ID: id}
|
||||
|
||||
drive, err := ac.Sites().GetDefaultDrive(ctx, id)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
r.DriveID = ptr.Val(drive.GetId())
|
||||
|
||||
driveRootFolder, err := ac.Drives().GetRootFolder(ctx, r.DriveID)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
r.DriveRootFolderID = ptr.Val(driveRootFolder.GetId())
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
func groupIDs(t *testing.T, id string, ac api.Client) GIDs {
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
r := GIDs{ID: id}
|
||||
|
||||
site, err := ac.Groups().GetRootSite(ctx, id)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
r.RootSite.ID = ptr.Val(site.GetId())
|
||||
|
||||
drive, err := ac.Sites().GetDefaultDrive(ctx, r.RootSite.ID)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
r.RootSite.DriveID = ptr.Val(drive.GetId())
|
||||
|
||||
driveRootFolder, err := ac.Drives().GetRootFolder(ctx, r.RootSite.DriveID)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
r.RootSite.DriveRootFolderID = ptr.Val(driveRootFolder.GetId())
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
func GetTestExtensionFactories() []extensions.CreateItemExtensioner {
|
||||
return []extensions.CreateItemExtensioner{
|
||||
&extensions.MockItemExtensionFactory{},
|
||||
|
||||
@ -13,12 +13,13 @@ import (
|
||||
"github.com/alcionai/corso/src/internal/common/ptr"
|
||||
"github.com/alcionai/corso/src/internal/events"
|
||||
evmock "github.com/alcionai/corso/src/internal/events/mock"
|
||||
"github.com/alcionai/corso/src/internal/m365"
|
||||
m365Ctrl "github.com/alcionai/corso/src/internal/m365"
|
||||
"github.com/alcionai/corso/src/internal/m365/collection/drive"
|
||||
"github.com/alcionai/corso/src/internal/model"
|
||||
. "github.com/alcionai/corso/src/internal/operations/test/m365"
|
||||
"github.com/alcionai/corso/src/internal/streamstore"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/internal/tester/its"
|
||||
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
||||
"github.com/alcionai/corso/src/internal/version"
|
||||
"github.com/alcionai/corso/src/pkg/backup"
|
||||
@ -36,7 +37,7 @@ import (
|
||||
|
||||
type OneDriveBackupIntgSuite struct {
|
||||
tester.Suite
|
||||
its IntgTesterSetup
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestOneDriveBackupIntgSuite(t *testing.T) {
|
||||
@ -48,12 +49,12 @@ func TestOneDriveBackupIntgSuite(t *testing.T) {
|
||||
}
|
||||
|
||||
func (suite *OneDriveBackupIntgSuite) SetupSuite() {
|
||||
suite.its = NewIntegrationTesterSetup(suite.T())
|
||||
suite.m365 = its.GetM365(suite.T())
|
||||
}
|
||||
|
||||
func (suite *OneDriveBackupIntgSuite) TestBackup_Run_oneDrive() {
|
||||
var (
|
||||
resourceID = suite.its.SecondaryUser.ID
|
||||
resourceID = suite.m365.SecondaryUser.ID
|
||||
sel = selectors.NewOneDriveBackup([]string{resourceID})
|
||||
)
|
||||
|
||||
@ -67,12 +68,12 @@ func (suite *OneDriveBackupIntgSuite) TestBackup_Run_oneDrive() {
|
||||
}
|
||||
|
||||
func (suite *OneDriveBackupIntgSuite) TestBackup_Run_incrementalOneDrive() {
|
||||
runOneDriveIncrementalBackupTests(suite, suite.its, control.DefaultOptions())
|
||||
runOneDriveIncrementalBackupTests(suite, suite.m365, control.DefaultOptions())
|
||||
}
|
||||
|
||||
func (suite *OneDriveBackupIntgSuite) TestBackup_Run_extensionsOneDrive() {
|
||||
var (
|
||||
resourceID = suite.its.SecondaryUser.ID
|
||||
resourceID = suite.m365.SecondaryUser.ID
|
||||
sel = selectors.NewOneDriveBackup([]string{resourceID})
|
||||
)
|
||||
|
||||
@ -91,7 +92,7 @@ func (suite *OneDriveBackupIntgSuite) TestBackup_Run_extensionsOneDrive() {
|
||||
|
||||
type OneDriveBackupTreeIntgSuite struct {
|
||||
tester.Suite
|
||||
its IntgTesterSetup
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestOneDriveBackupTreeIntgSuite(t *testing.T) {
|
||||
@ -103,12 +104,12 @@ func TestOneDriveBackupTreeIntgSuite(t *testing.T) {
|
||||
}
|
||||
|
||||
func (suite *OneDriveBackupTreeIntgSuite) SetupSuite() {
|
||||
suite.its = NewIntegrationTesterSetup(suite.T())
|
||||
suite.m365 = its.GetM365(suite.T())
|
||||
}
|
||||
|
||||
func (suite *OneDriveBackupTreeIntgSuite) TestBackup_Run_treeOneDrive() {
|
||||
var (
|
||||
resourceID = suite.its.SecondaryUser.ID
|
||||
resourceID = suite.m365.SecondaryUser.ID
|
||||
sel = selectors.NewOneDriveBackup([]string{resourceID})
|
||||
opts = control.DefaultOptions()
|
||||
)
|
||||
@ -124,12 +125,12 @@ func (suite *OneDriveBackupTreeIntgSuite) TestBackup_Run_treeOneDrive() {
|
||||
|
||||
func (suite *OneDriveBackupTreeIntgSuite) TestBackup_Run_treeIncrementalOneDrive() {
|
||||
opts := control.DefaultOptions()
|
||||
runOneDriveIncrementalBackupTests(suite, suite.its, opts)
|
||||
runOneDriveIncrementalBackupTests(suite, suite.m365, opts)
|
||||
}
|
||||
|
||||
func (suite *OneDriveBackupTreeIntgSuite) TestBackup_Run_treeExtensionsOneDrive() {
|
||||
var (
|
||||
resourceID = suite.its.SecondaryUser.ID
|
||||
resourceID = suite.m365.SecondaryUser.ID
|
||||
sel = selectors.NewOneDriveBackup([]string{resourceID})
|
||||
opts = control.DefaultOptions()
|
||||
)
|
||||
@ -149,10 +150,10 @@ func (suite *OneDriveBackupTreeIntgSuite) TestBackup_Run_treeExtensionsOneDrive(
|
||||
|
||||
func runOneDriveIncrementalBackupTests(
|
||||
suite tester.Suite,
|
||||
its IntgTesterSetup,
|
||||
m365 its.M365IntgTestSetup,
|
||||
opts control.Options,
|
||||
) {
|
||||
sel := selectors.NewOneDriveRestore([]string{its.User.ID})
|
||||
sel := selectors.NewOneDriveRestore([]string{m365.User.ID})
|
||||
|
||||
ic := func(cs []string) selectors.Selector {
|
||||
sel.Include(sel.Folders(cs, selectors.PrefixMatch()))
|
||||
@ -163,10 +164,10 @@ func runOneDriveIncrementalBackupTests(
|
||||
t *testing.T,
|
||||
ctx context.Context,
|
||||
) string {
|
||||
d, err := its.AC.Users().GetDefaultDrive(ctx, its.User.ID)
|
||||
d, err := m365.AC.Users().GetDefaultDrive(ctx, m365.User.ID)
|
||||
if err != nil {
|
||||
err = clues.Wrap(err, "retrieving default user drive").
|
||||
With("user", its.User.ID)
|
||||
With("user", m365.User.ID)
|
||||
}
|
||||
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
@ -184,8 +185,8 @@ func runOneDriveIncrementalBackupTests(
|
||||
RunIncrementalDriveishBackupTest(
|
||||
suite,
|
||||
opts,
|
||||
its.User.ID,
|
||||
its.User.ID,
|
||||
m365.User.ID,
|
||||
m365.User.ID,
|
||||
path.OneDriveService,
|
||||
path.FilesCategory,
|
||||
ic,
|
||||
@ -219,7 +220,7 @@ func (suite *OneDriveBackupIntgSuite) TestBackup_Run_oneDriveOwnerMigration() {
|
||||
creds, err := acct.M365Config()
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
ctrl, err := m365.NewController(
|
||||
ctrl, err := m365Ctrl.NewController(
|
||||
ctx,
|
||||
acct,
|
||||
path.OneDriveService,
|
||||
@ -229,7 +230,7 @@ func (suite *OneDriveBackupIntgSuite) TestBackup_Run_oneDriveOwnerMigration() {
|
||||
|
||||
userable, err := ctrl.AC.Users().GetByID(
|
||||
ctx,
|
||||
suite.its.User.ID,
|
||||
suite.m365.User.ID,
|
||||
api.CallConfig{})
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
@ -333,7 +334,7 @@ func (suite *OneDriveBackupIntgSuite) TestBackup_Run_oneDriveOwnerMigration() {
|
||||
|
||||
type OneDriveBackupNightlyIntgSuite struct {
|
||||
tester.Suite
|
||||
its IntgTesterSetup
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestOneDriveBackupNightlyIntgSuite(t *testing.T) {
|
||||
@ -345,11 +346,11 @@ func TestOneDriveBackupNightlyIntgSuite(t *testing.T) {
|
||||
}
|
||||
|
||||
func (suite *OneDriveBackupNightlyIntgSuite) SetupSuite() {
|
||||
suite.its = NewIntegrationTesterSetup(suite.T())
|
||||
suite.m365 = its.GetM365(suite.T())
|
||||
}
|
||||
|
||||
func (suite *OneDriveBackupNightlyIntgSuite) TestBackup_Run_oneDriveVersion9MergeBase() {
|
||||
sel := selectors.NewOneDriveBackup([]string{suite.its.User.ID})
|
||||
sel := selectors.NewOneDriveBackup([]string{suite.m365.User.ID})
|
||||
sel.Include(selTD.OneDriveBackupFolderScope(sel))
|
||||
|
||||
RunMergeBaseGroupsUpdate(suite, sel.Selector, true)
|
||||
@ -364,7 +365,7 @@ func (suite *OneDriveBackupNightlyIntgSuite) TestBackup_Run_oneDriveVersion9Merg
|
||||
|
||||
type OneDriveRestoreNightlyIntgSuite struct {
|
||||
tester.Suite
|
||||
its IntgTesterSetup
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestOneDriveRestoreIntgSuite(t *testing.T) {
|
||||
@ -376,34 +377,34 @@ func TestOneDriveRestoreIntgSuite(t *testing.T) {
|
||||
}
|
||||
|
||||
func (suite *OneDriveRestoreNightlyIntgSuite) SetupSuite() {
|
||||
suite.its = NewIntegrationTesterSetup(suite.T())
|
||||
suite.m365 = its.GetM365(suite.T())
|
||||
}
|
||||
|
||||
func (suite *OneDriveRestoreNightlyIntgSuite) TestRestore_Run_onedriveWithAdvancedOptions() {
|
||||
sel := selectors.NewOneDriveBackup([]string{suite.its.User.ID})
|
||||
sel := selectors.NewOneDriveBackup([]string{suite.m365.User.ID})
|
||||
sel.Include(selTD.OneDriveBackupFolderScope(sel))
|
||||
sel.DiscreteOwner = suite.its.User.ID
|
||||
sel.DiscreteOwner = suite.m365.User.ID
|
||||
|
||||
RunDriveRestoreWithAdvancedOptions(
|
||||
suite.T(),
|
||||
suite,
|
||||
suite.its.AC,
|
||||
suite.m365.AC,
|
||||
sel.Selector,
|
||||
suite.its.User.DriveID,
|
||||
suite.its.User.DriveRootFolderID)
|
||||
suite.m365.User.DriveID,
|
||||
suite.m365.User.DriveRootFolderID)
|
||||
}
|
||||
|
||||
func (suite *OneDriveRestoreNightlyIntgSuite) TestRestore_Run_onedriveAlternateProtectedResource() {
|
||||
sel := selectors.NewOneDriveBackup([]string{suite.its.User.ID})
|
||||
sel := selectors.NewOneDriveBackup([]string{suite.m365.User.ID})
|
||||
sel.Include(selTD.OneDriveBackupFolderScope(sel))
|
||||
sel.DiscreteOwner = suite.its.User.ID
|
||||
sel.DiscreteOwner = suite.m365.User.ID
|
||||
|
||||
RunDriveRestoreToAlternateProtectedResource(
|
||||
suite.T(),
|
||||
suite,
|
||||
suite.its.AC,
|
||||
suite.m365.AC,
|
||||
sel.Selector,
|
||||
suite.its.User,
|
||||
suite.its.SecondaryUser,
|
||||
suite.its.SecondaryUser.ID)
|
||||
suite.m365.User,
|
||||
suite.m365.SecondaryUser,
|
||||
suite.m365.SecondaryUser.ID)
|
||||
}
|
||||
|
||||
@ -16,6 +16,7 @@ import (
|
||||
"github.com/alcionai/corso/src/internal/m365/collection/drive"
|
||||
. "github.com/alcionai/corso/src/internal/operations/test/m365"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/internal/tester/its"
|
||||
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
||||
"github.com/alcionai/corso/src/internal/version"
|
||||
deeTD "github.com/alcionai/corso/src/pkg/backup/details/testdata"
|
||||
@ -31,7 +32,7 @@ import (
|
||||
|
||||
type SharePointBackupIntgSuite struct {
|
||||
tester.Suite
|
||||
its IntgTesterSetup
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestSharePointBackupIntgSuite(t *testing.T) {
|
||||
@ -43,12 +44,12 @@ func TestSharePointBackupIntgSuite(t *testing.T) {
|
||||
}
|
||||
|
||||
func (suite *SharePointBackupIntgSuite) SetupSuite() {
|
||||
suite.its = NewIntegrationTesterSetup(suite.T())
|
||||
suite.m365 = its.GetM365(suite.T())
|
||||
}
|
||||
|
||||
func (suite *SharePointBackupIntgSuite) TestBackup_Run_sharePoint() {
|
||||
var (
|
||||
resourceID = suite.its.Site.ID
|
||||
resourceID = suite.m365.Site.ID
|
||||
sel = selectors.NewSharePointBackup([]string{resourceID})
|
||||
)
|
||||
|
||||
@ -68,7 +69,7 @@ func (suite *SharePointBackupIntgSuite) TestBackup_Run_sharePointList() {
|
||||
defer flush()
|
||||
|
||||
var (
|
||||
resourceID = suite.its.Site.ID
|
||||
resourceID = suite.m365.Site.ID
|
||||
sel = selectors.NewSharePointBackup([]string{resourceID})
|
||||
tenID = tconfig.M365TenantID(t)
|
||||
mb = evmock.NewBus()
|
||||
@ -123,12 +124,12 @@ func (suite *SharePointBackupIntgSuite) TestBackup_Run_sharePointList() {
|
||||
}
|
||||
|
||||
func (suite *SharePointBackupIntgSuite) TestBackup_Run_incrementalSharePoint() {
|
||||
runSharePointIncrementalBackupTests(suite, suite.its, control.DefaultOptions())
|
||||
runSharePointIncrementalBackupTests(suite, suite.m365, control.DefaultOptions())
|
||||
}
|
||||
|
||||
func (suite *SharePointBackupIntgSuite) TestBackup_Run_extensionsSharePoint() {
|
||||
var (
|
||||
resourceID = suite.its.Site.ID
|
||||
resourceID = suite.m365.Site.ID
|
||||
sel = selectors.NewSharePointBackup([]string{resourceID})
|
||||
)
|
||||
|
||||
@ -147,7 +148,7 @@ func (suite *SharePointBackupIntgSuite) TestBackup_Run_extensionsSharePoint() {
|
||||
|
||||
type SharePointBackupTreeIntgSuite struct {
|
||||
tester.Suite
|
||||
its IntgTesterSetup
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestSharePointBackupTreeIntgSuite(t *testing.T) {
|
||||
@ -159,12 +160,12 @@ func TestSharePointBackupTreeIntgSuite(t *testing.T) {
|
||||
}
|
||||
|
||||
func (suite *SharePointBackupTreeIntgSuite) SetupSuite() {
|
||||
suite.its = NewIntegrationTesterSetup(suite.T())
|
||||
suite.m365 = its.GetM365(suite.T())
|
||||
}
|
||||
|
||||
func (suite *SharePointBackupTreeIntgSuite) TestBackup_Run_treeSharePoint() {
|
||||
var (
|
||||
resourceID = suite.its.Site.ID
|
||||
resourceID = suite.m365.Site.ID
|
||||
sel = selectors.NewSharePointBackup([]string{resourceID})
|
||||
opts = control.DefaultOptions()
|
||||
)
|
||||
@ -180,12 +181,12 @@ func (suite *SharePointBackupTreeIntgSuite) TestBackup_Run_treeSharePoint() {
|
||||
|
||||
func (suite *SharePointBackupTreeIntgSuite) TestBackup_Run_treeIncrementalSharePoint() {
|
||||
opts := control.DefaultOptions()
|
||||
runSharePointIncrementalBackupTests(suite, suite.its, opts)
|
||||
runSharePointIncrementalBackupTests(suite, suite.m365, opts)
|
||||
}
|
||||
|
||||
func (suite *SharePointBackupTreeIntgSuite) TestBackup_Run_treeExtensionsSharePoint() {
|
||||
var (
|
||||
resourceID = suite.its.Site.ID
|
||||
resourceID = suite.m365.Site.ID
|
||||
sel = selectors.NewSharePointBackup([]string{resourceID})
|
||||
opts = control.DefaultOptions()
|
||||
)
|
||||
@ -205,10 +206,10 @@ func (suite *SharePointBackupTreeIntgSuite) TestBackup_Run_treeExtensionsSharePo
|
||||
|
||||
func runSharePointIncrementalBackupTests(
|
||||
suite tester.Suite,
|
||||
its IntgTesterSetup,
|
||||
m365 its.M365IntgTestSetup,
|
||||
opts control.Options,
|
||||
) {
|
||||
sel := selectors.NewSharePointRestore([]string{its.Site.ID})
|
||||
sel := selectors.NewSharePointRestore([]string{m365.Site.ID})
|
||||
|
||||
ic := func(cs []string) selectors.Selector {
|
||||
sel.Include(sel.LibraryFolders(cs, selectors.PrefixMatch()))
|
||||
@ -219,10 +220,10 @@ func runSharePointIncrementalBackupTests(
|
||||
t *testing.T,
|
||||
ctx context.Context,
|
||||
) string {
|
||||
d, err := its.AC.Sites().GetDefaultDrive(ctx, its.Site.ID)
|
||||
d, err := m365.AC.Sites().GetDefaultDrive(ctx, m365.Site.ID)
|
||||
if err != nil {
|
||||
err = clues.Wrap(err, "retrieving default site drive").
|
||||
With("site", its.Site.ID)
|
||||
With("site", m365.Site.ID)
|
||||
}
|
||||
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
@ -240,8 +241,8 @@ func runSharePointIncrementalBackupTests(
|
||||
RunIncrementalDriveishBackupTest(
|
||||
suite,
|
||||
opts,
|
||||
its.Site.ID,
|
||||
its.User.ID,
|
||||
m365.Site.ID,
|
||||
m365.User.ID,
|
||||
path.SharePointService,
|
||||
path.LibrariesCategory,
|
||||
ic,
|
||||
@ -253,7 +254,7 @@ func runSharePointIncrementalBackupTests(
|
||||
|
||||
type SharePointBackupNightlyIntgSuite struct {
|
||||
tester.Suite
|
||||
its IntgTesterSetup
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestSharePointBackupNightlyIntgSuite(t *testing.T) {
|
||||
@ -265,18 +266,18 @@ func TestSharePointBackupNightlyIntgSuite(t *testing.T) {
|
||||
}
|
||||
|
||||
func (suite *SharePointBackupNightlyIntgSuite) SetupSuite() {
|
||||
suite.its = NewIntegrationTesterSetup(suite.T())
|
||||
suite.m365 = its.GetM365(suite.T())
|
||||
}
|
||||
|
||||
func (suite *SharePointBackupNightlyIntgSuite) TestBackup_Run_sharePointVersion9MergeBase() {
|
||||
sel := selectors.NewSharePointBackup([]string{suite.its.Site.ID})
|
||||
sel := selectors.NewSharePointBackup([]string{suite.m365.Site.ID})
|
||||
sel.Include(selTD.SharePointBackupFolderScope(sel))
|
||||
|
||||
RunMergeBaseGroupsUpdate(suite, sel.Selector, true)
|
||||
}
|
||||
|
||||
func (suite *SharePointBackupNightlyIntgSuite) TestBackup_Run_sharePointVersion9AssistBases() {
|
||||
sel := selectors.NewSharePointBackup([]string{suite.its.Site.ID})
|
||||
sel := selectors.NewSharePointBackup([]string{suite.m365.Site.ID})
|
||||
sel.Include(selTD.SharePointBackupFolderScope(sel))
|
||||
|
||||
RunDriveAssistBaseGroupsUpdate(suite, sel.Selector, true)
|
||||
@ -284,7 +285,7 @@ func (suite *SharePointBackupNightlyIntgSuite) TestBackup_Run_sharePointVersion9
|
||||
|
||||
type SharePointRestoreNightlyIntgSuite struct {
|
||||
tester.Suite
|
||||
its IntgTesterSetup
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestSharePointRestoreIntgSuite(t *testing.T) {
|
||||
@ -296,38 +297,38 @@ func TestSharePointRestoreIntgSuite(t *testing.T) {
|
||||
}
|
||||
|
||||
func (suite *SharePointRestoreNightlyIntgSuite) SetupSuite() {
|
||||
suite.its = NewIntegrationTesterSetup(suite.T())
|
||||
suite.m365 = its.GetM365(suite.T())
|
||||
}
|
||||
|
||||
func (suite *SharePointRestoreNightlyIntgSuite) TestRestore_Run_sharepointWithAdvancedOptions() {
|
||||
sel := selectors.NewSharePointBackup([]string{suite.its.Site.ID})
|
||||
sel := selectors.NewSharePointBackup([]string{suite.m365.Site.ID})
|
||||
sel.Include(selTD.SharePointBackupFolderScope(sel))
|
||||
sel.Filter(sel.Library("documents"))
|
||||
sel.DiscreteOwner = suite.its.Site.ID
|
||||
sel.DiscreteOwner = suite.m365.Site.ID
|
||||
|
||||
RunDriveRestoreWithAdvancedOptions(
|
||||
suite.T(),
|
||||
suite,
|
||||
suite.its.AC,
|
||||
suite.m365.AC,
|
||||
sel.Selector,
|
||||
suite.its.Site.DriveID,
|
||||
suite.its.Site.DriveRootFolderID)
|
||||
suite.m365.Site.DriveID,
|
||||
suite.m365.Site.DriveRootFolderID)
|
||||
}
|
||||
|
||||
func (suite *SharePointRestoreNightlyIntgSuite) TestRestore_Run_sharepointAlternateProtectedResource() {
|
||||
sel := selectors.NewSharePointBackup([]string{suite.its.Site.ID})
|
||||
sel := selectors.NewSharePointBackup([]string{suite.m365.Site.ID})
|
||||
sel.Include(selTD.SharePointBackupFolderScope(sel))
|
||||
sel.Filter(sel.Library("documents"))
|
||||
sel.DiscreteOwner = suite.its.Site.ID
|
||||
sel.DiscreteOwner = suite.m365.Site.ID
|
||||
|
||||
RunDriveRestoreToAlternateProtectedResource(
|
||||
suite.T(),
|
||||
suite,
|
||||
suite.its.AC,
|
||||
suite.m365.AC,
|
||||
sel.Selector,
|
||||
suite.its.Site,
|
||||
suite.its.SecondarySite,
|
||||
suite.its.SecondarySite.ID)
|
||||
suite.m365.Site,
|
||||
suite.m365.SecondarySite,
|
||||
suite.m365.SecondarySite.ID)
|
||||
}
|
||||
|
||||
func (suite *SharePointRestoreNightlyIntgSuite) TestRestore_Run_sharepointDeletedDrives() {
|
||||
@ -344,13 +345,13 @@ func (suite *SharePointRestoreNightlyIntgSuite) TestRestore_Run_sharepointDelete
|
||||
rc.OnCollision = control.Copy
|
||||
|
||||
// create a new drive
|
||||
md, err := suite.its.AC.Lists().PostDrive(ctx, suite.its.Site.ID, rc.Location)
|
||||
md, err := suite.m365.AC.Lists().PostDrive(ctx, suite.m365.Site.ID, rc.Location)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
driveID := ptr.Val(md.GetId())
|
||||
|
||||
// get the root folder
|
||||
mdi, err := suite.its.AC.Drives().GetRootFolder(ctx, driveID)
|
||||
mdi, err := suite.m365.AC.Drives().GetRootFolder(ctx, driveID)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
rootFolderID := ptr.Val(mdi.GetId())
|
||||
@ -364,7 +365,7 @@ func (suite *SharePointRestoreNightlyIntgSuite) TestRestore_Run_sharepointDelete
|
||||
file := models.NewFile()
|
||||
item.SetFile(file)
|
||||
|
||||
_, err = suite.its.AC.Drives().PostItemInContainer(
|
||||
_, err = suite.m365.AC.Drives().PostItemInContainer(
|
||||
ctx,
|
||||
driveID,
|
||||
rootFolderID,
|
||||
@ -377,13 +378,13 @@ func (suite *SharePointRestoreNightlyIntgSuite) TestRestore_Run_sharepointDelete
|
||||
mb = evmock.NewBus()
|
||||
counter = count.New()
|
||||
opts = control.DefaultOptions()
|
||||
graphClient = suite.its.AC.Stable.Client()
|
||||
graphClient = suite.m365.AC.Stable.Client()
|
||||
)
|
||||
|
||||
bsel := selectors.NewSharePointBackup([]string{suite.its.Site.ID})
|
||||
bsel := selectors.NewSharePointBackup([]string{suite.m365.Site.ID})
|
||||
bsel.Include(selTD.SharePointBackupFolderScope(bsel))
|
||||
bsel.Filter(bsel.Library(rc.Location))
|
||||
bsel.DiscreteOwner = suite.its.Site.ID
|
||||
bsel.DiscreteOwner = suite.m365.Site.ID
|
||||
|
||||
bo, bod := PrepNewTestBackupOp(t, ctx, mb, bsel.Selector, opts, version.Backup, counter)
|
||||
defer bod.Close(t, ctx)
|
||||
@ -481,9 +482,9 @@ func (suite *SharePointRestoreNightlyIntgSuite) TestRestore_Run_sharepointDelete
|
||||
RunAndCheckRestore(t, ctx, &ro, mb, false)
|
||||
assert.Equal(t, 1, ctr.Get(count.NewItemCreated), "restored an item")
|
||||
|
||||
pgr := suite.its.AC.
|
||||
pgr := suite.m365.AC.
|
||||
Drives().
|
||||
NewSiteDrivePager(suite.its.Site.ID, []string{"id", "name"})
|
||||
NewSiteDrivePager(suite.m365.Site.ID, []string{"id", "name"})
|
||||
|
||||
drives, err := api.GetAllDrives(ctx, pgr)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
@ -502,7 +503,7 @@ func (suite *SharePointRestoreNightlyIntgSuite) TestRestore_Run_sharepointDelete
|
||||
md = created
|
||||
driveID = ptr.Val(md.GetId())
|
||||
|
||||
mdi, err := suite.its.AC.Drives().GetRootFolder(ctx, driveID)
|
||||
mdi, err := suite.m365.AC.Drives().GetRootFolder(ctx, driveID)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
rootFolderID = ptr.Val(mdi.GetId())
|
||||
|
||||
258
src/internal/tester/its/m365.go
Normal file
258
src/internal/tester/its/m365.go
Normal file
@ -0,0 +1,258 @@
|
||||
package its
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/alcionai/clues"
|
||||
"github.com/h2non/gock"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/alcionai/corso/src/internal/common/idname"
|
||||
"github.com/alcionai/corso/src/internal/common/ptr"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
||||
"github.com/alcionai/corso/src/pkg/account"
|
||||
"github.com/alcionai/corso/src/pkg/control"
|
||||
"github.com/alcionai/corso/src/pkg/count"
|
||||
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
||||
"github.com/alcionai/corso/src/pkg/services/m365/api/graph"
|
||||
)
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Gockable client
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// GockClient produces a new exchange api client that can be
|
||||
// mocked using gock.
|
||||
func gockClient(creds account.M365Config, counter *count.Bus) (api.Client, error) {
|
||||
s, err := graph.NewGockService(creds, counter)
|
||||
if err != nil {
|
||||
return api.Client{}, err
|
||||
}
|
||||
|
||||
li, err := graph.NewGockService(creds, counter, graph.NoTimeout())
|
||||
if err != nil {
|
||||
return api.Client{}, err
|
||||
}
|
||||
|
||||
return api.Client{
|
||||
Credentials: creds,
|
||||
Stable: s,
|
||||
LargeItem: li,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Intercepting calls with Gock
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const graphAPIHostURL = "https://graph.microsoft.com"
|
||||
|
||||
func V1APIURLPath(parts ...string) string {
|
||||
return strings.Join(append([]string{"/v1.0"}, parts...), "/")
|
||||
}
|
||||
|
||||
func InterceptV1Path(pathParts ...string) *gock.Request {
|
||||
return gock.New(graphAPIHostURL).Get(V1APIURLPath(pathParts...))
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Suite Setup
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
type IDs struct {
|
||||
Provider idname.Provider
|
||||
ID string
|
||||
Email string
|
||||
DisplayName string
|
||||
DriveID string
|
||||
DriveRootFolderID string
|
||||
WebURL string
|
||||
// TestContainerID is used to store the ID of the primary container under
|
||||
// test. Normally this will be empty, but in certain services or data
|
||||
// categories, especially those where we don't have canonical containers
|
||||
// to isolate for testing, we may specify a TestContainer here instead.
|
||||
TestContainerID string
|
||||
// a "RootSite" is used by resources that own one or more sites.
|
||||
// ex: groups and teams. Each of those resources should designate
|
||||
// a "root" site (aka: the "default" site). That site gets embedded
|
||||
// here because we probably interface with it as its own resource
|
||||
// within the drive processors.
|
||||
RootSite struct {
|
||||
Provider idname.Provider
|
||||
ID string
|
||||
DisplayName string
|
||||
DriveID string
|
||||
DriveRootFolderID string
|
||||
WebURL string
|
||||
}
|
||||
}
|
||||
|
||||
// M365IntgTestSetup provides all the common references used in an m365 integration
|
||||
// test suite. Call `its.GetM365()` to get the singleton for your test suite.
|
||||
// If you're looking for unit testing setup, use `uts.GetM365()` instead.
|
||||
type M365IntgTestSetup struct {
|
||||
Acct account.Account
|
||||
Creds account.M365Config
|
||||
TenantID string
|
||||
|
||||
AC api.Client
|
||||
GockAC api.Client
|
||||
|
||||
Site IDs
|
||||
SecondarySite IDs
|
||||
|
||||
Group IDs
|
||||
SecondaryGroup IDs
|
||||
|
||||
User IDs
|
||||
SecondaryUser IDs
|
||||
TertiaryUser IDs
|
||||
}
|
||||
|
||||
// GetM365 returns the populated its.m365 singleton.
|
||||
func GetM365(t *testing.T) M365IntgTestSetup {
|
||||
var err error
|
||||
|
||||
setup := M365IntgTestSetup{}
|
||||
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
graph.InitializeConcurrencyLimiter(ctx, true, 4)
|
||||
|
||||
setup.Acct = tconfig.NewM365Account(t)
|
||||
setup.Creds, err = setup.Acct.M365Config()
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
setup.TenantID = setup.Creds.AzureTenantID
|
||||
|
||||
setup.AC, err = api.NewClient(setup.Creds, control.DefaultOptions(), count.New())
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
setup.GockAC, err = gockClient(setup.Creds, count.New())
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
// users
|
||||
|
||||
fillUser(t, setup.AC, tconfig.M365UserID(t), &setup.User)
|
||||
fillUser(t, setup.AC, tconfig.SecondaryM365UserID(t), &setup.SecondaryUser)
|
||||
fillUser(t, setup.AC, tconfig.TertiaryM365UserID(t), &setup.TertiaryUser)
|
||||
|
||||
// site
|
||||
|
||||
fillSite(t, setup.AC, tconfig.M365SiteID(t), &setup.Site)
|
||||
fillSite(t, setup.AC, tconfig.SecondaryM365SiteID(t), &setup.SecondarySite)
|
||||
|
||||
// team
|
||||
|
||||
fillTeam(t, setup.AC, tconfig.M365TeamID(t), &setup.Group)
|
||||
fillTeam(t, setup.AC, tconfig.SecondaryM365TeamID(t), &setup.SecondaryGroup)
|
||||
|
||||
return setup
|
||||
}
|
||||
|
||||
func fillUser(
|
||||
t *testing.T,
|
||||
ac api.Client,
|
||||
uid string,
|
||||
ids *IDs,
|
||||
) {
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
ids.ID = tconfig.M365UserID(t)
|
||||
|
||||
user, err := ac.Users().GetByID(ctx, uid, api.CallConfig{})
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
ids.ID = ptr.Val(user.GetId())
|
||||
ids.Email = ptr.Val(user.GetUserPrincipalName())
|
||||
ids.Provider = idname.NewProvider(ids.ID, ids.Email)
|
||||
ids.DisplayName = ptr.Val(user.GetDisplayName())
|
||||
|
||||
drive, err := ac.Users().GetDefaultDrive(ctx, ids.ID)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
ids.DriveID = ptr.Val(drive.GetId())
|
||||
|
||||
rootFolder, err := ac.Drives().GetRootFolder(ctx, ids.DriveID)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
ids.DriveRootFolderID = ptr.Val(rootFolder.GetId())
|
||||
}
|
||||
|
||||
func fillSite(
|
||||
t *testing.T,
|
||||
ac api.Client,
|
||||
sid string,
|
||||
ids *IDs,
|
||||
) {
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
site, err := ac.Sites().GetByID(ctx, sid, api.CallConfig{})
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
ids.ID = ptr.Val(site.GetId())
|
||||
ids.WebURL = ptr.Val(site.GetWebUrl())
|
||||
ids.Provider = idname.NewProvider(ids.ID, ids.WebURL)
|
||||
ids.DisplayName = ptr.Val(site.GetDisplayName())
|
||||
|
||||
drive, err := ac.Sites().GetDefaultDrive(ctx, ids.ID)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
ids.DriveID = ptr.Val(drive.GetId())
|
||||
|
||||
rootFolder, err := ac.Drives().GetRootFolder(ctx, ids.DriveID)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
ids.DriveRootFolderID = ptr.Val(rootFolder.GetId())
|
||||
}
|
||||
|
||||
func fillTeam(
|
||||
t *testing.T,
|
||||
ac api.Client,
|
||||
gid string,
|
||||
ids *IDs,
|
||||
) {
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
team, err := ac.Groups().GetByID(ctx, gid, api.CallConfig{})
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
ids.ID = ptr.Val(team.GetId())
|
||||
ids.Email = ptr.Val(team.GetMail())
|
||||
ids.Provider = idname.NewProvider(ids.ID, ids.Email)
|
||||
ids.DisplayName = ptr.Val(team.GetDisplayName())
|
||||
|
||||
channel, err := ac.Channels().
|
||||
GetChannelByName(
|
||||
ctx,
|
||||
ids.ID,
|
||||
"Test")
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
require.Equal(t, "Test", ptr.Val(channel.GetDisplayName()))
|
||||
|
||||
ids.TestContainerID = ptr.Val(channel.GetId())
|
||||
|
||||
site, err := ac.Groups().GetRootSite(ctx, gid)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
ids.RootSite.ID = ptr.Val(site.GetId())
|
||||
ids.RootSite.WebURL = ptr.Val(site.GetWebUrl())
|
||||
ids.RootSite.DisplayName = ptr.Val(site.GetDisplayName())
|
||||
ids.RootSite.Provider = idname.NewProvider(ids.RootSite.ID, ids.RootSite.WebURL)
|
||||
|
||||
drive, err := ac.Sites().GetDefaultDrive(ctx, ids.RootSite.ID)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
ids.RootSite.DriveID = ptr.Val(drive.GetId())
|
||||
|
||||
rootFolder, err := ac.Drives().GetRootFolder(ctx, ids.RootSite.DriveID)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
ids.RootSite.DriveRootFolderID = ptr.Val(rootFolder.GetId())
|
||||
}
|
||||
154
src/internal/tester/its/m365_test.go
Normal file
154
src/internal/tester/its/m365_test.go
Normal file
@ -0,0 +1,154 @@
|
||||
package its
|
||||
|
||||
import (
|
||||
"slices"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
||||
storeTD "github.com/alcionai/corso/src/pkg/storage/testdata"
|
||||
)
|
||||
|
||||
type M365IntgSuite struct {
|
||||
tester.Suite
|
||||
}
|
||||
|
||||
func TestM365IntgSuite(t *testing.T) {
|
||||
suite.Run(t, &M365IntgSuite{
|
||||
Suite: tester.NewIntegrationSuite(
|
||||
t,
|
||||
[][]string{tconfig.M365AcctCredEnvs, storeTD.AWSStorageCredEnvs}),
|
||||
})
|
||||
}
|
||||
|
||||
func (suite *M365IntgSuite) TestGetM365() {
|
||||
t := suite.T()
|
||||
result := GetM365(t)
|
||||
|
||||
assert.NotEmpty(t, result.Acct)
|
||||
assert.NotEmpty(t, result.Creds)
|
||||
assert.NotEmpty(t, result.AC)
|
||||
assert.NotEmpty(t, result.GockAC)
|
||||
assert.NotEmpty(t, result.TenantID)
|
||||
|
||||
var (
|
||||
none = []string{}
|
||||
expectSite = []string{id, weburl, provider, displayname, driveid, driverootfolderid}
|
||||
expectRootSite = []string{id, weburl, provider, displayname, driveid, driverootfolderid}
|
||||
expectGroup = []string{id, email, provider, displayname, testcontainerid}
|
||||
expectUser = []string{id, email, provider, displayname, driveid, driverootfolderid}
|
||||
)
|
||||
|
||||
assertIDs(t, result.Site, expectSite, none)
|
||||
assertIDs(t, result.SecondarySite, expectSite, none)
|
||||
assertIDs(t, result.Group, expectGroup, expectRootSite)
|
||||
assertIDs(t, result.SecondaryGroup, expectGroup, expectRootSite)
|
||||
assertIDs(t, result.User, expectUser, none)
|
||||
assertIDs(t, result.SecondaryUser, expectUser, none)
|
||||
assertIDs(t, result.TertiaryUser, expectUser, none)
|
||||
}
|
||||
|
||||
const (
|
||||
provider = "provider"
|
||||
id = "id"
|
||||
email = "email"
|
||||
displayname = "displayname"
|
||||
driveid = "driveid"
|
||||
driverootfolderid = "driverootfolderid"
|
||||
testcontainerid = "testcontainerid"
|
||||
weburl = "weburl"
|
||||
)
|
||||
|
||||
func assertIDs(
|
||||
t *testing.T,
|
||||
ids IDs,
|
||||
expect []string,
|
||||
expectRootSite []string,
|
||||
) {
|
||||
assert.NotEmpty(t, ids)
|
||||
|
||||
if slices.Contains(expect, provider) {
|
||||
assert.NotNil(t, ids.Provider)
|
||||
assert.NotEmpty(t, ids.Provider.ID())
|
||||
assert.NotEmpty(t, ids.Provider.Name())
|
||||
} else {
|
||||
assert.Nil(t, ids.Provider)
|
||||
}
|
||||
|
||||
if slices.Contains(expect, id) {
|
||||
assert.NotEmpty(t, ids.ID)
|
||||
} else {
|
||||
assert.Empty(t, ids.ID)
|
||||
}
|
||||
|
||||
if slices.Contains(expect, email) {
|
||||
assert.NotEmpty(t, ids.Email)
|
||||
} else {
|
||||
assert.Empty(t, ids.Email)
|
||||
}
|
||||
|
||||
if slices.Contains(expect, driveid) {
|
||||
assert.NotEmpty(t, ids.DriveID)
|
||||
} else {
|
||||
assert.Empty(t, ids.DriveID)
|
||||
}
|
||||
|
||||
if slices.Contains(expect, driverootfolderid) {
|
||||
assert.NotEmpty(t, ids.DriveRootFolderID)
|
||||
} else {
|
||||
assert.Empty(t, ids.DriveRootFolderID)
|
||||
}
|
||||
|
||||
if slices.Contains(expect, testcontainerid) {
|
||||
assert.NotEmpty(t, ids.TestContainerID)
|
||||
} else {
|
||||
assert.Empty(t, ids.TestContainerID)
|
||||
}
|
||||
|
||||
if slices.Contains(expect, weburl) {
|
||||
assert.NotEmpty(t, ids.WebURL)
|
||||
} else {
|
||||
assert.Empty(t, ids.WebURL)
|
||||
}
|
||||
|
||||
if slices.Contains(expectRootSite, provider) {
|
||||
assert.NotNil(t, ids.RootSite.Provider)
|
||||
assert.NotEmpty(t, ids.RootSite.Provider.ID())
|
||||
assert.NotEmpty(t, ids.RootSite.Provider.Name())
|
||||
} else {
|
||||
assert.Nil(t, ids.RootSite.Provider)
|
||||
}
|
||||
|
||||
if slices.Contains(expectRootSite, id) {
|
||||
assert.NotEmpty(t, ids.RootSite.ID)
|
||||
} else {
|
||||
assert.Empty(t, ids.RootSite.ID)
|
||||
}
|
||||
|
||||
if slices.Contains(expectRootSite, driveid) {
|
||||
assert.NotEmpty(t, ids.RootSite.DriveID)
|
||||
} else {
|
||||
assert.Empty(t, ids.RootSite.DriveID)
|
||||
}
|
||||
|
||||
if slices.Contains(expectRootSite, displayname) {
|
||||
assert.NotEmpty(t, ids.RootSite.DisplayName)
|
||||
} else {
|
||||
assert.Empty(t, ids.RootSite.DisplayName)
|
||||
}
|
||||
|
||||
if slices.Contains(expectRootSite, driverootfolderid) {
|
||||
assert.NotEmpty(t, ids.RootSite.DriveRootFolderID)
|
||||
} else {
|
||||
assert.Empty(t, ids.RootSite.DriveRootFolderID)
|
||||
}
|
||||
|
||||
if slices.Contains(expectRootSite, weburl) {
|
||||
assert.NotEmpty(t, ids.RootSite.WebURL)
|
||||
} else {
|
||||
assert.Empty(t, ids.RootSite.WebURL)
|
||||
}
|
||||
}
|
||||
30
src/internal/tester/its/resourceService.go
Normal file
30
src/internal/tester/its/resourceService.go
Normal file
@ -0,0 +1,30 @@
|
||||
package its
|
||||
|
||||
import "github.com/alcionai/corso/src/pkg/path"
|
||||
|
||||
type ResourceServicer interface {
|
||||
Resource() IDs
|
||||
Service() path.ServiceType
|
||||
}
|
||||
|
||||
var _ ResourceServicer = resourceAndService{}
|
||||
|
||||
type resourceAndService struct {
|
||||
protectedResource IDs
|
||||
serviceType path.ServiceType
|
||||
}
|
||||
|
||||
func (ras resourceAndService) Resource() IDs {
|
||||
return ras.protectedResource
|
||||
}
|
||||
|
||||
func (ras resourceAndService) Service() path.ServiceType {
|
||||
return ras.serviceType
|
||||
}
|
||||
|
||||
func NewResourceService(r IDs, s path.ServiceType) ResourceServicer {
|
||||
return &resourceAndService{
|
||||
protectedResource: r,
|
||||
serviceType: s,
|
||||
}
|
||||
}
|
||||
@ -37,10 +37,10 @@ func NewFakeM365Account(t *testing.T) account.Account {
|
||||
account.ProviderM365,
|
||||
account.M365Config{
|
||||
M365: credentials.M365{
|
||||
AzureClientID: "12345",
|
||||
AzureClientSecret: "abcde",
|
||||
AzureClientID: "client-12345",
|
||||
AzureClientSecret: "secret-abcde",
|
||||
},
|
||||
AzureTenantID: "09876",
|
||||
AzureTenantID: "tenant-09876",
|
||||
})
|
||||
require.NoError(t, err, "initializing mock account", clues.ToCore(err))
|
||||
|
||||
|
||||
@ -16,6 +16,7 @@ import (
|
||||
"github.com/alcionai/corso/src/cli/flags"
|
||||
"github.com/alcionai/corso/src/internal/common/str"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/internal/tester/its"
|
||||
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
||||
"github.com/alcionai/corso/src/pkg/account"
|
||||
"github.com/alcionai/corso/src/pkg/control/repository"
|
||||
@ -399,6 +400,7 @@ func (suite *ConfigSuite) TestReadFromFlags() {
|
||||
|
||||
type ConfigIntegrationSuite struct {
|
||||
tester.Suite
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestConfigIntegrationSuite(t *testing.T) {
|
||||
@ -407,6 +409,10 @@ func TestConfigIntegrationSuite(t *testing.T) {
|
||||
[][]string{storeTD.AWSStorageCredEnvs, tconfig.M365AcctCredEnvs})})
|
||||
}
|
||||
|
||||
func (suite *ConfigIntegrationSuite) SetupSuite() {
|
||||
suite.m365 = its.GetM365(suite.T())
|
||||
}
|
||||
|
||||
func (suite *ConfigIntegrationSuite) TestGetStorageAndAccount() {
|
||||
t := suite.T()
|
||||
vpr := viper.New()
|
||||
@ -418,7 +424,6 @@ func (suite *ConfigIntegrationSuite) TestGetStorageAndAccount() {
|
||||
bkt = "get-storage-and-account-bucket"
|
||||
end = "https://get-storage-and-account.com"
|
||||
pfx = "get-storage-and-account-prefix/"
|
||||
tid = "3a2faa4e-a882-445c-9d27-f552ef189381"
|
||||
)
|
||||
|
||||
// Configure viper to read test config file
|
||||
@ -434,9 +439,10 @@ func (suite *ConfigIntegrationSuite) TestGetStorageAndAccount() {
|
||||
DoNotVerifyTLS: true,
|
||||
DoNotUseTLS: true,
|
||||
}
|
||||
m365 := account.M365Config{AzureTenantID: tid}
|
||||
|
||||
err = writeRepoConfigWithViper(vpr, s3Cfg, m365, repository.Options{}, "repoid")
|
||||
creds := suite.m365.Creds
|
||||
|
||||
err = writeRepoConfigWithViper(vpr, s3Cfg, creds, repository.Options{}, "repoid")
|
||||
require.NoError(t, err, "writing repo config", clues.ToCore(err))
|
||||
|
||||
require.Equal(
|
||||
@ -484,13 +490,12 @@ func (suite *ConfigIntegrationSuite) TestGetStorageAndAccount_noFileOnlyOverride
|
||||
bkt = "get-storage-and-account-no-file-bucket"
|
||||
end = "https://get-storage-and-account.com/no-file"
|
||||
pfx = "get-storage-and-account-no-file-prefix/"
|
||||
tid = "88f8522b-18e4-4d0f-b514-2d7b34d4c5a1"
|
||||
)
|
||||
|
||||
m365 := account.M365Config{AzureTenantID: tid}
|
||||
creds := suite.m365.Creds
|
||||
|
||||
overrides := map[string]string{
|
||||
account.AzureTenantID: tid,
|
||||
account.AzureTenantID: suite.m365.TenantID,
|
||||
account.AccountProviderTypeKey: account.ProviderM365.String(),
|
||||
storage.Bucket: bkt,
|
||||
storage.Endpoint: end,
|
||||
@ -519,7 +524,7 @@ func (suite *ConfigIntegrationSuite) TestGetStorageAndAccount_noFileOnlyOverride
|
||||
|
||||
readM365, err := cfg.Account.M365Config()
|
||||
require.NoError(t, err, "reading m365 config from account", clues.ToCore(err))
|
||||
assert.Equal(t, readM365.AzureTenantID, m365.AzureTenantID)
|
||||
assert.Equal(t, readM365.AzureTenantID, creds.AzureTenantID)
|
||||
assert.Equal(t, readM365.AzureClientID, os.Getenv(credentials.AzureClientID))
|
||||
assert.Equal(t, readM365.AzureClientSecret, os.Getenv(credentials.AzureClientSecret))
|
||||
}
|
||||
|
||||
@ -523,16 +523,16 @@ func (c Events) PostLargeAttachment(
|
||||
return "", clues.Wrap(err, "uploading large event attachment")
|
||||
}
|
||||
|
||||
url := ptr.Val(us.GetUploadUrl())
|
||||
w := graph.NewLargeItemWriter(parentItemID, url, size, c.counter)
|
||||
copyBuffer := make([]byte, graph.AttachmentChunkSize)
|
||||
var (
|
||||
url = ptr.Val(us.GetUploadUrl())
|
||||
w = graph.NewLargeItemWriter(parentItemID, url, size, c.counter)
|
||||
reader = bytes.NewReader(content)
|
||||
copyBuffer = make([]byte, graph.AttachmentChunkSize)
|
||||
)
|
||||
|
||||
_, err = io.CopyBuffer(w, bytes.NewReader(content), copyBuffer)
|
||||
if err != nil {
|
||||
return "", clues.WrapWC(ctx, err, "buffering large attachment content")
|
||||
}
|
||||
_, err = io.CopyBuffer(w, reader, copyBuffer)
|
||||
|
||||
return w.ID, nil
|
||||
return w.ID, clues.WrapWC(ctx, err, "buffering large attachment content").OrNil()
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@ -241,27 +241,30 @@ func (suite *EventsAPIIntgSuite) TestEvents_RestoreLargeAttachment() {
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
userID := tconfig.M365UserID(suite.T())
|
||||
var (
|
||||
evts = suite.its.ac.Events()
|
||||
userID = suite.its.user.id
|
||||
folderName = testdata.DefaultRestoreConfig("eventlargeattachmenttest").Location
|
||||
tomorrow = time.Now().Add(24 * time.Hour)
|
||||
item models.Eventable
|
||||
start = models.NewDateTimeTimeZone()
|
||||
end = models.NewDateTimeTimeZone()
|
||||
)
|
||||
|
||||
folderName := testdata.DefaultRestoreConfig("eventlargeattachmenttest").Location
|
||||
evts := suite.its.ac.Events()
|
||||
calendar, err := evts.CreateContainer(ctx, userID, "", folderName)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
tomorrow := time.Now().Add(24 * time.Hour)
|
||||
evt := models.NewEvent()
|
||||
sdtz := models.NewDateTimeTimeZone()
|
||||
edtz := models.NewDateTimeTimeZone()
|
||||
start.SetDateTime(ptr.To(dttm.Format(tomorrow)))
|
||||
start.SetTimeZone(ptr.To("UTC"))
|
||||
end.SetDateTime(ptr.To(dttm.Format(tomorrow.Add(30 * time.Minute))))
|
||||
end.SetTimeZone(ptr.To("UTC"))
|
||||
|
||||
evt.SetSubject(ptr.To("Event with attachment"))
|
||||
sdtz.SetDateTime(ptr.To(dttm.Format(tomorrow)))
|
||||
sdtz.SetTimeZone(ptr.To("UTC"))
|
||||
edtz.SetDateTime(ptr.To(dttm.Format(tomorrow.Add(30 * time.Minute))))
|
||||
edtz.SetTimeZone(ptr.To("UTC"))
|
||||
evt.SetStart(sdtz)
|
||||
evt.SetEnd(edtz)
|
||||
item = models.NewEvent()
|
||||
item.SetSubject(ptr.To("Event with attachment"))
|
||||
item.SetStart(start)
|
||||
item.SetEnd(end)
|
||||
|
||||
item, err := evts.PostItem(ctx, userID, ptr.Val(calendar.GetId()), evt)
|
||||
item, err = evts.PostItem(ctx, userID, ptr.Val(calendar.GetId()), item)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
id, err := evts.PostLargeAttachment(
|
||||
@ -269,10 +272,10 @@ func (suite *EventsAPIIntgSuite) TestEvents_RestoreLargeAttachment() {
|
||||
userID,
|
||||
ptr.Val(calendar.GetId()),
|
||||
ptr.Val(item.GetId()),
|
||||
"raboganm",
|
||||
"rabognam",
|
||||
[]byte("mangobar"))
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
require.NotEmpty(t, id, "empty id for large attachment")
|
||||
require.NotEmpty(t, id, "attachment should have an id after uploading")
|
||||
}
|
||||
|
||||
func (suite *EventsAPIIntgSuite) TestEvents_canFindNonStandardFolder() {
|
||||
|
||||
@ -12,6 +12,7 @@ import (
|
||||
|
||||
"github.com/alcionai/corso/src/internal/common/ptr"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/internal/tester/its"
|
||||
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
||||
"github.com/alcionai/corso/src/pkg/errs"
|
||||
"github.com/alcionai/corso/src/pkg/errs/core"
|
||||
@ -21,6 +22,7 @@ import (
|
||||
type GroupsIntgSuite struct {
|
||||
tester.Suite
|
||||
cli client
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestGroupsIntgSuite(t *testing.T) {
|
||||
@ -37,12 +39,12 @@ func (suite *GroupsIntgSuite) SetupSuite() {
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
acct := tconfig.NewM365Account(t)
|
||||
|
||||
var err error
|
||||
suite.m365 = its.GetM365(t)
|
||||
|
||||
// will init the concurrency limiter
|
||||
suite.cli, err = NewM365Client(ctx, acct)
|
||||
var err error
|
||||
|
||||
suite.cli, err = NewM365Client(ctx, suite.m365.Acct)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
}
|
||||
|
||||
@ -52,7 +54,7 @@ func (suite *GroupsIntgSuite) TestGroupByID() {
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
gid := tconfig.M365TeamID(t)
|
||||
gid := suite.m365.Group.ID
|
||||
|
||||
group, err := suite.cli.GroupByID(ctx, gid)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
@ -68,7 +70,7 @@ func (suite *GroupsIntgSuite) TestGroupByID_ByEmail() {
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
gid := tconfig.M365TeamID(t)
|
||||
gid := suite.m365.Group.ID
|
||||
|
||||
group, err := suite.cli.GroupByID(ctx, gid)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
@ -77,7 +79,7 @@ func (suite *GroupsIntgSuite) TestGroupByID_ByEmail() {
|
||||
assert.Equal(t, gid, group.ID, "must match expected id")
|
||||
assert.NotEmpty(t, group.DisplayName)
|
||||
|
||||
gemail := tconfig.M365TeamEmail(t)
|
||||
gemail := suite.m365.Group.Email
|
||||
|
||||
groupByEmail, err := suite.cli.GroupByID(ctx, gemail)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
@ -92,7 +94,7 @@ func (suite *GroupsIntgSuite) TestTeamByID() {
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
gid := tconfig.M365TeamID(t)
|
||||
gid := suite.m365.Group.ID
|
||||
|
||||
group, err := suite.cli.TeamByID(ctx, gid)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
@ -132,7 +134,7 @@ func (suite *GroupsIntgSuite) TestGroups() {
|
||||
assert.NotEmpty(t, group.DisplayName)
|
||||
|
||||
// at least one known group should be a team
|
||||
if group.ID == tconfig.M365TeamID(t) {
|
||||
if group.ID == suite.m365.Group.ID {
|
||||
assert.True(t, group.IsTeam)
|
||||
}
|
||||
})
|
||||
@ -145,7 +147,7 @@ func (suite *GroupsIntgSuite) TestSitesInGroup() {
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
gid := tconfig.M365TeamID(t)
|
||||
gid := suite.m365.Group.ID
|
||||
|
||||
sites, err := suite.cli.SitesInGroup(ctx, gid, fault.New(true))
|
||||
assert.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
@ -8,12 +8,14 @@ import (
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/internal/tester/its"
|
||||
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
||||
"github.com/alcionai/corso/src/pkg/account"
|
||||
)
|
||||
|
||||
type M365IntgSuite struct {
|
||||
tester.Suite
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestM365IntgSuite(t *testing.T) {
|
||||
@ -24,26 +26,29 @@ func TestM365IntgSuite(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func (suite *userIntegrationSuite) TestNewM365Client() {
|
||||
t := suite.T()
|
||||
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
_, err := NewM365Client(ctx, tconfig.NewM365Account(t))
|
||||
assert.NoError(t, err, clues.ToCore(err))
|
||||
func (suite *M365IntgSuite) SetupSuite() {
|
||||
suite.m365 = its.GetM365(suite.T())
|
||||
}
|
||||
|
||||
func (suite *userIntegrationSuite) TestNewM365Client_invalidCredentials() {
|
||||
func (suite *M365IntgSuite) TestNewM365Client() {
|
||||
table := []struct {
|
||||
name string
|
||||
acct func(t *testing.T) account.Account
|
||||
expectErr assert.ErrorAssertionFunc
|
||||
}{
|
||||
{
|
||||
name: "Valid Credentials",
|
||||
acct: func(t *testing.T) account.Account {
|
||||
return suite.m365.Acct
|
||||
},
|
||||
expectErr: assert.NoError,
|
||||
},
|
||||
{
|
||||
name: "Invalid Credentials",
|
||||
acct: func(t *testing.T) account.Account {
|
||||
return tconfig.NewFakeM365Account(t)
|
||||
},
|
||||
expectErr: assert.Error,
|
||||
},
|
||||
}
|
||||
|
||||
@ -55,7 +60,7 @@ func (suite *userIntegrationSuite) TestNewM365Client_invalidCredentials() {
|
||||
defer flush()
|
||||
|
||||
_, err := NewM365Client(ctx, test.acct(t))
|
||||
assert.Error(t, err, clues.ToCore(err))
|
||||
test.expectErr(t, err, clues.ToCore(err))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,6 +13,7 @@ import (
|
||||
|
||||
"github.com/alcionai/corso/src/internal/common/ptr"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/internal/tester/its"
|
||||
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
||||
"github.com/alcionai/corso/src/pkg/errs/core"
|
||||
"github.com/alcionai/corso/src/pkg/fault"
|
||||
@ -24,6 +25,7 @@ import (
|
||||
type siteIntegrationSuite struct {
|
||||
tester.Suite
|
||||
cli client
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestSiteIntegrationSuite(t *testing.T) {
|
||||
@ -40,12 +42,12 @@ func (suite *siteIntegrationSuite) SetupSuite() {
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
acct := tconfig.NewM365Account(t)
|
||||
|
||||
var err error
|
||||
suite.m365 = its.GetM365(t)
|
||||
|
||||
// will init the concurrency limiter
|
||||
suite.cli, err = NewM365Client(ctx, acct)
|
||||
var err error
|
||||
|
||||
suite.cli, err = NewM365Client(ctx, suite.m365.Acct)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
}
|
||||
|
||||
@ -258,9 +260,9 @@ func (suite *siteUnitSuite) TestGetSites() {
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
gas := test.mock(ctx)
|
||||
getAllSites := test.mock(ctx)
|
||||
|
||||
site, err := getSiteByID(ctx, gas, "id", api.CallConfig{})
|
||||
site, err := getSiteByID(ctx, getAllSites, "id", api.CallConfig{})
|
||||
test.expectSite(t, site)
|
||||
test.expectErr(t, err, clues.ToCore(err))
|
||||
})
|
||||
|
||||
@ -10,6 +10,7 @@ import (
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/internal/tester/its"
|
||||
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
||||
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
||||
)
|
||||
@ -17,6 +18,7 @@ import (
|
||||
type userIntegrationSuite struct {
|
||||
tester.Suite
|
||||
cli client
|
||||
m365 its.M365IntgTestSetup
|
||||
}
|
||||
|
||||
func TestUserIntegrationSuite(t *testing.T) {
|
||||
@ -28,17 +30,18 @@ func TestUserIntegrationSuite(t *testing.T) {
|
||||
}
|
||||
|
||||
func (suite *userIntegrationSuite) SetupSuite() {
|
||||
t := suite.T()
|
||||
var (
|
||||
t = suite.T()
|
||||
err error
|
||||
)
|
||||
|
||||
suite.m365 = its.GetM365(t)
|
||||
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
acct := tconfig.NewM365Account(t)
|
||||
|
||||
var err error
|
||||
|
||||
// will init the concurrency limiter
|
||||
suite.cli, err = NewM365Client(ctx, acct)
|
||||
suite.cli, err = NewM365Client(ctx, suite.m365.Acct)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
}
|
||||
|
||||
@ -64,9 +67,6 @@ func (suite *userIntegrationSuite) TestUsersCompat_HasNoInfo() {
|
||||
}
|
||||
|
||||
func (suite *userIntegrationSuite) TestUserHasMailbox() {
|
||||
t := suite.T()
|
||||
userID := tconfig.M365UserID(t)
|
||||
|
||||
table := []struct {
|
||||
name string
|
||||
user string
|
||||
@ -79,7 +79,7 @@ func (suite *userIntegrationSuite) TestUserHasMailbox() {
|
||||
},
|
||||
{
|
||||
name: "user with mailbox",
|
||||
user: userID,
|
||||
user: suite.m365.User.ID,
|
||||
expect: true,
|
||||
},
|
||||
}
|
||||
@ -98,9 +98,6 @@ func (suite *userIntegrationSuite) TestUserHasMailbox() {
|
||||
}
|
||||
|
||||
func (suite *userIntegrationSuite) TestUserHasDrive() {
|
||||
t := suite.T()
|
||||
userID := tconfig.M365UserID(t)
|
||||
|
||||
table := []struct {
|
||||
name string
|
||||
user string
|
||||
@ -115,7 +112,7 @@ func (suite *userIntegrationSuite) TestUserHasDrive() {
|
||||
},
|
||||
{
|
||||
name: "user with drive",
|
||||
user: userID,
|
||||
user: suite.m365.User.ID,
|
||||
expect: true,
|
||||
expectErr: require.NoError,
|
||||
},
|
||||
@ -135,9 +132,6 @@ func (suite *userIntegrationSuite) TestUserHasDrive() {
|
||||
}
|
||||
|
||||
func (suite *userIntegrationSuite) TestUserGetMailboxInfo() {
|
||||
t := suite.T()
|
||||
userID := tconfig.M365UserID(t)
|
||||
|
||||
table := []struct {
|
||||
name string
|
||||
user string
|
||||
@ -155,7 +149,7 @@ func (suite *userIntegrationSuite) TestUserGetMailboxInfo() {
|
||||
},
|
||||
{
|
||||
name: "user mailbox",
|
||||
user: userID,
|
||||
user: suite.m365.User.ID,
|
||||
expect: func(t *testing.T, info api.MailboxInfo) {
|
||||
require.NotNil(t, info)
|
||||
assert.Equal(t, "user", info.Purpose)
|
||||
@ -201,9 +195,6 @@ func (suite *userIntegrationSuite) TestUserGetMailboxInfo() {
|
||||
|
||||
func (suite *userIntegrationSuite) TestUserAssignedLicenses() {
|
||||
t := suite.T()
|
||||
ctx, flush := tester.NewContext(t)
|
||||
|
||||
defer flush()
|
||||
|
||||
runs := []struct {
|
||||
name string
|
||||
@ -219,7 +210,7 @@ func (suite *userIntegrationSuite) TestUserAssignedLicenses() {
|
||||
},
|
||||
{
|
||||
name: "user with licenses",
|
||||
userID: tconfig.M365UserID(t),
|
||||
userID: suite.m365.User.ID,
|
||||
expect: 2,
|
||||
expectErr: require.NoError,
|
||||
},
|
||||
@ -232,7 +223,12 @@ func (suite *userIntegrationSuite) TestUserAssignedLicenses() {
|
||||
}
|
||||
|
||||
for _, run := range runs {
|
||||
t.Run(run.name, func(t *testing.T) {
|
||||
suite.Run(run.name, func() {
|
||||
t := suite.T()
|
||||
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
user, err := suite.cli.UserAssignedLicenses(ctx, run.userID)
|
||||
run.expectErr(t, err, clues.ToCore(err))
|
||||
assert.Equal(t, run.expect, user)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user