move default folder consts to api (#3734)
only code movement, no logic changes --- #### Does this PR need a docs update or release note? - [x] ⛔ No #### Type of change - [x] 🧹 Tech Debt/Cleanup #### Issue(s) * #3562 #### Test Plan - [x] ⚡ Unit test - [x] 💚 E2E
This commit is contained in:
parent
2a150cc610
commit
39a93e9054
@ -20,7 +20,6 @@ import (
|
|||||||
"github.com/alcionai/corso/src/cli/print"
|
"github.com/alcionai/corso/src/cli/print"
|
||||||
cliTD "github.com/alcionai/corso/src/cli/testdata"
|
cliTD "github.com/alcionai/corso/src/cli/testdata"
|
||||||
"github.com/alcionai/corso/src/internal/common/idname"
|
"github.com/alcionai/corso/src/internal/common/idname"
|
||||||
"github.com/alcionai/corso/src/internal/m365/exchange"
|
|
||||||
"github.com/alcionai/corso/src/internal/operations"
|
"github.com/alcionai/corso/src/internal/operations"
|
||||||
"github.com/alcionai/corso/src/internal/tester"
|
"github.com/alcionai/corso/src/internal/tester"
|
||||||
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
||||||
@ -28,6 +27,7 @@ import (
|
|||||||
"github.com/alcionai/corso/src/pkg/path"
|
"github.com/alcionai/corso/src/pkg/path"
|
||||||
"github.com/alcionai/corso/src/pkg/repository"
|
"github.com/alcionai/corso/src/pkg/repository"
|
||||||
"github.com/alcionai/corso/src/pkg/selectors"
|
"github.com/alcionai/corso/src/pkg/selectors"
|
||||||
|
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
||||||
"github.com/alcionai/corso/src/pkg/storage"
|
"github.com/alcionai/corso/src/pkg/storage"
|
||||||
storeTD "github.com/alcionai/corso/src/pkg/storage/testdata"
|
storeTD "github.com/alcionai/corso/src/pkg/storage/testdata"
|
||||||
)
|
)
|
||||||
@ -483,13 +483,13 @@ func (suite *PreparedBackupExchangeE2ESuite) SetupSuite() {
|
|||||||
|
|
||||||
switch set {
|
switch set {
|
||||||
case email:
|
case email:
|
||||||
scopes = sel.MailFolders([]string{exchange.DefaultMailFolder}, selectors.PrefixMatch())
|
scopes = sel.MailFolders([]string{api.MailInbox}, selectors.PrefixMatch())
|
||||||
|
|
||||||
case contacts:
|
case contacts:
|
||||||
scopes = sel.ContactFolders([]string{exchange.DefaultContactFolder}, selectors.PrefixMatch())
|
scopes = sel.ContactFolders([]string{api.DefaultContacts}, selectors.PrefixMatch())
|
||||||
|
|
||||||
case events:
|
case events:
|
||||||
scopes = sel.EventCalendars([]string{exchange.DefaultCalendar}, selectors.PrefixMatch())
|
scopes = sel.EventCalendars([]string{api.DefaultCalendar}, selectors.PrefixMatch())
|
||||||
}
|
}
|
||||||
|
|
||||||
sel.Include(scopes)
|
sel.Include(scopes)
|
||||||
@ -728,7 +728,7 @@ func (suite *BackupDeleteExchangeE2ESuite) SetupSuite() {
|
|||||||
|
|
||||||
// some tests require an existing backup
|
// some tests require an existing backup
|
||||||
sel := selectors.NewExchangeBackup(users)
|
sel := selectors.NewExchangeBackup(users)
|
||||||
sel.Include(sel.MailFolders([]string{exchange.DefaultMailFolder}, selectors.PrefixMatch()))
|
sel.Include(sel.MailFolders([]string{api.MailInbox}, selectors.PrefixMatch()))
|
||||||
|
|
||||||
backupOp, err := suite.repo.NewBackup(ctx, sel.Selector)
|
backupOp, err := suite.repo.NewBackup(ctx, sel.Selector)
|
||||||
require.NoError(t, err, clues.ToCore(err))
|
require.NoError(t, err, clues.ToCore(err))
|
||||||
|
|||||||
@ -15,7 +15,6 @@ import (
|
|||||||
"github.com/alcionai/corso/src/cli/flags"
|
"github.com/alcionai/corso/src/cli/flags"
|
||||||
cliTD "github.com/alcionai/corso/src/cli/testdata"
|
cliTD "github.com/alcionai/corso/src/cli/testdata"
|
||||||
"github.com/alcionai/corso/src/internal/common/idname"
|
"github.com/alcionai/corso/src/internal/common/idname"
|
||||||
"github.com/alcionai/corso/src/internal/m365/exchange"
|
|
||||||
"github.com/alcionai/corso/src/internal/operations"
|
"github.com/alcionai/corso/src/internal/operations"
|
||||||
"github.com/alcionai/corso/src/internal/tester"
|
"github.com/alcionai/corso/src/internal/tester"
|
||||||
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
||||||
@ -24,6 +23,7 @@ import (
|
|||||||
"github.com/alcionai/corso/src/pkg/path"
|
"github.com/alcionai/corso/src/pkg/path"
|
||||||
"github.com/alcionai/corso/src/pkg/repository"
|
"github.com/alcionai/corso/src/pkg/repository"
|
||||||
"github.com/alcionai/corso/src/pkg/selectors"
|
"github.com/alcionai/corso/src/pkg/selectors"
|
||||||
|
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
||||||
"github.com/alcionai/corso/src/pkg/storage"
|
"github.com/alcionai/corso/src/pkg/storage"
|
||||||
storeTD "github.com/alcionai/corso/src/pkg/storage/testdata"
|
storeTD "github.com/alcionai/corso/src/pkg/storage/testdata"
|
||||||
)
|
)
|
||||||
@ -96,13 +96,13 @@ func (suite *RestoreExchangeE2ESuite) SetupSuite() {
|
|||||||
|
|
||||||
switch set {
|
switch set {
|
||||||
case email:
|
case email:
|
||||||
scopes = sel.MailFolders([]string{exchange.DefaultMailFolder}, selectors.PrefixMatch())
|
scopes = sel.MailFolders([]string{api.MailInbox}, selectors.PrefixMatch())
|
||||||
|
|
||||||
case contacts:
|
case contacts:
|
||||||
scopes = sel.ContactFolders([]string{exchange.DefaultContactFolder}, selectors.PrefixMatch())
|
scopes = sel.ContactFolders([]string{api.DefaultContacts}, selectors.PrefixMatch())
|
||||||
|
|
||||||
case events:
|
case events:
|
||||||
scopes = sel.EventCalendars([]string{exchange.DefaultCalendar}, selectors.PrefixMatch())
|
scopes = sel.EventCalendars([]string{api.DefaultCalendar}, selectors.PrefixMatch())
|
||||||
}
|
}
|
||||||
|
|
||||||
sel.Include(scopes)
|
sel.Include(scopes)
|
||||||
|
|||||||
@ -76,7 +76,7 @@ func (suite *DataCollectionIntgSuite) TestExchangeDataCollection() {
|
|||||||
name: "Email",
|
name: "Email",
|
||||||
getSelector: func(t *testing.T) selectors.Selector {
|
getSelector: func(t *testing.T) selectors.Selector {
|
||||||
sel := selectors.NewExchangeBackup(selUsers)
|
sel := selectors.NewExchangeBackup(selUsers)
|
||||||
sel.Include(sel.MailFolders([]string{exchange.DefaultMailFolder}, selectors.PrefixMatch()))
|
sel.Include(sel.MailFolders([]string{api.MailInbox}, selectors.PrefixMatch()))
|
||||||
sel.DiscreteOwner = suite.user
|
sel.DiscreteOwner = suite.user
|
||||||
return sel.Selector
|
return sel.Selector
|
||||||
},
|
},
|
||||||
@ -85,7 +85,7 @@ func (suite *DataCollectionIntgSuite) TestExchangeDataCollection() {
|
|||||||
name: "Contacts",
|
name: "Contacts",
|
||||||
getSelector: func(t *testing.T) selectors.Selector {
|
getSelector: func(t *testing.T) selectors.Selector {
|
||||||
sel := selectors.NewExchangeBackup(selUsers)
|
sel := selectors.NewExchangeBackup(selUsers)
|
||||||
sel.Include(sel.ContactFolders([]string{exchange.DefaultContactFolder}, selectors.PrefixMatch()))
|
sel.Include(sel.ContactFolders([]string{api.DefaultContacts}, selectors.PrefixMatch()))
|
||||||
sel.DiscreteOwner = suite.user
|
sel.DiscreteOwner = suite.user
|
||||||
return sel.Selector
|
return sel.Selector
|
||||||
},
|
},
|
||||||
|
|||||||
@ -29,6 +29,7 @@ import (
|
|||||||
"github.com/alcionai/corso/src/pkg/path"
|
"github.com/alcionai/corso/src/pkg/path"
|
||||||
"github.com/alcionai/corso/src/pkg/selectors"
|
"github.com/alcionai/corso/src/pkg/selectors"
|
||||||
selTD "github.com/alcionai/corso/src/pkg/selectors/testdata"
|
selTD "github.com/alcionai/corso/src/pkg/selectors/testdata"
|
||||||
|
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
@ -672,7 +673,7 @@ func (suite *ControllerIntegrationSuite) TestRestoreAndBackup() {
|
|||||||
resourceCat: resource.Users,
|
resourceCat: resource.Users,
|
||||||
collections: []stub.ColInfo{
|
collections: []stub.ColInfo{
|
||||||
{
|
{
|
||||||
PathElements: []string{"Inbox"},
|
PathElements: []string{api.MailInbox},
|
||||||
Category: path.EmailCategory,
|
Category: path.EmailCategory,
|
||||||
Items: []stub.ItemInfo{
|
Items: []stub.ItemInfo{
|
||||||
{
|
{
|
||||||
@ -699,7 +700,7 @@ func (suite *ControllerIntegrationSuite) TestRestoreAndBackup() {
|
|||||||
resourceCat: resource.Users,
|
resourceCat: resource.Users,
|
||||||
collections: []stub.ColInfo{
|
collections: []stub.ColInfo{
|
||||||
{
|
{
|
||||||
PathElements: []string{"Inbox"},
|
PathElements: []string{api.MailInbox},
|
||||||
Category: path.EmailCategory,
|
Category: path.EmailCategory,
|
||||||
Items: []stub.ItemInfo{
|
Items: []stub.ItemInfo{
|
||||||
{
|
{
|
||||||
@ -738,7 +739,7 @@ func (suite *ControllerIntegrationSuite) TestRestoreAndBackup() {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
PathElements: []string{"Work", "Inbox"},
|
PathElements: []string{"Work", api.MailInbox},
|
||||||
Category: path.EmailCategory,
|
Category: path.EmailCategory,
|
||||||
Items: []stub.ItemInfo{
|
Items: []stub.ItemInfo{
|
||||||
{
|
{
|
||||||
@ -753,7 +754,7 @@ func (suite *ControllerIntegrationSuite) TestRestoreAndBackup() {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
PathElements: []string{"Work", "Inbox", "Work"},
|
PathElements: []string{"Work", api.MailInbox, "Work"},
|
||||||
Category: path.EmailCategory,
|
Category: path.EmailCategory,
|
||||||
Items: []stub.ItemInfo{
|
Items: []stub.ItemInfo{
|
||||||
{
|
{
|
||||||
@ -1116,7 +1117,7 @@ func (suite *ControllerIntegrationSuite) TestRestoreAndBackup_largeMailAttachmen
|
|||||||
resourceCat: resource.Users,
|
resourceCat: resource.Users,
|
||||||
collections: []stub.ColInfo{
|
collections: []stub.ColInfo{
|
||||||
{
|
{
|
||||||
PathElements: []string{"Inbox"},
|
PathElements: []string{api.MailInbox},
|
||||||
Category: path.EmailCategory,
|
Category: path.EmailCategory,
|
||||||
Items: []stub.ItemInfo{
|
Items: []stub.ItemInfo{
|
||||||
{
|
{
|
||||||
|
|||||||
@ -566,8 +566,8 @@ func includeContainer(
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Clause ensures that DefaultContactFolder is inspected properly
|
// Clause ensures that DefaultContactFolder is inspected properly
|
||||||
if category == path.ContactsCategory && ptr.Val(c.GetDisplayName()) == DefaultContactFolder {
|
if category == path.ContactsCategory && ptr.Val(c.GetDisplayName()) == api.DefaultContacts {
|
||||||
loc = loc.Append(DefaultContactFolder)
|
loc = loc.Append(api.DefaultContacts)
|
||||||
}
|
}
|
||||||
|
|
||||||
dirPath, err := pb.ToDataLayerExchangePathForCategory(
|
dirPath, err := pb.ToDataLayerExchangePathForCategory(
|
||||||
|
|||||||
@ -438,22 +438,22 @@ func (suite *BackupIntgSuite) TestMailFetch() {
|
|||||||
{
|
{
|
||||||
name: "Folder Iterative Check Mail",
|
name: "Folder Iterative Check Mail",
|
||||||
scope: selectors.NewExchangeBackup(users).MailFolders(
|
scope: selectors.NewExchangeBackup(users).MailFolders(
|
||||||
[]string{DefaultMailFolder},
|
[]string{api.MailInbox},
|
||||||
selectors.PrefixMatch(),
|
selectors.PrefixMatch(),
|
||||||
)[0],
|
)[0],
|
||||||
folderNames: map[string]struct{}{
|
folderNames: map[string]struct{}{
|
||||||
DefaultMailFolder: {},
|
api.MailInbox: {},
|
||||||
},
|
},
|
||||||
canMakeDeltaQueries: true,
|
canMakeDeltaQueries: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Folder Iterative Check Mail Non-Delta",
|
name: "Folder Iterative Check Mail Non-Delta",
|
||||||
scope: selectors.NewExchangeBackup(users).MailFolders(
|
scope: selectors.NewExchangeBackup(users).MailFolders(
|
||||||
[]string{DefaultMailFolder},
|
[]string{api.MailInbox},
|
||||||
selectors.PrefixMatch(),
|
selectors.PrefixMatch(),
|
||||||
)[0],
|
)[0],
|
||||||
folderNames: map[string]struct{}{
|
folderNames: map[string]struct{}{
|
||||||
DefaultMailFolder: {},
|
api.MailInbox: {},
|
||||||
},
|
},
|
||||||
canMakeDeltaQueries: false,
|
canMakeDeltaQueries: false,
|
||||||
},
|
},
|
||||||
@ -520,21 +520,21 @@ func (suite *BackupIntgSuite) TestDelta() {
|
|||||||
{
|
{
|
||||||
name: "Mail",
|
name: "Mail",
|
||||||
scope: selectors.NewExchangeBackup(users).MailFolders(
|
scope: selectors.NewExchangeBackup(users).MailFolders(
|
||||||
[]string{DefaultMailFolder},
|
[]string{api.MailInbox},
|
||||||
selectors.PrefixMatch(),
|
selectors.PrefixMatch(),
|
||||||
)[0],
|
)[0],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Contacts",
|
name: "Contacts",
|
||||||
scope: selectors.NewExchangeBackup(users).ContactFolders(
|
scope: selectors.NewExchangeBackup(users).ContactFolders(
|
||||||
[]string{DefaultContactFolder},
|
[]string{api.DefaultContacts},
|
||||||
selectors.PrefixMatch(),
|
selectors.PrefixMatch(),
|
||||||
)[0],
|
)[0],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Events",
|
name: "Events",
|
||||||
scope: selectors.NewExchangeBackup(users).EventCalendars(
|
scope: selectors.NewExchangeBackup(users).EventCalendars(
|
||||||
[]string{DefaultCalendar},
|
[]string{api.DefaultCalendar},
|
||||||
selectors.PrefixMatch(),
|
selectors.PrefixMatch(),
|
||||||
)[0],
|
)[0],
|
||||||
},
|
},
|
||||||
@ -624,7 +624,7 @@ func (suite *BackupIntgSuite) TestMailSerializationRegression() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
sel := selectors.NewExchangeBackup(users)
|
sel := selectors.NewExchangeBackup(users)
|
||||||
sel.Include(sel.MailFolders([]string{DefaultMailFolder}, selectors.PrefixMatch()))
|
sel.Include(sel.MailFolders([]string{api.MailInbox}, selectors.PrefixMatch()))
|
||||||
|
|
||||||
collections, err := createCollections(
|
collections, err := createCollections(
|
||||||
ctx,
|
ctx,
|
||||||
@ -688,7 +688,7 @@ func (suite *BackupIntgSuite) TestContactSerializationRegression() {
|
|||||||
{
|
{
|
||||||
name: "Default Contact Folder",
|
name: "Default Contact Folder",
|
||||||
scope: selectors.NewExchangeBackup(users).ContactFolders(
|
scope: selectors.NewExchangeBackup(users).ContactFolders(
|
||||||
[]string{DefaultContactFolder},
|
[]string{api.DefaultContacts},
|
||||||
selectors.PrefixMatch())[0],
|
selectors.PrefixMatch())[0],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -752,7 +752,7 @@ func (suite *BackupIntgSuite) TestContactSerializationRegression() {
|
|||||||
assert.Equal(
|
assert.Equal(
|
||||||
t,
|
t,
|
||||||
edc.(data.LocationPather).LocationPath().String(),
|
edc.(data.LocationPather).LocationPath().String(),
|
||||||
DefaultContactFolder)
|
api.DefaultContacts)
|
||||||
assert.NotZero(t, count)
|
assert.NotZero(t, count)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -777,7 +777,7 @@ func (suite *BackupIntgSuite) TestEventsSerializationRegression() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
fn := func(gcc graph.CachedContainer) error {
|
fn := func(gcc graph.CachedContainer) error {
|
||||||
if ptr.Val(gcc.GetDisplayName()) == DefaultCalendar {
|
if ptr.Val(gcc.GetDisplayName()) == api.DefaultCalendar {
|
||||||
calID = ptr.Val(gcc.GetId())
|
calID = ptr.Val(gcc.GetId())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -788,7 +788,12 @@ func (suite *BackupIntgSuite) TestEventsSerializationRegression() {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
err := suite.ac.Events().EnumerateContainers(ctx, suite.user, DefaultCalendar, fn, fault.New(true))
|
err := suite.ac.Events().EnumerateContainers(
|
||||||
|
ctx,
|
||||||
|
suite.user,
|
||||||
|
api.DefaultCalendar,
|
||||||
|
fn,
|
||||||
|
fault.New(true))
|
||||||
require.NoError(t, err, clues.ToCore(err))
|
require.NoError(t, err, clues.ToCore(err))
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
@ -799,7 +804,7 @@ func (suite *BackupIntgSuite) TestEventsSerializationRegression() {
|
|||||||
name: "Default Event Calendar",
|
name: "Default Event Calendar",
|
||||||
expected: calID,
|
expected: calID,
|
||||||
scope: selectors.NewExchangeBackup(users).EventCalendars(
|
scope: selectors.NewExchangeBackup(users).EventCalendars(
|
||||||
[]string{DefaultCalendar},
|
[]string{api.DefaultCalendar},
|
||||||
selectors.PrefixMatch(),
|
selectors.PrefixMatch(),
|
||||||
)[0],
|
)[0],
|
||||||
},
|
},
|
||||||
|
|||||||
@ -27,15 +27,4 @@ const (
|
|||||||
// MailReceiveDateTimeOverrideProperty allows receive date time to be updated.
|
// MailReceiveDateTimeOverrideProperty allows receive date time to be updated.
|
||||||
// Section: 2.789 PidTagMessageDeliveryTime
|
// Section: 2.789 PidTagMessageDeliveryTime
|
||||||
MailReceiveDateTimeOverriveProperty = "SystemTime 0x0E06"
|
MailReceiveDateTimeOverriveProperty = "SystemTime 0x0E06"
|
||||||
|
|
||||||
// ----------------------------------
|
|
||||||
// Default Folder Names
|
|
||||||
// ----------------------------------
|
|
||||||
// Mail Definitions: https://docs.microsoft.com/en-us/graph/api/resources/mailfolder?view=graph-rest-1.0
|
|
||||||
|
|
||||||
// inbox and root
|
|
||||||
DefaultMailFolder = "Inbox"
|
|
||||||
rootFolderAlias = "msgfolderroot"
|
|
||||||
DefaultContactFolder = "Contacts"
|
|
||||||
DefaultCalendar = "Calendar"
|
|
||||||
)
|
)
|
||||||
|
|||||||
@ -32,7 +32,7 @@ func (h contactBackupHandler) itemHandler() itemGetterSerializer {
|
|||||||
func (h contactBackupHandler) NewContainerCache(
|
func (h contactBackupHandler) NewContainerCache(
|
||||||
userID string,
|
userID string,
|
||||||
) (string, graph.ContainerResolver) {
|
) (string, graph.ContainerResolver) {
|
||||||
return DefaultContactFolder, &contactContainerCache{
|
return api.DefaultContacts, &contactContainerCache{
|
||||||
userID: userID,
|
userID: userID,
|
||||||
enumer: h.ac,
|
enumer: h.ac,
|
||||||
getter: h.ac,
|
getter: h.ac,
|
||||||
|
|||||||
@ -725,45 +725,45 @@ func (suite *ContainerResolverSuite) TestPopulate() {
|
|||||||
{
|
{
|
||||||
name: "Default Event Cache",
|
name: "Default Event Cache",
|
||||||
// Fine as long as this isn't running against a migrated Exchange server.
|
// Fine as long as this isn't running against a migrated Exchange server.
|
||||||
folderInCache: DefaultCalendar,
|
folderInCache: api.DefaultCalendar,
|
||||||
root: DefaultCalendar,
|
root: api.DefaultCalendar,
|
||||||
basePath: DefaultCalendar,
|
basePath: api.DefaultCalendar,
|
||||||
resolverFunc: eventFunc,
|
resolverFunc: eventFunc,
|
||||||
canFind: assert.True,
|
canFind: assert.True,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Default Event Folder Hidden",
|
name: "Default Event Folder Hidden",
|
||||||
folderInCache: DefaultContactFolder,
|
folderInCache: api.DefaultContacts,
|
||||||
root: DefaultCalendar,
|
root: api.DefaultCalendar,
|
||||||
canFind: assert.False,
|
canFind: assert.False,
|
||||||
resolverFunc: eventFunc,
|
resolverFunc: eventFunc,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Name Not in Cache",
|
name: "Name Not in Cache",
|
||||||
folderInCache: "testFooBarWhoBar",
|
folderInCache: "testFooBarWhoBar",
|
||||||
root: DefaultCalendar,
|
root: api.DefaultCalendar,
|
||||||
canFind: assert.False,
|
canFind: assert.False,
|
||||||
resolverFunc: eventFunc,
|
resolverFunc: eventFunc,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Default Contact Cache",
|
name: "Default Contact Cache",
|
||||||
folderInCache: DefaultContactFolder,
|
folderInCache: api.DefaultContacts,
|
||||||
root: DefaultContactFolder,
|
root: api.DefaultContacts,
|
||||||
basePath: DefaultContactFolder,
|
basePath: api.DefaultContacts,
|
||||||
canFind: assert.True,
|
canFind: assert.True,
|
||||||
resolverFunc: contactFunc,
|
resolverFunc: contactFunc,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Default Contact Hidden",
|
name: "Default Contact Hidden",
|
||||||
folderInCache: DefaultContactFolder,
|
folderInCache: api.DefaultContacts,
|
||||||
root: DefaultContactFolder,
|
root: api.DefaultContacts,
|
||||||
canFind: assert.False,
|
canFind: assert.False,
|
||||||
resolverFunc: contactFunc,
|
resolverFunc: contactFunc,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Name Not in Cache",
|
name: "Name Not in Cache",
|
||||||
folderInCache: "testFooBarWhoBar",
|
folderInCache: "testFooBarWhoBar",
|
||||||
root: DefaultContactFolder,
|
root: api.DefaultContacts,
|
||||||
canFind: assert.False,
|
canFind: assert.False,
|
||||||
resolverFunc: contactFunc,
|
resolverFunc: contactFunc,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -32,7 +32,7 @@ func (h eventBackupHandler) itemHandler() itemGetterSerializer {
|
|||||||
func (h eventBackupHandler) NewContainerCache(
|
func (h eventBackupHandler) NewContainerCache(
|
||||||
userID string,
|
userID string,
|
||||||
) (string, graph.ContainerResolver) {
|
) (string, graph.ContainerResolver) {
|
||||||
return DefaultCalendar, &eventContainerCache{
|
return api.DefaultCalendar, &eventContainerCache{
|
||||||
userID: userID,
|
userID: userID,
|
||||||
enumer: h.ac,
|
enumer: h.ac,
|
||||||
getter: h.ac,
|
getter: h.ac,
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import (
|
|||||||
"github.com/alcionai/corso/src/internal/m365/graph"
|
"github.com/alcionai/corso/src/internal/m365/graph"
|
||||||
"github.com/alcionai/corso/src/pkg/fault"
|
"github.com/alcionai/corso/src/pkg/fault"
|
||||||
"github.com/alcionai/corso/src/pkg/path"
|
"github.com/alcionai/corso/src/pkg/path"
|
||||||
|
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ graph.ContainerResolver = &eventContainerCache{}
|
var _ graph.ContainerResolver = &eventContainerCache{}
|
||||||
@ -38,7 +39,7 @@ func (ecc *eventContainerCache) init(
|
|||||||
// Action ensures that cache will stop at appropriate level.
|
// Action ensures that cache will stop at appropriate level.
|
||||||
// @error iff the struct is not properly instantiated
|
// @error iff the struct is not properly instantiated
|
||||||
func (ecc *eventContainerCache) populateEventRoot(ctx context.Context) error {
|
func (ecc *eventContainerCache) populateEventRoot(ctx context.Context) error {
|
||||||
container := DefaultCalendar
|
container := api.DefaultCalendar
|
||||||
|
|
||||||
f, err := ecc.getter.GetContainerByID(ctx, ecc.userID, container)
|
f, err := ecc.getter.GetContainerByID(ctx, ecc.userID, container)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -32,7 +32,7 @@ func (h mailBackupHandler) itemHandler() itemGetterSerializer {
|
|||||||
func (h mailBackupHandler) NewContainerCache(
|
func (h mailBackupHandler) NewContainerCache(
|
||||||
userID string,
|
userID string,
|
||||||
) (string, graph.ContainerResolver) {
|
) (string, graph.ContainerResolver) {
|
||||||
return rootFolderAlias, &mailContainerCache{
|
return api.MsgFolderRoot, &mailContainerCache{
|
||||||
userID: userID,
|
userID: userID,
|
||||||
enumer: h.ac,
|
enumer: h.ac,
|
||||||
getter: h.ac,
|
getter: h.ac,
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import (
|
|||||||
"github.com/alcionai/corso/src/internal/m365/graph"
|
"github.com/alcionai/corso/src/internal/m365/graph"
|
||||||
"github.com/alcionai/corso/src/pkg/fault"
|
"github.com/alcionai/corso/src/pkg/fault"
|
||||||
"github.com/alcionai/corso/src/pkg/path"
|
"github.com/alcionai/corso/src/pkg/path"
|
||||||
|
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -65,7 +66,7 @@ func (mc *mailContainerCache) init(
|
|||||||
// Action ensures that cache will stop at appropriate level.
|
// Action ensures that cache will stop at appropriate level.
|
||||||
// @error iff the struct is not properly instantiated
|
// @error iff the struct is not properly instantiated
|
||||||
func (mc *mailContainerCache) populateMailRoot(ctx context.Context) error {
|
func (mc *mailContainerCache) populateMailRoot(ctx context.Context) error {
|
||||||
f, err := mc.getter.GetContainerByID(ctx, mc.userID, rootFolderAlias)
|
f, err := mc.getter.GetContainerByID(ctx, mc.userID, api.MsgFolderRoot)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return clues.Wrap(err, "fetching root folder")
|
return clues.Wrap(err, "fetching root folder")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -62,7 +62,7 @@ func (suite *MailFolderCacheIntegrationSuite) TestDeltaFetch() {
|
|||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "Default Root",
|
name: "Default Root",
|
||||||
root: rootFolderAlias,
|
root: api.MsgFolderRoot,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Node Root",
|
name: "Node Root",
|
||||||
|
|||||||
@ -52,7 +52,7 @@ func (h mailRestoreHandler) CreateContainer(
|
|||||||
userID, parentContainerID, containerName string,
|
userID, parentContainerID, containerName string,
|
||||||
) (graph.Container, error) {
|
) (graph.Container, error) {
|
||||||
if len(parentContainerID) == 0 {
|
if len(parentContainerID) == 0 {
|
||||||
parentContainerID = rootFolderAlias
|
parentContainerID = api.MsgFolderRoot
|
||||||
}
|
}
|
||||||
|
|
||||||
return h.ac.CreateContainer(ctx, userID, parentContainerID, containerName)
|
return h.ac.CreateContainer(ctx, userID, parentContainerID, containerName)
|
||||||
@ -67,7 +67,7 @@ func (h mailRestoreHandler) GetContainerByName(
|
|||||||
|
|
||||||
// always returns rootFolderAlias
|
// always returns rootFolderAlias
|
||||||
func (h mailRestoreHandler) orRootContainer(string) string {
|
func (h mailRestoreHandler) orRootContainer(string) string {
|
||||||
return rootFolderAlias
|
return api.MsgFolderRoot
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h mailRestoreHandler) restore(
|
func (h mailRestoreHandler) restore(
|
||||||
|
|||||||
@ -17,7 +17,6 @@ import (
|
|||||||
evmock "github.com/alcionai/corso/src/internal/events/mock"
|
evmock "github.com/alcionai/corso/src/internal/events/mock"
|
||||||
"github.com/alcionai/corso/src/internal/kopia"
|
"github.com/alcionai/corso/src/internal/kopia"
|
||||||
"github.com/alcionai/corso/src/internal/m365"
|
"github.com/alcionai/corso/src/internal/m365"
|
||||||
"github.com/alcionai/corso/src/internal/m365/exchange"
|
|
||||||
exchMock "github.com/alcionai/corso/src/internal/m365/exchange/mock"
|
exchMock "github.com/alcionai/corso/src/internal/m365/exchange/mock"
|
||||||
"github.com/alcionai/corso/src/internal/m365/graph"
|
"github.com/alcionai/corso/src/internal/m365/graph"
|
||||||
"github.com/alcionai/corso/src/internal/m365/mock"
|
"github.com/alcionai/corso/src/internal/m365/mock"
|
||||||
@ -282,9 +281,9 @@ func setupExchangeBackup(
|
|||||||
|
|
||||||
esel.DiscreteOwner = owner
|
esel.DiscreteOwner = owner
|
||||||
esel.Include(
|
esel.Include(
|
||||||
esel.MailFolders([]string{exchange.DefaultMailFolder}, selectors.PrefixMatch()),
|
esel.MailFolders([]string{api.MailInbox}, selectors.PrefixMatch()),
|
||||||
esel.ContactFolders([]string{exchange.DefaultContactFolder}, selectors.PrefixMatch()),
|
esel.ContactFolders([]string{api.DefaultContacts}, selectors.PrefixMatch()),
|
||||||
esel.EventCalendars([]string{exchange.DefaultCalendar}, selectors.PrefixMatch()))
|
esel.EventCalendars([]string{api.DefaultCalendar}, selectors.PrefixMatch()))
|
||||||
|
|
||||||
ctrl, sel := ControllerWithSelector(t, ctx, acct, resource.Users, esel.Selector, nil, nil)
|
ctrl, sel := ControllerWithSelector(t, ctx, acct, resource.Users, esel.Selector, nil, nil)
|
||||||
|
|
||||||
|
|||||||
@ -64,7 +64,7 @@ func (suite *ExchangeBackupIntgSuite) TestBackup_Run_exchange() {
|
|||||||
name: "Mail",
|
name: "Mail",
|
||||||
selector: func() *selectors.ExchangeBackup {
|
selector: func() *selectors.ExchangeBackup {
|
||||||
sel := selectors.NewExchangeBackup([]string{suite.its.userID})
|
sel := selectors.NewExchangeBackup([]string{suite.its.userID})
|
||||||
sel.Include(sel.MailFolders([]string{exchange.DefaultMailFolder}, selectors.PrefixMatch()))
|
sel.Include(sel.MailFolders([]string{api.MailInbox}, selectors.PrefixMatch()))
|
||||||
sel.DiscreteOwner = suite.its.userID
|
sel.DiscreteOwner = suite.its.userID
|
||||||
|
|
||||||
return sel
|
return sel
|
||||||
@ -76,7 +76,7 @@ func (suite *ExchangeBackupIntgSuite) TestBackup_Run_exchange() {
|
|||||||
name: "Contacts",
|
name: "Contacts",
|
||||||
selector: func() *selectors.ExchangeBackup {
|
selector: func() *selectors.ExchangeBackup {
|
||||||
sel := selectors.NewExchangeBackup([]string{suite.its.userID})
|
sel := selectors.NewExchangeBackup([]string{suite.its.userID})
|
||||||
sel.Include(sel.ContactFolders([]string{exchange.DefaultContactFolder}, selectors.PrefixMatch()))
|
sel.Include(sel.ContactFolders([]string{api.DefaultContacts}, selectors.PrefixMatch()))
|
||||||
return sel
|
return sel
|
||||||
},
|
},
|
||||||
category: path.ContactsCategory,
|
category: path.ContactsCategory,
|
||||||
@ -86,7 +86,7 @@ func (suite *ExchangeBackupIntgSuite) TestBackup_Run_exchange() {
|
|||||||
name: "Calendar Events",
|
name: "Calendar Events",
|
||||||
selector: func() *selectors.ExchangeBackup {
|
selector: func() *selectors.ExchangeBackup {
|
||||||
sel := selectors.NewExchangeBackup([]string{suite.its.userID})
|
sel := selectors.NewExchangeBackup([]string{suite.its.userID})
|
||||||
sel.Include(sel.EventCalendars([]string{exchange.DefaultCalendar}, selectors.PrefixMatch()))
|
sel.Include(sel.EventCalendars([]string{api.DefaultCalendar}, selectors.PrefixMatch()))
|
||||||
return sel
|
return sel
|
||||||
},
|
},
|
||||||
category: path.EventsCategory,
|
category: path.EventsCategory,
|
||||||
|
|||||||
10
src/pkg/services/m365/api/consts.go
Normal file
10
src/pkg/services/m365/api/consts.go
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package api
|
||||||
|
|
||||||
|
// Well knwon Folder Names
|
||||||
|
// Mail Definitions: https://docs.microsoft.com/en-us/graph/api/resources/mailfolder?view=graph-rest-1.0
|
||||||
|
const (
|
||||||
|
DefaultCalendar = "Calendar"
|
||||||
|
DefaultContacts = "Contacts"
|
||||||
|
MailInbox = "Inbox"
|
||||||
|
MsgFolderRoot = "msgfolderroot"
|
||||||
|
)
|
||||||
@ -39,7 +39,7 @@ func (suite *MailPagerIntgSuite) TestMail_GetItemsInContainerByCollisionKey() {
|
|||||||
ctx, flush := tester.NewContext(t)
|
ctx, flush := tester.NewContext(t)
|
||||||
defer flush()
|
defer flush()
|
||||||
|
|
||||||
container, err := ac.GetContainerByID(ctx, suite.its.userID, "inbox")
|
container, err := ac.GetContainerByID(ctx, suite.its.userID, api.MailInbox)
|
||||||
require.NoError(t, err, clues.ToCore(err))
|
require.NoError(t, err, clues.ToCore(err))
|
||||||
|
|
||||||
msgs, err := ac.Stable.
|
msgs, err := ac.Stable.
|
||||||
@ -61,7 +61,7 @@ func (suite *MailPagerIntgSuite) TestMail_GetItemsInContainerByCollisionKey() {
|
|||||||
|
|
||||||
expect := maps.Keys(expectM)
|
expect := maps.Keys(expectM)
|
||||||
|
|
||||||
results, err := suite.its.ac.Mail().GetItemsInContainerByCollisionKey(ctx, suite.its.userID, "inbox")
|
results, err := suite.its.ac.Mail().GetItemsInContainerByCollisionKey(ctx, suite.its.userID, api.MailInbox)
|
||||||
require.NoError(t, err, clues.ToCore(err))
|
require.NoError(t, err, clues.ToCore(err))
|
||||||
require.Less(t, 0, len(results), "requires at least one result")
|
require.Less(t, 0, len(results), "requires at least one result")
|
||||||
|
|
||||||
|
|||||||
@ -423,7 +423,7 @@ func (suite *MailAPIIntgSuite) TestMail_GetContainerByName() {
|
|||||||
expectErr assert.ErrorAssertionFunc
|
expectErr assert.ErrorAssertionFunc
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "Inbox",
|
name: api.MailInbox,
|
||||||
expectErr: assert.NoError,
|
expectErr: assert.NoError,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@ -292,7 +292,7 @@ func (c Users) GetMailInbox(
|
|||||||
Users().
|
Users().
|
||||||
ByUserId(userID).
|
ByUserId(userID).
|
||||||
MailFolders().
|
MailFolders().
|
||||||
ByMailFolderId("inbox").
|
ByMailFolderId(MailInbox).
|
||||||
Get(ctx, nil)
|
Get(ctx, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, graph.Wrap(ctx, err, "getting MailFolders")
|
return nil, graph.Wrap(ctx, err, "getting MailFolders")
|
||||||
|
|||||||
@ -145,7 +145,7 @@ func (suite *UsersIntgSuite) TestUsers_GetInfo_errors() {
|
|||||||
interceptV1Path("users", "user", "drive").
|
interceptV1Path("users", "user", "drive").
|
||||||
Reply(400).
|
Reply(400).
|
||||||
JSON(parseableToMap(t, odErrMsg("anycode", string(graph.MysiteNotFound))))
|
JSON(parseableToMap(t, odErrMsg("anycode", string(graph.MysiteNotFound))))
|
||||||
interceptV1Path("users", "user", "mailFolders", "inbox").
|
interceptV1Path("users", "user", "mailFolders", api.MailInbox).
|
||||||
Reply(400).
|
Reply(400).
|
||||||
JSON(parseableToMap(t, odErr(string(graph.ResourceNotFound))))
|
JSON(parseableToMap(t, odErr(string(graph.ResourceNotFound))))
|
||||||
},
|
},
|
||||||
@ -159,7 +159,7 @@ func (suite *UsersIntgSuite) TestUsers_GetInfo_errors() {
|
|||||||
interceptV1Path("users", "user", "drive").
|
interceptV1Path("users", "user", "drive").
|
||||||
Reply(400).
|
Reply(400).
|
||||||
JSON(parseableToMap(t, odErrMsg("anycode", string(graph.NoSPLicense))))
|
JSON(parseableToMap(t, odErrMsg("anycode", string(graph.NoSPLicense))))
|
||||||
interceptV1Path("users", "user", "mailFolders", "inbox").
|
interceptV1Path("users", "user", "mailFolders", api.MailInbox).
|
||||||
Reply(400).
|
Reply(400).
|
||||||
JSON(parseableToMap(t, odErr(string(graph.ResourceNotFound))))
|
JSON(parseableToMap(t, odErr(string(graph.ResourceNotFound))))
|
||||||
},
|
},
|
||||||
@ -184,7 +184,7 @@ func (suite *UsersIntgSuite) TestUsers_GetInfo_errors() {
|
|||||||
interceptV1Path("users", "user", "drive").
|
interceptV1Path("users", "user", "drive").
|
||||||
Reply(200).
|
Reply(200).
|
||||||
JSON(parseableToMap(t, models.NewDrive()))
|
JSON(parseableToMap(t, models.NewDrive()))
|
||||||
interceptV1Path("users", "user", "mailFolders", "inbox").
|
interceptV1Path("users", "user", "mailFolders", api.MailInbox).
|
||||||
Reply(400).
|
Reply(400).
|
||||||
JSON(parseableToMap(t, odErr(string(graph.RequestResourceNotFound))))
|
JSON(parseableToMap(t, odErr(string(graph.RequestResourceNotFound))))
|
||||||
},
|
},
|
||||||
@ -198,7 +198,7 @@ func (suite *UsersIntgSuite) TestUsers_GetInfo_errors() {
|
|||||||
interceptV1Path("users", "user", "drive").
|
interceptV1Path("users", "user", "drive").
|
||||||
Reply(200).
|
Reply(200).
|
||||||
JSON(parseableToMap(t, models.NewDrive()))
|
JSON(parseableToMap(t, models.NewDrive()))
|
||||||
interceptV1Path("users", "user", "mailFolders", "inbox").
|
interceptV1Path("users", "user", "mailFolders", api.MailInbox).
|
||||||
Reply(400).
|
Reply(400).
|
||||||
JSON(parseableToMap(t, odErr(string(graph.MailboxNotEnabledForRESTAPI))))
|
JSON(parseableToMap(t, odErr(string(graph.MailboxNotEnabledForRESTAPI))))
|
||||||
},
|
},
|
||||||
@ -212,7 +212,7 @@ func (suite *UsersIntgSuite) TestUsers_GetInfo_errors() {
|
|||||||
interceptV1Path("users", "user", "drive").
|
interceptV1Path("users", "user", "drive").
|
||||||
Reply(200).
|
Reply(200).
|
||||||
JSON(parseableToMap(t, models.NewDrive()))
|
JSON(parseableToMap(t, models.NewDrive()))
|
||||||
interceptV1Path("users", "user", "mailFolders", "inbox").
|
interceptV1Path("users", "user", "mailFolders", api.MailInbox).
|
||||||
Reply(400).
|
Reply(400).
|
||||||
JSON(parseableToMap(t, odErr(string(graph.AuthenticationError))))
|
JSON(parseableToMap(t, odErr(string(graph.AuthenticationError))))
|
||||||
},
|
},
|
||||||
@ -226,7 +226,7 @@ func (suite *UsersIntgSuite) TestUsers_GetInfo_errors() {
|
|||||||
interceptV1Path("users", "user", "drive").
|
interceptV1Path("users", "user", "drive").
|
||||||
Reply(200).
|
Reply(200).
|
||||||
JSON(parseableToMap(t, models.NewDrive()))
|
JSON(parseableToMap(t, models.NewDrive()))
|
||||||
interceptV1Path("users", "user", "mailFolders", "inbox").
|
interceptV1Path("users", "user", "mailFolders", api.MailInbox).
|
||||||
Reply(400).
|
Reply(400).
|
||||||
JSON(parseableToMap(t, odErrMsg("somecode", "somemessage")))
|
JSON(parseableToMap(t, odErrMsg("somecode", "somemessage")))
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user