Merge pull request #16951 from edx/ahsan/LEARNER-3393-rate-limited-access-token-view

Rate limited /oauth2/access_token/
This commit is contained in:
Ahsan Ul Haq
2018-01-08 18:52:47 +05:00
committed by GitHub
5 changed files with 25 additions and 1 deletions

View File

@@ -1,4 +1,5 @@
# pylint: disable=missing-docstring
import mock
from django.core.cache import cache
from django.test.utils import override_settings
# Will also run default tests for IDTokens and UserInfo
@@ -134,6 +135,13 @@ class IDTokenTest(BaseTestMixin, IDTokenTestCase):
_scopes, claims = self.get_id_token_values('openid profile permissions')
self.assertTrue(claims['administrator'])
def test_rate_limit_token(self):
with mock.patch('openedx.core.djangoapps.oauth_dispatch.views.AccessTokenView.ratelimit_rate', '1/m'):
response = self.get_access_token_response('openid profile permissions')
self.assertEqual(response.status_code, 200)
response = self.get_access_token_response('openid profile permissions')
self.assertEqual(response.status_code, 403)
class UserInfoTest(BaseTestMixin, UserInfoTestCase):
def setUp(self):