'Test that a POST HTTPS request with a bad referer is rejected'

@override_settings(ALLOWED_HOSTS=[u'www.example.com'])
def test_https_malformed_referer(self):

    req = self._get_POST_request_with_token()
    req._is_secure_override = True
    req.META[u'HTTP_HOST'] = u'www.example.com'
    req.META[u'HTTP_REFERER'] = u'http://http://www.example.com/'
    req2 = CsrfViewMiddleware().process_view(req, post_form_view, (), {})
    self.assertNotEqual(None, req2)
    self.assertEqual(403, req2.status_code)
