diff --git a/src/cli/backup/exchange_e2e_test.go b/src/cli/backup/exchange_e2e_test.go index d3b6561c9..587888d47 100644 --- a/src/cli/backup/exchange_e2e_test.go +++ b/src/cli/backup/exchange_e2e_test.go @@ -20,7 +20,6 @@ import ( "github.com/alcionai/corso/src/cli/print" cliTD "github.com/alcionai/corso/src/cli/testdata" "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/tester" "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/repository" "github.com/alcionai/corso/src/pkg/selectors" + "github.com/alcionai/corso/src/pkg/services/m365/api" "github.com/alcionai/corso/src/pkg/storage" storeTD "github.com/alcionai/corso/src/pkg/storage/testdata" ) @@ -483,13 +483,13 @@ func (suite *PreparedBackupExchangeE2ESuite) SetupSuite() { switch set { case email: - scopes = sel.MailFolders([]string{exchange.DefaultMailFolder}, selectors.PrefixMatch()) + scopes = sel.MailFolders([]string{api.MailInbox}, selectors.PrefixMatch()) case contacts: - scopes = sel.ContactFolders([]string{exchange.DefaultContactFolder}, selectors.PrefixMatch()) + scopes = sel.ContactFolders([]string{api.DefaultContacts}, selectors.PrefixMatch()) case events: - scopes = sel.EventCalendars([]string{exchange.DefaultCalendar}, selectors.PrefixMatch()) + scopes = sel.EventCalendars([]string{api.DefaultCalendar}, selectors.PrefixMatch()) } sel.Include(scopes) @@ -728,7 +728,7 @@ func (suite *BackupDeleteExchangeE2ESuite) SetupSuite() { // some tests require an existing backup 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) require.NoError(t, err, clues.ToCore(err)) diff --git a/src/cli/restore/exchange_e2e_test.go b/src/cli/restore/exchange_e2e_test.go index 83d9ad977..56b0e7255 100644 --- a/src/cli/restore/exchange_e2e_test.go +++ b/src/cli/restore/exchange_e2e_test.go @@ -15,7 +15,6 @@ import ( "github.com/alcionai/corso/src/cli/flags" cliTD "github.com/alcionai/corso/src/cli/testdata" "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/tester" "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/repository" "github.com/alcionai/corso/src/pkg/selectors" + "github.com/alcionai/corso/src/pkg/services/m365/api" "github.com/alcionai/corso/src/pkg/storage" storeTD "github.com/alcionai/corso/src/pkg/storage/testdata" ) @@ -96,13 +96,13 @@ func (suite *RestoreExchangeE2ESuite) SetupSuite() { switch set { case email: - scopes = sel.MailFolders([]string{exchange.DefaultMailFolder}, selectors.PrefixMatch()) + scopes = sel.MailFolders([]string{api.MailInbox}, selectors.PrefixMatch()) case contacts: - scopes = sel.ContactFolders([]string{exchange.DefaultContactFolder}, selectors.PrefixMatch()) + scopes = sel.ContactFolders([]string{api.DefaultContacts}, selectors.PrefixMatch()) case events: - scopes = sel.EventCalendars([]string{exchange.DefaultCalendar}, selectors.PrefixMatch()) + scopes = sel.EventCalendars([]string{api.DefaultCalendar}, selectors.PrefixMatch()) } sel.Include(scopes) diff --git a/src/internal/m365/backup_test.go b/src/internal/m365/backup_test.go index 894f6a747..bb59741f8 100644 --- a/src/internal/m365/backup_test.go +++ b/src/internal/m365/backup_test.go @@ -76,7 +76,7 @@ func (suite *DataCollectionIntgSuite) TestExchangeDataCollection() { name: "Email", getSelector: func(t *testing.T) selectors.Selector { 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 return sel.Selector }, @@ -85,7 +85,7 @@ func (suite *DataCollectionIntgSuite) TestExchangeDataCollection() { name: "Contacts", getSelector: func(t *testing.T) selectors.Selector { 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 return sel.Selector }, diff --git a/src/internal/m365/controller_test.go b/src/internal/m365/controller_test.go index d9b3bf302..6d04b7e9e 100644 --- a/src/internal/m365/controller_test.go +++ b/src/internal/m365/controller_test.go @@ -29,6 +29,7 @@ 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" ) // --------------------------------------------------------------------------- @@ -672,7 +673,7 @@ func (suite *ControllerIntegrationSuite) TestRestoreAndBackup() { resourceCat: resource.Users, collections: []stub.ColInfo{ { - PathElements: []string{"Inbox"}, + PathElements: []string{api.MailInbox}, Category: path.EmailCategory, Items: []stub.ItemInfo{ { @@ -699,7 +700,7 @@ func (suite *ControllerIntegrationSuite) TestRestoreAndBackup() { resourceCat: resource.Users, collections: []stub.ColInfo{ { - PathElements: []string{"Inbox"}, + PathElements: []string{api.MailInbox}, Category: path.EmailCategory, Items: []stub.ItemInfo{ { @@ -738,7 +739,7 @@ func (suite *ControllerIntegrationSuite) TestRestoreAndBackup() { }, }, { - PathElements: []string{"Work", "Inbox"}, + PathElements: []string{"Work", api.MailInbox}, Category: path.EmailCategory, 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, Items: []stub.ItemInfo{ { @@ -1116,7 +1117,7 @@ func (suite *ControllerIntegrationSuite) TestRestoreAndBackup_largeMailAttachmen resourceCat: resource.Users, collections: []stub.ColInfo{ { - PathElements: []string{"Inbox"}, + PathElements: []string{api.MailInbox}, Category: path.EmailCategory, Items: []stub.ItemInfo{ { diff --git a/src/internal/m365/exchange/backup.go b/src/internal/m365/exchange/backup.go index d69f71225..0d7cb9740 100644 --- a/src/internal/m365/exchange/backup.go +++ b/src/internal/m365/exchange/backup.go @@ -566,8 +566,8 @@ func includeContainer( ) // Clause ensures that DefaultContactFolder is inspected properly - if category == path.ContactsCategory && ptr.Val(c.GetDisplayName()) == DefaultContactFolder { - loc = loc.Append(DefaultContactFolder) + if category == path.ContactsCategory && ptr.Val(c.GetDisplayName()) == api.DefaultContacts { + loc = loc.Append(api.DefaultContacts) } dirPath, err := pb.ToDataLayerExchangePathForCategory( diff --git a/src/internal/m365/exchange/backup_test.go b/src/internal/m365/exchange/backup_test.go index bec9d50c9..8ac8c14dd 100644 --- a/src/internal/m365/exchange/backup_test.go +++ b/src/internal/m365/exchange/backup_test.go @@ -438,22 +438,22 @@ func (suite *BackupIntgSuite) TestMailFetch() { { name: "Folder Iterative Check Mail", scope: selectors.NewExchangeBackup(users).MailFolders( - []string{DefaultMailFolder}, + []string{api.MailInbox}, selectors.PrefixMatch(), )[0], folderNames: map[string]struct{}{ - DefaultMailFolder: {}, + api.MailInbox: {}, }, canMakeDeltaQueries: true, }, { name: "Folder Iterative Check Mail Non-Delta", scope: selectors.NewExchangeBackup(users).MailFolders( - []string{DefaultMailFolder}, + []string{api.MailInbox}, selectors.PrefixMatch(), )[0], folderNames: map[string]struct{}{ - DefaultMailFolder: {}, + api.MailInbox: {}, }, canMakeDeltaQueries: false, }, @@ -520,21 +520,21 @@ func (suite *BackupIntgSuite) TestDelta() { { name: "Mail", scope: selectors.NewExchangeBackup(users).MailFolders( - []string{DefaultMailFolder}, + []string{api.MailInbox}, selectors.PrefixMatch(), )[0], }, { name: "Contacts", scope: selectors.NewExchangeBackup(users).ContactFolders( - []string{DefaultContactFolder}, + []string{api.DefaultContacts}, selectors.PrefixMatch(), )[0], }, { name: "Events", scope: selectors.NewExchangeBackup(users).EventCalendars( - []string{DefaultCalendar}, + []string{api.DefaultCalendar}, selectors.PrefixMatch(), )[0], }, @@ -624,7 +624,7 @@ func (suite *BackupIntgSuite) TestMailSerializationRegression() { ) sel := selectors.NewExchangeBackup(users) - sel.Include(sel.MailFolders([]string{DefaultMailFolder}, selectors.PrefixMatch())) + sel.Include(sel.MailFolders([]string{api.MailInbox}, selectors.PrefixMatch())) collections, err := createCollections( ctx, @@ -688,7 +688,7 @@ func (suite *BackupIntgSuite) TestContactSerializationRegression() { { name: "Default Contact Folder", scope: selectors.NewExchangeBackup(users).ContactFolders( - []string{DefaultContactFolder}, + []string{api.DefaultContacts}, selectors.PrefixMatch())[0], }, } @@ -752,7 +752,7 @@ func (suite *BackupIntgSuite) TestContactSerializationRegression() { assert.Equal( t, edc.(data.LocationPather).LocationPath().String(), - DefaultContactFolder) + api.DefaultContacts) assert.NotZero(t, count) } @@ -777,7 +777,7 @@ func (suite *BackupIntgSuite) TestEventsSerializationRegression() { ) fn := func(gcc graph.CachedContainer) error { - if ptr.Val(gcc.GetDisplayName()) == DefaultCalendar { + if ptr.Val(gcc.GetDisplayName()) == api.DefaultCalendar { calID = ptr.Val(gcc.GetId()) } @@ -788,7 +788,12 @@ func (suite *BackupIntgSuite) TestEventsSerializationRegression() { 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)) tests := []struct { @@ -799,7 +804,7 @@ func (suite *BackupIntgSuite) TestEventsSerializationRegression() { name: "Default Event Calendar", expected: calID, scope: selectors.NewExchangeBackup(users).EventCalendars( - []string{DefaultCalendar}, + []string{api.DefaultCalendar}, selectors.PrefixMatch(), )[0], }, diff --git a/src/internal/m365/exchange/consts.go b/src/internal/m365/exchange/consts.go index e45de0bf0..32876d050 100644 --- a/src/internal/m365/exchange/consts.go +++ b/src/internal/m365/exchange/consts.go @@ -27,15 +27,4 @@ const ( // MailReceiveDateTimeOverrideProperty allows receive date time to be updated. // Section: 2.789 PidTagMessageDeliveryTime 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" ) diff --git a/src/internal/m365/exchange/contacts_backup.go b/src/internal/m365/exchange/contacts_backup.go index fb8fde2ab..91c7f3748 100644 --- a/src/internal/m365/exchange/contacts_backup.go +++ b/src/internal/m365/exchange/contacts_backup.go @@ -32,7 +32,7 @@ func (h contactBackupHandler) itemHandler() itemGetterSerializer { func (h contactBackupHandler) NewContainerCache( userID string, ) (string, graph.ContainerResolver) { - return DefaultContactFolder, &contactContainerCache{ + return api.DefaultContacts, &contactContainerCache{ userID: userID, enumer: h.ac, getter: h.ac, diff --git a/src/internal/m365/exchange/container_resolver_test.go b/src/internal/m365/exchange/container_resolver_test.go index 220d5e878..908aa6c9b 100644 --- a/src/internal/m365/exchange/container_resolver_test.go +++ b/src/internal/m365/exchange/container_resolver_test.go @@ -725,45 +725,45 @@ func (suite *ContainerResolverSuite) TestPopulate() { { name: "Default Event Cache", // Fine as long as this isn't running against a migrated Exchange server. - folderInCache: DefaultCalendar, - root: DefaultCalendar, - basePath: DefaultCalendar, + folderInCache: api.DefaultCalendar, + root: api.DefaultCalendar, + basePath: api.DefaultCalendar, resolverFunc: eventFunc, canFind: assert.True, }, { name: "Default Event Folder Hidden", - folderInCache: DefaultContactFolder, - root: DefaultCalendar, + folderInCache: api.DefaultContacts, + root: api.DefaultCalendar, canFind: assert.False, resolverFunc: eventFunc, }, { name: "Name Not in Cache", folderInCache: "testFooBarWhoBar", - root: DefaultCalendar, + root: api.DefaultCalendar, canFind: assert.False, resolverFunc: eventFunc, }, { name: "Default Contact Cache", - folderInCache: DefaultContactFolder, - root: DefaultContactFolder, - basePath: DefaultContactFolder, + folderInCache: api.DefaultContacts, + root: api.DefaultContacts, + basePath: api.DefaultContacts, canFind: assert.True, resolverFunc: contactFunc, }, { name: "Default Contact Hidden", - folderInCache: DefaultContactFolder, - root: DefaultContactFolder, + folderInCache: api.DefaultContacts, + root: api.DefaultContacts, canFind: assert.False, resolverFunc: contactFunc, }, { name: "Name Not in Cache", folderInCache: "testFooBarWhoBar", - root: DefaultContactFolder, + root: api.DefaultContacts, canFind: assert.False, resolverFunc: contactFunc, }, diff --git a/src/internal/m365/exchange/events_backup.go b/src/internal/m365/exchange/events_backup.go index c1502c965..a4e9991ed 100644 --- a/src/internal/m365/exchange/events_backup.go +++ b/src/internal/m365/exchange/events_backup.go @@ -32,7 +32,7 @@ func (h eventBackupHandler) itemHandler() itemGetterSerializer { func (h eventBackupHandler) NewContainerCache( userID string, ) (string, graph.ContainerResolver) { - return DefaultCalendar, &eventContainerCache{ + return api.DefaultCalendar, &eventContainerCache{ userID: userID, enumer: h.ac, getter: h.ac, diff --git a/src/internal/m365/exchange/events_container_cache.go b/src/internal/m365/exchange/events_container_cache.go index d89a5caa2..eb8a70ae4 100644 --- a/src/internal/m365/exchange/events_container_cache.go +++ b/src/internal/m365/exchange/events_container_cache.go @@ -9,6 +9,7 @@ import ( "github.com/alcionai/corso/src/internal/m365/graph" "github.com/alcionai/corso/src/pkg/fault" "github.com/alcionai/corso/src/pkg/path" + "github.com/alcionai/corso/src/pkg/services/m365/api" ) var _ graph.ContainerResolver = &eventContainerCache{} @@ -38,7 +39,7 @@ func (ecc *eventContainerCache) init( // Action ensures that cache will stop at appropriate level. // @error iff the struct is not properly instantiated func (ecc *eventContainerCache) populateEventRoot(ctx context.Context) error { - container := DefaultCalendar + container := api.DefaultCalendar f, err := ecc.getter.GetContainerByID(ctx, ecc.userID, container) if err != nil { diff --git a/src/internal/m365/exchange/mail_backup.go b/src/internal/m365/exchange/mail_backup.go index ecd31919c..d1d92a109 100644 --- a/src/internal/m365/exchange/mail_backup.go +++ b/src/internal/m365/exchange/mail_backup.go @@ -32,7 +32,7 @@ func (h mailBackupHandler) itemHandler() itemGetterSerializer { func (h mailBackupHandler) NewContainerCache( userID string, ) (string, graph.ContainerResolver) { - return rootFolderAlias, &mailContainerCache{ + return api.MsgFolderRoot, &mailContainerCache{ userID: userID, enumer: h.ac, getter: h.ac, diff --git a/src/internal/m365/exchange/mail_container_cache.go b/src/internal/m365/exchange/mail_container_cache.go index cf7b0bcdc..c499de40b 100644 --- a/src/internal/m365/exchange/mail_container_cache.go +++ b/src/internal/m365/exchange/mail_container_cache.go @@ -8,6 +8,7 @@ import ( "github.com/alcionai/corso/src/internal/m365/graph" "github.com/alcionai/corso/src/pkg/fault" "github.com/alcionai/corso/src/pkg/path" + "github.com/alcionai/corso/src/pkg/services/m365/api" ) var ( @@ -65,7 +66,7 @@ func (mc *mailContainerCache) init( // Action ensures that cache will stop at appropriate level. // @error iff the struct is not properly instantiated 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 { return clues.Wrap(err, "fetching root folder") } diff --git a/src/internal/m365/exchange/mail_container_cache_test.go b/src/internal/m365/exchange/mail_container_cache_test.go index c206dff5b..b95a9a170 100644 --- a/src/internal/m365/exchange/mail_container_cache_test.go +++ b/src/internal/m365/exchange/mail_container_cache_test.go @@ -62,7 +62,7 @@ func (suite *MailFolderCacheIntegrationSuite) TestDeltaFetch() { }{ { name: "Default Root", - root: rootFolderAlias, + root: api.MsgFolderRoot, }, { name: "Node Root", diff --git a/src/internal/m365/exchange/mail_restore.go b/src/internal/m365/exchange/mail_restore.go index f7e10d991..5aa7f88db 100644 --- a/src/internal/m365/exchange/mail_restore.go +++ b/src/internal/m365/exchange/mail_restore.go @@ -52,7 +52,7 @@ func (h mailRestoreHandler) CreateContainer( userID, parentContainerID, containerName string, ) (graph.Container, error) { if len(parentContainerID) == 0 { - parentContainerID = rootFolderAlias + parentContainerID = api.MsgFolderRoot } return h.ac.CreateContainer(ctx, userID, parentContainerID, containerName) @@ -67,7 +67,7 @@ func (h mailRestoreHandler) GetContainerByName( // always returns rootFolderAlias func (h mailRestoreHandler) orRootContainer(string) string { - return rootFolderAlias + return api.MsgFolderRoot } func (h mailRestoreHandler) restore( diff --git a/src/internal/operations/restore_test.go b/src/internal/operations/restore_test.go index 9b43551f9..7cf9fcf2e 100644 --- a/src/internal/operations/restore_test.go +++ b/src/internal/operations/restore_test.go @@ -17,7 +17,6 @@ import ( evmock "github.com/alcionai/corso/src/internal/events/mock" "github.com/alcionai/corso/src/internal/kopia" "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" "github.com/alcionai/corso/src/internal/m365/graph" "github.com/alcionai/corso/src/internal/m365/mock" @@ -282,9 +281,9 @@ func setupExchangeBackup( esel.DiscreteOwner = owner esel.Include( - esel.MailFolders([]string{exchange.DefaultMailFolder}, selectors.PrefixMatch()), - esel.ContactFolders([]string{exchange.DefaultContactFolder}, selectors.PrefixMatch()), - esel.EventCalendars([]string{exchange.DefaultCalendar}, selectors.PrefixMatch())) + esel.MailFolders([]string{api.MailInbox}, selectors.PrefixMatch()), + esel.ContactFolders([]string{api.DefaultContacts}, selectors.PrefixMatch()), + esel.EventCalendars([]string{api.DefaultCalendar}, selectors.PrefixMatch())) ctrl, sel := ControllerWithSelector(t, ctx, acct, resource.Users, esel.Selector, nil, nil) diff --git a/src/internal/operations/test/exchange_test.go b/src/internal/operations/test/exchange_test.go index 51f8488c0..3edcea9a8 100644 --- a/src/internal/operations/test/exchange_test.go +++ b/src/internal/operations/test/exchange_test.go @@ -64,7 +64,7 @@ func (suite *ExchangeBackupIntgSuite) TestBackup_Run_exchange() { name: "Mail", selector: func() *selectors.ExchangeBackup { 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 return sel @@ -76,7 +76,7 @@ func (suite *ExchangeBackupIntgSuite) TestBackup_Run_exchange() { name: "Contacts", selector: func() *selectors.ExchangeBackup { 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 }, category: path.ContactsCategory, @@ -86,7 +86,7 @@ func (suite *ExchangeBackupIntgSuite) TestBackup_Run_exchange() { name: "Calendar Events", selector: func() *selectors.ExchangeBackup { 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 }, category: path.EventsCategory, diff --git a/src/pkg/services/m365/api/consts.go b/src/pkg/services/m365/api/consts.go new file mode 100644 index 000000000..13d88de14 --- /dev/null +++ b/src/pkg/services/m365/api/consts.go @@ -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" +) diff --git a/src/pkg/services/m365/api/mail_pager_test.go b/src/pkg/services/m365/api/mail_pager_test.go index 231e6a6e9..476e13401 100644 --- a/src/pkg/services/m365/api/mail_pager_test.go +++ b/src/pkg/services/m365/api/mail_pager_test.go @@ -39,7 +39,7 @@ func (suite *MailPagerIntgSuite) TestMail_GetItemsInContainerByCollisionKey() { ctx, flush := tester.NewContext(t) 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)) msgs, err := ac.Stable. @@ -61,7 +61,7 @@ func (suite *MailPagerIntgSuite) TestMail_GetItemsInContainerByCollisionKey() { 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.Less(t, 0, len(results), "requires at least one result") diff --git a/src/pkg/services/m365/api/mail_test.go b/src/pkg/services/m365/api/mail_test.go index 460bd2fb2..812e86a0c 100644 --- a/src/pkg/services/m365/api/mail_test.go +++ b/src/pkg/services/m365/api/mail_test.go @@ -423,7 +423,7 @@ func (suite *MailAPIIntgSuite) TestMail_GetContainerByName() { expectErr assert.ErrorAssertionFunc }{ { - name: "Inbox", + name: api.MailInbox, expectErr: assert.NoError, }, { diff --git a/src/pkg/services/m365/api/users.go b/src/pkg/services/m365/api/users.go index 39013dfca..728e1f466 100644 --- a/src/pkg/services/m365/api/users.go +++ b/src/pkg/services/m365/api/users.go @@ -292,7 +292,7 @@ func (c Users) GetMailInbox( Users(). ByUserId(userID). MailFolders(). - ByMailFolderId("inbox"). + ByMailFolderId(MailInbox). Get(ctx, nil) if err != nil { return nil, graph.Wrap(ctx, err, "getting MailFolders") diff --git a/src/pkg/services/m365/api/users_test.go b/src/pkg/services/m365/api/users_test.go index 18924777d..107d12fa7 100644 --- a/src/pkg/services/m365/api/users_test.go +++ b/src/pkg/services/m365/api/users_test.go @@ -145,7 +145,7 @@ func (suite *UsersIntgSuite) TestUsers_GetInfo_errors() { interceptV1Path("users", "user", "drive"). Reply(400). JSON(parseableToMap(t, odErrMsg("anycode", string(graph.MysiteNotFound)))) - interceptV1Path("users", "user", "mailFolders", "inbox"). + interceptV1Path("users", "user", "mailFolders", api.MailInbox). Reply(400). JSON(parseableToMap(t, odErr(string(graph.ResourceNotFound)))) }, @@ -159,7 +159,7 @@ func (suite *UsersIntgSuite) TestUsers_GetInfo_errors() { interceptV1Path("users", "user", "drive"). Reply(400). JSON(parseableToMap(t, odErrMsg("anycode", string(graph.NoSPLicense)))) - interceptV1Path("users", "user", "mailFolders", "inbox"). + interceptV1Path("users", "user", "mailFolders", api.MailInbox). Reply(400). JSON(parseableToMap(t, odErr(string(graph.ResourceNotFound)))) }, @@ -184,7 +184,7 @@ func (suite *UsersIntgSuite) TestUsers_GetInfo_errors() { interceptV1Path("users", "user", "drive"). Reply(200). JSON(parseableToMap(t, models.NewDrive())) - interceptV1Path("users", "user", "mailFolders", "inbox"). + interceptV1Path("users", "user", "mailFolders", api.MailInbox). Reply(400). JSON(parseableToMap(t, odErr(string(graph.RequestResourceNotFound)))) }, @@ -198,7 +198,7 @@ func (suite *UsersIntgSuite) TestUsers_GetInfo_errors() { interceptV1Path("users", "user", "drive"). Reply(200). JSON(parseableToMap(t, models.NewDrive())) - interceptV1Path("users", "user", "mailFolders", "inbox"). + interceptV1Path("users", "user", "mailFolders", api.MailInbox). Reply(400). JSON(parseableToMap(t, odErr(string(graph.MailboxNotEnabledForRESTAPI)))) }, @@ -212,7 +212,7 @@ func (suite *UsersIntgSuite) TestUsers_GetInfo_errors() { interceptV1Path("users", "user", "drive"). Reply(200). JSON(parseableToMap(t, models.NewDrive())) - interceptV1Path("users", "user", "mailFolders", "inbox"). + interceptV1Path("users", "user", "mailFolders", api.MailInbox). Reply(400). JSON(parseableToMap(t, odErr(string(graph.AuthenticationError)))) }, @@ -226,7 +226,7 @@ func (suite *UsersIntgSuite) TestUsers_GetInfo_errors() { interceptV1Path("users", "user", "drive"). Reply(200). JSON(parseableToMap(t, models.NewDrive())) - interceptV1Path("users", "user", "mailFolders", "inbox"). + interceptV1Path("users", "user", "mailFolders", api.MailInbox). Reply(400). JSON(parseableToMap(t, odErrMsg("somecode", "somemessage"))) },