|
1 | 1 | # Note: Since Aug 2019 we move all e2e tests into test_e2e.py,
|
2 | 2 | # so this test_application file contains only unit tests without dependency.
|
| 3 | +import sys |
3 | 4 | from msal.application import *
|
4 | 5 | from msal.application import _str2bytes
|
5 | 6 | import msal
|
@@ -602,3 +603,25 @@ def test_get_accounts(self):
|
602 | 603 | self.assertIn("local_account_id", account, "Backward compatibility")
|
603 | 604 | self.assertIn("realm", account, "Backward compatibility")
|
604 | 605 |
|
| 606 | + |
| 607 | +@unittest.skipUnless( |
| 608 | + sys.version_info[0] >= 3 and sys.version_info[1] >= 2, |
| 609 | + "assertWarns() is only available in Python 3.2+") |
| 610 | +class TestClientCredentialGrant(unittest.TestCase): |
| 611 | + def _test_certain_authority_should_emit_warnning(self, authority): |
| 612 | + app = ConfidentialClientApplication( |
| 613 | + "client_id", client_credential="secret", authority=authority) |
| 614 | + def mock_post(url, headers=None, *args, **kwargs): |
| 615 | + return MinimalResponse( |
| 616 | + status_code=200, text=json.dumps({"access_token": "an AT"})) |
| 617 | + with self.assertWarns(DeprecationWarning): |
| 618 | + app.acquire_token_for_client(["scope"], post=mock_post) |
| 619 | + |
| 620 | + def test_common_authority_should_emit_warnning(self): |
| 621 | + self._test_certain_authority_should_emit_warnning( |
| 622 | + authority="https://login.microsoftonline.com/common") |
| 623 | + |
| 624 | + def test_organizations_authority_should_emit_warnning(self): |
| 625 | + self._test_certain_authority_should_emit_warnning( |
| 626 | + authority="https://login.microsoftonline.com/organizations") |
| 627 | + |
0 commit comments