Skip to content

Commit

Permalink
Fix to decorators to remove methods and blacklist
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Hallett committed Aug 4, 2014
1 parent d25c604 commit 6c35b6a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
9 changes: 4 additions & 5 deletions django_twilio/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ def my_view(request):
"""
@csrf_exempt
@wraps(f)
def decorator(request_or_self, methods=('POST',),
blacklist=True, *args, **kwargs):
def decorator(request_or_self, *args, **kwargs):

class_based_view = not isinstance(request_or_self, HttpRequest)
if not class_based_view:
Expand All @@ -84,7 +83,7 @@ def decorator(request_or_self, methods=('POST',),
)
if use_forgery_protection:

if request.method not in methods:
if request.method not in ['GET', 'POST']:
return HttpResponseNotAllowed(request.method)

# Forgery check
Expand All @@ -102,11 +101,11 @@ def decorator(request_or_self, methods=('POST',),
if not validator.validate(url, request.GET, signature):
return HttpResponseForbidden()

# Blacklist check
# Blacklist check, by default is true
check_blacklist = getattr(
settings,
'DJANGO_TWILIO_BLACKLIST_CHECK',
blacklist
True
)
if check_blacklist:
blacklisted_resp = get_blacklisted_response(request)
Expand Down
3 changes: 2 additions & 1 deletion test_project/test_app/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ def setUp(self):
def test_requires_post(self):
client = Client(enforce_csrf_checks=True)
with override_settings(DEBUG=False):
self.assertEquals(client.get(self.str_uri).status_code, 405)
self.assertEquals(client.get(self.str_uri).status_code, 403)
self.assertEquals(client.post(self.str_uri).status_code, 403)
self.assertEquals(client.head(self.str_uri).status_code, 405)
self.assertEquals(client.options(self.str_uri).status_code, 405)
self.assertEquals(client.put(self.str_uri).status_code, 405)
Expand Down

0 comments on commit 6c35b6a

Please sign in to comment.