Commit 9d71c524 by Peter Fogg

Merge pull request #73 from edx/peter-fogg/anonymous-rate-limiting

Allow rate-limiting for anonymous users.
parents fecf558a 0d19c5a7
......@@ -15,7 +15,7 @@ class RateLimitingTest(APITestCase):
def setUp(self):
super(RateLimitingTest, self).setUp()
self.url = reverse('api:v1:catalog-list')
self.url = reverse('django.swagger.resources.view')
self.user = UserFactory()
self.client.login(username=self.user.username, password=USER_PASSWORD)
......@@ -48,3 +48,7 @@ class RateLimitingTest(APITestCase):
self.user.save()
response = self._make_requests()
self.assertEqual(response.status_code, 200)
def test_anonymous_throttling(self):
self.client.logout()
self.test_rate_limiting()
......@@ -11,6 +11,7 @@ class OverridableUserRateThrottle(UserRateThrottle):
user = request.user
if user.is_superuser:
return True
if not user.is_anonymous():
try:
# Override this throttle's rate if applicable
user_throttle = UserThrottleRate.objects.get(user=user)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment