              resp2 = CsrfViewMiddleware().process_response(req, resp)
          csrf_cookie = resp2.cookies.get('myname', False)
          self.assertNotEqual(csrf_cookie, False)
          self.assertTrue('Cookie' in resp2.get('Vary',''))
  
      def test_process_response_get_token_not_used(self):
          """
          Check that if get_token() is not called, the view middleware does not
          add a cookie.
 
</s> remove         csrf_cookie = resp2.cookies.get(settings.CSRF_COOKIE_NAME, False)
 </s> add         # Put tests for CSRF_COOKIE_* settings here
        with self.settings(CSRF_COOKIE_NAME='myname',
                           CSRF_COOKIE_DOMAIN='.example.com',
                           CSRF_COOKIE_PATH='/test/',
                           CSRF_COOKIE_SECURE=True):
            # token_view calls get_token() indirectly
            CsrfViewMiddleware().process_view(req, token_view, (), {})
            resp = token_view(req)
            resp2 = CsrfViewMiddleware().process_response(req, resp)
        csrf_cookie = resp2.cookies.get('myname', False) </s> remove # Name and domain for CSRF cookie.
 </s> add # Settings for CSRF cookie. </s> remove         # token_view calls get_token() indirectly
        CsrfViewMiddleware().process_view(req, token_view, (), {})
        resp = token_view(req)
        resp2 = CsrfViewMiddleware().process_response(req, resp)
 </s> add  </s> remove                 request.META["CSRF_COOKIE"], max_age = 60 * 60 * 24 * 7 * 52,
                domain=settings.CSRF_COOKIE_DOMAIN)
 </s> add                             request.META["CSRF_COOKIE"],
                            max_age = 60 * 60 * 24 * 7 * 52,
                            domain=settings.CSRF_COOKIE_DOMAIN,
                            path=settings.CSRF_COOKIE_PATH,
                            secure=settings.CSRF_COOKIE_SECURE
                            )
        self.assertEqual(csrf_cookie['domain'], '.example.com')
        self.assertEqual(csrf_cookie['secure'], True)
        self.assertEqual(csrf_cookie['path'], '/test/')
              resp2 = CsrfViewMiddleware().process_response(req, resp)
          csrf_cookie = resp2.cookies.get('myname', False)
          self.assertNotEqual(csrf_cookie, False)
        self.assertEqual(csrf_cookie['domain'], '.example.com')
        self.assertEqual(csrf_cookie['secure'], True)
        self.assertEqual(csrf_cookie['path'], '/test/')
          self.assertTrue('Cookie' in resp2.get('Vary',''))
  
      def test_process_response_get_token_not_used(self):
          """
          Check that if get_token() is not called, the view middleware does not
          add a cookie.
keep keep add keep keep keep keep keep keep
 Fixed #14134 - ability to set cookie 'path' and 'secure' attributes of CSRF cookie

Thanks to cfattarsi for the report and initial patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16200 bcc190cf-cafb-0310-a4f2-bffc1f526a37 
tests/regressiontests/csrf_tests/tests.py