Example #1
0
 def test_response_middleware_contenttype_exclusion(self):
     """ ensure POST forms are not rewritten for non-html content types """
     request = _get_POST_request()
     request.POST[settings.HONEYPOT_FIELD_NAME] = ''
     response = HttpResponse(self._response_body, content_type='text/javascript')
     HoneypotResponseMiddleware().process_response(request, response)
     self.assertContains(response, self._response_body)
Example #2
0
 def test_response_middleware_unicode(self):
     """ ensure that POST form rewriting works with unicode templates """
     request = _get_GET_request()
     unicode_body = u'\u2603' + self._response_body    # add unicode snowman
     response = HttpResponse(unicode_body)
     HoneypotResponseMiddleware().process_response(request, response)
     self.assertNotContains(response, unicode_body)
     self.assertContains(response, 'name="%s"' % settings.HONEYPOT_FIELD_NAME)
Example #3
0
 def test_response_middleware_rewrite(self):
     """ ensure POST forms are rewritten """
     request = _get_POST_request()
     request.POST[settings.HONEYPOT_FIELD_NAME] = ''
     response = HttpResponse(self._response_body)
     HoneypotResponseMiddleware().process_response(request, response)
     self.assertNotContains(response, self._response_body)
     self.assertContains(response, 'name="%s"' % settings.HONEYPOT_FIELD_NAME)