2010-08-09 18:04:01 +04:00
|
|
|
from nose.tools import eq_
|
2010-08-10 19:44:45 +04:00
|
|
|
import test_utils
|
2010-08-09 18:04:01 +04:00
|
|
|
|
|
|
|
from django.conf import settings
|
|
|
|
from django.contrib.auth.models import User
|
|
|
|
from django.core.urlresolvers import reverse
|
|
|
|
|
|
|
|
|
|
|
|
class MiddlewareTestCase(test_utils.TestCase):
|
|
|
|
"""Test our custom middleware(s)."""
|
|
|
|
|
|
|
|
def test_httponly(self):
|
|
|
|
uid = 'john'
|
|
|
|
pw = 'johnpw'
|
|
|
|
User.objects.create_user(uid,'lennon@thebeatles.com', pw)
|
|
|
|
r = self.client.post(reverse('cas_login'), {
|
|
|
|
'username': uid, 'password': pw})
|
|
|
|
|
|
|
|
# No errors
|
|
|
|
eq_(r.status_code, 200)
|
|
|
|
|
|
|
|
# We have cookies and all are httponly unless specified otherwise.
|
|
|
|
self.assertTrue(len(r.cookies) > 0)
|
|
|
|
for name in r.cookies:
|
|
|
|
if name not in settings.JAVASCRIPT_READABLE_COOKIES:
|
|
|
|
eq_(bool(r.cookies[name].get('httponly')), True)
|