diff --git a/src/internal/connector/discovery/api/users.go b/src/internal/connector/discovery/api/users.go index 931b689fe..b47fc1184 100644 --- a/src/internal/connector/discovery/api/users.go +++ b/src/internal/connector/discovery/api/users.go @@ -182,10 +182,19 @@ func (c Users) GetInfo(ctx context.Context, userID string) (*UserInfo, error) { var ( err error userInfo = newUserInfo() + + requestParameters = &users.ItemMailFoldersRequestBuilderGetQueryParameters{ + Select: []string{"id"}, + Top: ptr.To[int32](1), // if we get any folders, then we have access. + } + + options = users.ItemMailFoldersRequestBuilderGetRequestConfiguration{ + QueryParameters: requestParameters, + } ) // TODO: OneDrive - _, err = c.stable.Client().UsersById(userID).MailFolders().Get(ctx, nil) + _, err = c.stable.Client().UsersById(userID).MailFolders().Get(ctx, &options) if err != nil { if !graph.IsErrExchangeMailFolderNotFound(err) { return nil, graph.Wrap(ctx, err, "getting user's mail folder") diff --git a/src/internal/connector/exchange/api/api_test.go b/src/internal/connector/exchange/api/api_test.go index c5708f159..3d15cc6ec 100644 --- a/src/internal/connector/exchange/api/api_test.go +++ b/src/internal/connector/exchange/api/api_test.go @@ -84,86 +84,6 @@ func (suite *ExchangeServiceSuite) TestOptionsForCalendars() { } } -// TestOptionsForFolders ensures that approved query options -// are added to the RequestBuildConfiguration. Expected will always be +1 -// on than the input as "id" are always included within the select parameters -func (suite *ExchangeServiceSuite) TestOptionsForFolders() { - tests := []struct { - name string - params []string - checkError assert.ErrorAssertionFunc - expected int - }{ - { - name: "Valid Folder Option", - params: []string{"parentFolderId"}, - checkError: assert.NoError, - expected: 2, - }, - { - name: "Multiple Folder Options: Valid", - params: []string{"displayName", "isHidden"}, - checkError: assert.NoError, - expected: 3, - }, - { - name: "Invalid Folder option param", - params: []string{"status"}, - checkError: assert.Error, - }, - } - for _, test := range tests { - suite.Run(test.name, func() { - t := suite.T() - - config, err := optionsForMailFolders(test.params) - test.checkError(t, err, clues.ToCore(err)) - if err == nil { - assert.Equal(t, test.expected, len(config.QueryParameters.Select)) - } - }) - } -} - -// TestOptionsForContacts similar to TestExchangeService_optionsForFolders -func (suite *ExchangeServiceSuite) TestOptionsForContacts() { - tests := []struct { - name string - params []string - checkError assert.ErrorAssertionFunc - expected int - }{ - { - name: "Valid Contact Option", - params: []string{"displayName"}, - checkError: assert.NoError, - expected: 2, - }, - { - name: "Multiple Contact Options: Valid", - params: []string{"displayName", "parentFolderId"}, - checkError: assert.NoError, - expected: 3, - }, - { - name: "Invalid Contact Option param", - params: []string{"status"}, - checkError: assert.Error, - }, - } - for _, test := range tests { - suite.Run(test.name, func() { - t := suite.T() - - options, err := optionsForContacts(test.params) - test.checkError(t, err, clues.ToCore(err)) - if err == nil { - assert.Equal(t, test.expected, len(options.QueryParameters.Select)) - } - }) - } -} - //nolint:lll var stubHTMLContent = "
\r\n