示例#1
0
 def test_incorrect_signature_returns_forbidden(self):
     debug_orig = settings.DEBUG
     settings.DEBUG = False
     request = self.factory.post(self.str_uri, HTTP_X_TWILIO_SIGNATURE='fakesignature')
     self.assertEquals(str_view(request).status_code, 403)
     settings.DEBUG = True
     self.assertEquals(str_view(request).status_code, 200)
     settings.DEBUG = debug_orig
示例#2
0
 def test_incorrect_signature_returns_forbidden(self):
     debug_orig = settings.DEBUG
     settings.DEBUG = False
     request = self.factory.post(self.str_uri,
                                 HTTP_X_TWILIO_SIGNATURE='fakesignature')
     self.assertEquals(str_view(request).status_code, 403)
     settings.DEBUG = True
     self.assertEquals(str_view(request).status_code, 200)
     settings.DEBUG = debug_orig
示例#3
0
 def test_blacklist_works(self):
     debug_orig = settings.DEBUG
     settings.DEBUG = False
     request = self.factory.post(self.str_uri, {'From': '+13333333333'},
             HTTP_X_TWILIO_SIGNATURE=self.str_signature_with_from_field_blacklisted_caller)
     response = str_view(request)
     r = Response()
     r.reject()
     self.assertEquals(response.content, str(r))
     settings.DEBUG = True
     request = self.factory.post(self.str_uri, {'From': '+13333333333'},
             HTTP_X_TWILIO_SIGNATURE=self.str_signature_with_from_field_blacklisted_caller)
     response = str_view(request)
     r = Response()
     r.reject()
     self.assertEquals(response.content, str(r))
     settings.DEBUG = debug_orig
示例#4
0
 def test_blacklist_works(self):
     debug_orig = settings.DEBUG
     settings.DEBUG = False
     request = self.factory.post(self.str_uri, {'From': '+13333333333'},
                                 HTTP_X_TWILIO_SIGNATURE=self.
                                 sig_with_from_field_blacklisted_caller)
     response = str_view(request)
     r = Response()
     r.reject()
     self.assertEquals(response.content, str(r))
     settings.DEBUG = True
     request = self.factory.post(self.str_uri, {'From': '+13333333333'},
                                 HTTP_X_TWILIO_SIGNATURE=self.
                                 sig_with_from_field_blacklisted_caller)
     response = str_view(request)
     r = Response()
     r.reject()
     self.assertEquals(response.content, str(r))
     settings.DEBUG = debug_orig
示例#5
0
 def test_allows_post(self):
     request = self.factory.post(self.str_uri,
                                 HTTP_X_TWILIO_SIGNATURE=self.str_signature)
     self.assertEquals(str_view(request).status_code, 200)
示例#6
0
 def test_override_forgery_protection_on_debug_on(self):
     with override_settings(DJANGO_TWILIO_FORGERY_PROTECTION=True,
                            DEBUG=True):
         request = self.factory.post(self.str_uri)
         self.assertEquals(str_view(request).status_code, 403)
示例#7
0
 def test_decorator_modifies_str(self):
     request = self.factory.post(self.str_uri,
                                 HTTP_X_TWILIO_SIGNATURE=self.str_signature)
     self.assertTrue(isinstance(str_view(request), HttpResponse))
示例#8
0
 def test_from_field_no_caller(self):
     request = self.factory.post(
         self.str_uri, {'From': '+12222222222'},
         HTTP_X_TWILIO_SIGNATURE=self.sig_with_from_field_normal_caller)
     self.assertEquals(str_view(request).status_code, 200)
示例#9
0
 def test_allows_post(self):
     request = self.factory.post(self.str_uri, HTTP_X_TWILIO_SIGNATURE=self.str_signature)
     self.assertEquals(str_view(request).status_code, 200)
示例#10
0
 def test_decorator_modifies_str(self):
     request = self.factory.post(self.str_uri,
             HTTP_X_TWILIO_SIGNATURE=self.str_signature)
     self.assertTrue(isinstance(str_view(request), HttpResponse))
示例#11
0
 def test_from_field_no_caller(self):
     request = self.factory.post(self.str_uri, {'From': '+12222222222'},
             HTTP_X_TWILIO_SIGNATURE=self.str_signature_with_from_field_normal_caller)
     self.assertEquals(str_view(request).status_code, 200)
示例#12
0
 def test_override_forgery_protection_on_debug_on(self):
     with override_settings(DJANGO_TWILIO_FORGERY_PROTECTION=True, DEBUG=True):
         request = self.factory.post(self.str_uri)
         self.assertEquals(str_view(request).status_code, 403)