remove cli support for exchange item msoft id lookup (#3316)

removes the microsoft item ID from the exchange pathValues set when using only-name selector configuration.  This is the standard config for the cli, thus this removes the ability to filter exchange items from the cli by using their m365 id.

---

#### Does this PR need a docs update or release note?

- [x]  Yes, it's included

#### Type of change

- [x] 🧹 Tech Debt/Cleanup

#### Issue(s)

* #3313

#### Test Plan

- [x] 💪 Manual
- [x]  Unit test
This commit is contained in:
Keepers 2023-05-05 14:28:14 -06:00 committed by GitHub
parent 5b9cd69e29
commit e67e5be977
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 74 additions and 36 deletions

View File

@ -13,8 +13,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Graph requests now automatically retry in case of a Bad Gateway or Gateway Timeout. - Graph requests now automatically retry in case of a Bad Gateway or Gateway Timeout.
- POST Retries following certain status codes (500, 502, 504) will re-use the post body instead of retrying with a no-content request. - POST Retries following certain status codes (500, 502, 504) will re-use the post body instead of retrying with a no-content request.
- Fix nil pointer exception when running an incremental backup on SharePoint where the base backup used an older index data format. - Fix nil pointer exception when running an incremental backup on SharePoint where the base backup used an older index data format.
- --user and --mailbox flags (already not supported) have been removed from CLI examples for details and restore commands. - --user and --mailbox flags have been removed from CLI examples for details and restore commands (they were already not supported, this only updates the docs).
- Improve restore time on large restores by optimizing how items are loaded from the remote repository. - Improve restore time on large restores by optimizing how items are loaded from the remote repository.
- Remove exchange item filtering based on m365 item ID via the CLI.
## [v0.7.0] (beta) - 2023-05-02 ## [v0.7.0] (beta) - 2023-05-02

View File

@ -198,13 +198,6 @@ var (
EmailReceivedBefore: dttm.Format(testdata.Time1.Add(time.Second)), EmailReceivedBefore: dttm.Format(testdata.Time1.Add(time.Second)),
}, },
}, },
{
Name: "MailItemRef",
Expected: []details.Entry{testdata.ExchangeEmailItems[0]},
Opts: utils.ExchangeOpts{
Email: []string{testdata.ExchangeEmailItems[0].ItemRef},
},
},
{ {
Name: "MailShortRef", Name: "MailShortRef",
Expected: []details.Entry{testdata.ExchangeEmailItems[0]}, Expected: []details.Entry{testdata.ExchangeEmailItems[0]},
@ -212,6 +205,15 @@ var (
Email: []string{testdata.ExchangeEmailItemPath1.RR.ShortRef()}, Email: []string{testdata.ExchangeEmailItemPath1.RR.ShortRef()},
}, },
}, },
{
Name: "BadMailItemRef",
// no matches are expected, since exchange ItemRefs
// are not matched when using the CLI's selectors.
Expected: []details.Entry{},
Opts: utils.ExchangeOpts{
Email: []string{testdata.ExchangeEmailItems[0].ItemRef},
},
},
{ {
Name: "MultipleMailShortRef", Name: "MultipleMailShortRef",
Expected: []details.Entry{ Expected: []details.Entry{

View File

@ -617,6 +617,15 @@ func (ec exchangeCategory) pathValues(
item = repo.Item() item = repo.Item()
} }
items := []string{ent.ShortRef, item}
// only include the item ID when the user is NOT matching
// item names. Exchange data does not contain an item name,
// only an ID, and we don't want to mix up the two.
if cfg.OnlyMatchItemNames {
items = []string{ent.ShortRef}
}
// Will hit the if-condition when we're at a top-level folder, but we'll get // Will hit the if-condition when we're at a top-level folder, but we'll get
// the same result when we extract from the RepoRef. // the same result when we extract from the RepoRef.
folder := ent.LocationRef folder := ent.LocationRef
@ -626,7 +635,7 @@ func (ec exchangeCategory) pathValues(
result := map[categorizer][]string{ result := map[categorizer][]string{
folderCat: {folder}, folderCat: {folder},
itemCat: {item, ent.ShortRef}, itemCat: items,
} }
return result, nil return result, nil

View File

@ -1492,48 +1492,74 @@ func (suite *ExchangeSelectorSuite) TestExchangeCategory_leafCat() {
func (suite *ExchangeSelectorSuite) TestExchangeCategory_PathValues() { func (suite *ExchangeSelectorSuite) TestExchangeCategory_PathValues() {
t := suite.T() t := suite.T()
contactPath := stubPath(t, "user", []string{"cfolder.d", "contactitem.d"}, path.ContactsCategory) var (
contactLoc := stubPath(t, "user", []string{"cfolder", "contactitem"}, path.ContactsCategory) contactPath = stubPath(t, "u", []string{"cfolder.d", "contactitem.d"}, path.ContactsCategory)
contactMap := map[categorizer][]string{ contactLoc = stubPath(t, "u", []string{"cfolder", "contactitem"}, path.ContactsCategory)
contactMap = map[categorizer][]string{
ExchangeContactFolder: {contactLoc.Folder(false)}, ExchangeContactFolder: {contactLoc.Folder(false)},
ExchangeContact: {contactPath.Item(), "short"}, ExchangeContact: {contactPath.Item(), "contact-short"},
} }
eventPath := stubPath(t, "user", []string{"ecalendar.d", "eventitem.d"}, path.EventsCategory) contactOnlyNameMap = map[categorizer][]string{
eventLoc := stubPath(t, "user", []string{"ecalendar", "eventitem"}, path.EventsCategory) ExchangeContactFolder: {contactLoc.Folder(false)},
eventMap := map[categorizer][]string{ ExchangeContact: {"contact-short"},
}
eventPath = stubPath(t, "u", []string{"ecalendar.d", "eventitem.d"}, path.EventsCategory)
eventLoc = stubPath(t, "u", []string{"ecalendar", "eventitem"}, path.EventsCategory)
eventMap = map[categorizer][]string{
ExchangeEventCalendar: {eventLoc.Folder(false)}, ExchangeEventCalendar: {eventLoc.Folder(false)},
ExchangeEvent: {eventPath.Item(), "short"}, ExchangeEvent: {eventPath.Item(), "event-short"},
} }
mailPath := stubPath(t, "user", []string{"mfolder.d", "mailitem.d"}, path.EmailCategory) eventOnlyNameMap = map[categorizer][]string{
mailLoc := stubPath(t, "user", []string{"mfolder", "mailitem"}, path.EmailCategory) ExchangeEventCalendar: {eventLoc.Folder(false)},
mailMap := map[categorizer][]string{ ExchangeEvent: {"event-short"},
}
mailPath = stubPath(t, "u", []string{"mfolder.d", "mailitem.d"}, path.EmailCategory)
mailLoc = stubPath(t, "u", []string{"mfolder", "mailitem"}, path.EmailCategory)
mailMap = map[categorizer][]string{
ExchangeMailFolder: {mailLoc.Folder(false)}, ExchangeMailFolder: {mailLoc.Folder(false)},
ExchangeMail: {mailPath.Item(), "short"}, ExchangeMail: {mailPath.Item(), "mail-short"},
} }
mailOnlyNameMap = map[categorizer][]string{
ExchangeMailFolder: {mailLoc.Folder(false)},
ExchangeMail: {"mail-short"},
}
)
table := []struct { table := []struct {
cat exchangeCategory cat exchangeCategory
path path.Path path path.Path
loc path.Path loc path.Path
short string
expect map[categorizer][]string expect map[categorizer][]string
expectOnlyName map[categorizer][]string
}{ }{
{ExchangeContact, contactPath, contactLoc, contactMap}, {ExchangeContact, contactPath, contactLoc, "contact-short", contactMap, contactOnlyNameMap},
{ExchangeEvent, eventPath, eventLoc, eventMap}, {ExchangeEvent, eventPath, eventLoc, "event-short", eventMap, eventOnlyNameMap},
{ExchangeMail, mailPath, mailLoc, mailMap}, {ExchangeMail, mailPath, mailLoc, "mail-short", mailMap, mailOnlyNameMap},
} }
for _, test := range table { for _, test := range table {
suite.Run(string(test.cat), func() { suite.Run(string(test.cat), func() {
t := suite.T() t := suite.T()
ent := details.Entry{ ent := details.Entry{
RepoRef: test.path.String(), RepoRef: test.path.String(),
ShortRef: "short", ShortRef: test.short,
LocationRef: test.loc.Folder(true), LocationRef: test.loc.Folder(true),
ItemRef: test.path.Item(), ItemRef: test.path.Item(),
} }
pvs, err := test.cat.pathValues(test.path, ent, Config{}) pvs, err := test.cat.pathValues(test.path, ent, Config{})
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, test.expect, pvs)
for k := range test.expect {
assert.ElementsMatch(t, test.expect[k], pvs[k])
}
pvs, err = test.cat.pathValues(test.path, ent, Config{OnlyMatchItemNames: true})
require.NoError(t, err)
for k := range test.expectOnlyName {
assert.ElementsMatch(t, test.expectOnlyName[k], pvs[k], k)
}
}) })
} }
} }