Skip to content

Commit 3072793

Browse files
committed
chore: complete test coverage
1 parent 32dc9af commit 3072793

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/test_oauth2_validators.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,22 @@ def test_load_application_overwrites_client_on_client_id_mismatch(self):
247247
self.assertEqual(self.request.client, self.application)
248248
another_application.delete()
249249

250+
@mock.patch.object(Application, "is_usable")
251+
def test_load_application_returns_none_when_client_not_usable_cached(self, mock_is_usable):
252+
mock_is_usable.return_value = False
253+
self.request.client = self.application
254+
application = self.validator._load_application("client_id", self.request)
255+
self.assertIsNone(application)
256+
self.assertIsNone(self.request.client)
257+
258+
@mock.patch.object(Application, "is_usable")
259+
def test_load_application_returns_none_when_client_not_usable_db_lookup(self, mock_is_usable):
260+
mock_is_usable.return_value = False
261+
self.request.client = None
262+
application = self.validator._load_application("client_id", self.request)
263+
self.assertIsNone(application)
264+
self.assertIsNone(self.request.client)
265+
250266
def test_rotate_refresh_token__is_true(self):
251267
self.assertTrue(self.validator.rotate_refresh_token(mock.MagicMock()))
252268

0 commit comments

Comments
 (0)