From a8a2aee99ddbcca3bceb9c86e922bcc7008b40ce Mon Sep 17 00:00:00 2001 From: Keepers Date: Tue, 26 Sep 2023 16:32:15 -0600 Subject: [PATCH] remove expand drive from root site (#4377) missed the root site call usage of expand drive on the last fix. --- #### Does this PR need a docs update or release note? - [x] :no_entry: No #### Type of change - [x] :bug: Bugfix #### Issue(s) * #4337 #### Test Plan - [x] :muscle: Manual - [x] :zap: Unit test - [x] :green_heart: E2E --- src/internal/m365/service/sharepoint/enabled.go | 5 +++-- .../m365/service/sharepoint/enabled_test.go | 6 +++++- src/pkg/services/m365/api/sites.go | 13 +++++++++---- src/pkg/services/m365/api/sites_test.go | 2 +- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/internal/m365/service/sharepoint/enabled.go b/src/internal/m365/service/sharepoint/enabled.go index d816cad7f..b5507af0f 100644 --- a/src/internal/m365/service/sharepoint/enabled.go +++ b/src/internal/m365/service/sharepoint/enabled.go @@ -7,10 +7,11 @@ import ( "github.com/microsoftgraph/msgraph-sdk-go/models" "github.com/alcionai/corso/src/internal/m365/graph" + "github.com/alcionai/corso/src/pkg/services/m365/api" ) type getSiteRooter interface { - GetRoot(ctx context.Context) (models.Siteable, error) + GetRoot(ctx context.Context, cc api.CallConfig) (models.Siteable, error) } func IsServiceEnabled( @@ -18,7 +19,7 @@ func IsServiceEnabled( gsr getSiteRooter, resource string, ) (bool, error) { - _, err := gsr.GetRoot(ctx) + _, err := gsr.GetRoot(ctx, api.CallConfig{}) if err != nil { if clues.HasLabel(err, graph.LabelsNoSharePointLicense) { return false, nil diff --git a/src/internal/m365/service/sharepoint/enabled_test.go b/src/internal/m365/service/sharepoint/enabled_test.go index af9fe01fb..49d59b909 100644 --- a/src/internal/m365/service/sharepoint/enabled_test.go +++ b/src/internal/m365/service/sharepoint/enabled_test.go @@ -12,6 +12,7 @@ import ( "github.com/alcionai/corso/src/internal/m365/graph" "github.com/alcionai/corso/src/internal/tester" + "github.com/alcionai/corso/src/pkg/services/m365/api" ) type EnabledUnitSuite struct { @@ -29,7 +30,10 @@ type mockGSR struct { err error } -func (m mockGSR) GetRoot(context.Context) (models.Siteable, error) { +func (m mockGSR) GetRoot( + context.Context, + api.CallConfig, +) (models.Siteable, error) { return m.response, m.err } diff --git a/src/pkg/services/m365/api/sites.go b/src/pkg/services/m365/api/sites.go index 2ad3751f1..0865a4f47 100644 --- a/src/pkg/services/m365/api/sites.go +++ b/src/pkg/services/m365/api/sites.go @@ -35,11 +35,16 @@ type Sites struct { // api calls // --------------------------------------------------------------------------- -func (c Sites) GetRoot(ctx context.Context) (models.Siteable, error) { +func (c Sites) GetRoot( + ctx context.Context, + cc CallConfig, +) (models.Siteable, error) { options := &sites.SiteItemRequestBuilderGetRequestConfiguration{ - QueryParameters: &sites.SiteItemRequestBuilderGetQueryParameters{ - Expand: []string{"drive"}, - }, + QueryParameters: &sites.SiteItemRequestBuilderGetQueryParameters{}, + } + + if len(cc.Expand) > 0 { + options.QueryParameters.Expand = cc.Expand } resp, err := c.Stable. diff --git a/src/pkg/services/m365/api/sites_test.go b/src/pkg/services/m365/api/sites_test.go index 64b0387f6..ada517c92 100644 --- a/src/pkg/services/m365/api/sites_test.go +++ b/src/pkg/services/m365/api/sites_test.go @@ -256,7 +256,7 @@ func (suite *SitesIntgSuite) TestGetRoot() { ctx, flush := tester.NewContext(t) defer flush() - result, err := suite.its.ac.Sites().GetRoot(ctx) + result, err := suite.its.ac.Sites().GetRoot(ctx, api.CallConfig{Expand: []string{"drive"}}) require.NoError(t, err) require.NotNil(t, result, "must find the root site") require.NotEmpty(t, ptr.Val(result.GetId()), "must have an id")