From 9a622b16aa0c7d7431703cc63cc4dfb64a40a7a6 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 21 Nov 2024 01:14:45 +0000 Subject: [PATCH] [8.x] [outlook] Filter users to only include active ones (#2967) (#2974) Co-authored-by: Sean Story Co-authored-by: Artem Shelkovnikov --- connectors/sources/outlook.py | 4 +++- tests/sources/test_outlook.py | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/connectors/sources/outlook.py b/connectors/sources/outlook.py index 47a495162..1f3573fb0 100644 --- a/connectors/sources/outlook.py +++ b/connectors/sources/outlook.py @@ -44,6 +44,7 @@ html_to_text, iso_utc, retryable, + url_encode, ) RETRIES = 3 @@ -410,7 +411,8 @@ async def _fetch_token(self): ) async def get_users(self): access_token = await self._fetch_token() - url = f"https://graph.microsoft.com/v1.0/users?$top={TOP}" + filter_ = url_encode("accountEnabled eq true") + url = f"https://graph.microsoft.com/v1.0/users?$top={TOP}&$filter={filter_}" while True: try: async with self._get_session.get( diff --git a/tests/sources/test_outlook.py b/tests/sources/test_outlook.py index 31cc507c2..213717112 100644 --- a/tests/sources/test_outlook.py +++ b/tests/sources/test_outlook.py @@ -420,7 +420,10 @@ def side_effect_function(url, headers): Args: url, ssl: Params required for get call """ - if url == "https://graph.microsoft.com/v1.0/users?$top=999": + if ( + url + == "https://graph.microsoft.com/v1.0/users?$top=999&$filter=accountEnabled%20eq%20true" + ): return get_json_mock( mock_response={ "@odata.nextLink": "https://graph.microsoft.com/v1.0/users?$top=999&$skipToken=fake-skip-token",