From cc5864f852c5ebb4b7c99be027164ab1fa7704ee Mon Sep 17 00:00:00 2001 From: ashmrtn <3891298+ashmrtn@users.noreply.github.com> Date: Tue, 29 Aug 2023 15:08:43 -0700 Subject: [PATCH] Fix data clobbering issue when getting Quota Exceeded status (#4144) Don't clobber the Quota Exceeded status once we get it Add unit test to make sure this doesn't happen --- #### Does this PR need a docs update or release note? - [x] :white_check_mark: Yes, it's included - [ ] :clock1: Yes, but in a later PR - [ ] :no_entry: No #### Type of change - [ ] :sunflower: Feature - [x] :bug: Bugfix - [ ] :world_map: Documentation - [ ] :robot: Supportability/Tests - [ ] :computer: CI/Deployment - [ ] :broom: Tech Debt/Cleanup #### Test Plan - [ ] :muscle: Manual - [x] :zap: Unit test - [ ] :green_heart: E2E --- CHANGELOG.md | 3 +++ src/pkg/services/m365/api/users.go | 2 +- src/pkg/services/m365/api/users_test.go | 27 +++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 58d74df74..4a89634c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] (beta) +### Fixed +- Exchange backups would fail attempting to use delta tokens even if the user was over quota + ## [v0.12.0] (beta) - 2023-08-28 ### Added diff --git a/src/pkg/services/m365/api/users.go b/src/pkg/services/m365/api/users.go index 728e1f466..590eb7a70 100644 --- a/src/pkg/services/m365/api/users.go +++ b/src/pkg/services/m365/api/users.go @@ -238,7 +238,7 @@ func (c Users) GetInfo(ctx context.Context, userID string) (*UserInfo, error) { return nil, clues.Stack(err) } - userInfo.Mailbox.QuotaExceeded = graph.IsErrQuotaExceeded(err) + mi.QuotaExceeded = graph.IsErrQuotaExceeded(err) } userInfo.Mailbox = mi diff --git a/src/pkg/services/m365/api/users_test.go b/src/pkg/services/m365/api/users_test.go index 107d12fa7..d7078e497 100644 --- a/src/pkg/services/m365/api/users_test.go +++ b/src/pkg/services/m365/api/users_test.go @@ -7,6 +7,7 @@ import ( "github.com/h2non/gock" "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/m365/graph" @@ -250,3 +251,29 @@ func (suite *UsersIntgSuite) TestUsers_GetInfo_errors() { }) } } + +func (suite *UsersIntgSuite) TestUsers_GetInfo_quotaExceeded() { + t := suite.T() + ctx, flush := tester.NewContext(t) + + defer flush() + defer gock.Off() + + gock.EnableNetworking() + gock.New(graphAPIHostURL). + // Wildcard match on the inbox folder ID. + Get(v1APIURLPath("users", suite.its.userID, "mailFolders", "(.*)", "messages", "delta")). + Reply(403). + SetHeaders( + map[string]string{ + "Content-Type": "application/json; odata.metadata=minimal; " + + "odata.streaming=true; IEEE754Compatible=false; charset=utf-8", + }, + ). + BodyString(`{"error":{"code":"ErrorQuotaExceeded","message":"The process failed to get the correct properties."}}`) + + output, err := suite.its.gockAC.Users().GetInfo(ctx, suite.its.userID) + require.NoError(t, err, clues.ToCore(err)) + + assert.True(t, output.Mailbox.QuotaExceeded) +}