Skip to content

Commit

Permalink
SharePoint Online Connector: Added credentials.close() call to _fetch…
Browse files Browse the repository at this point in the history
…_token() method (#3177)

(cherry picked from commit 56b6971)
  • Loading branch information
mattnowzari committed Feb 5, 2025
1 parent c93b5f0 commit ee30e05
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions connectors/sources/sharepoint_online.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,8 @@ async def _fetch_token(self):

token = await credentials.get_token(self._scope)

await credentials.close()

return token.token, datetime.utcfromtimestamp(token.expires_on)


Expand Down
3 changes: 3 additions & 0 deletions tests/sources/test_sharepoint_online.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,13 +534,16 @@ async def test_fetch_token(self, token, mock_responses):

certificate_credential_mock = AsyncMock()
certificate_credential_mock.get_token = AsyncMock(return_value=entra_token)
certificate_credential_mock.close = AsyncMock()

with patch(
"connectors.sources.sharepoint_online.CertificateCredential",
return_value=certificate_credential_mock,
):
actual_token, actual_expires_at = await token._fetch_token()

certificate_credential_mock.close.assert_called_once()

assert actual_token == bearer
assert actual_expires_at == datetime.utcfromtimestamp(expires_at)

Expand Down

0 comments on commit ee30e05

Please sign in to comment.