From 6bdff5ac86cbaaa760b797aa58ac44f2e8028674 Mon Sep 17 00:00:00 2001 From: Valentin Samir Date: Fri, 20 Nov 2015 17:38:03 +0100 Subject: [PATCH] Correct some tests --- cas_server/views.py | 4 ++-- tests/dummy.py | 3 +++ tests/test_views_login.py | 6 +++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/cas_server/views.py b/cas_server/views.py index 5316ebc..e3639ac 100644 --- a/cas_server/views.py +++ b/cas_server/views.py @@ -281,7 +281,7 @@ class LoginView(View, LogoutMixin): ) if self.ajax: data = {"status": "error", "detail": "confirmation needed"} - return JsonResponse(request, data) + return JsonResponse(self.request, data) else: return render( self.request, @@ -291,7 +291,7 @@ class LoginView(View, LogoutMixin): service_pattern, renew=self.renew )} - ) + ) else: # redirect, using method ? list(messages.get_messages(self.request)) # clean messages before leaving django diff --git a/tests/dummy.py b/tests/dummy.py index 3534140..8266d7b 100644 --- a/tests/dummy.py +++ b/tests/dummy.py @@ -128,6 +128,9 @@ class DummySession(dict): def set_expiry(self, int): pass + def flush(self): + self.clear() + class DummyQuerySet(set): pass diff --git a/tests/test_views_login.py b/tests/test_views_login.py index 3b7d580..6aabe80 100644 --- a/tests/test_views_login.py +++ b/tests/test_views_login.py @@ -18,7 +18,7 @@ def test_login_view_post_goodpass_goodlt(): request = factory.post('/login', {'username':'test', 'password':'test', 'lt':'LT-random'}) request.session = DummySession() - request.session['lt'] = 'LT-random' + request.session['lt'] = ['LT-random'] request.session["username"] = os.urandom(20) request.session["warn"] = os.urandom(20) @@ -38,7 +38,7 @@ def test_login_view_post_badlt(): request = factory.post('/login', {'username':'test', 'password':'test', 'lt':'LT-random1'}) request.session = DummySession() - request.session['lt'] = 'LT-random2' + request.session['lt'] = ['LT-random2'] authenticated = os.urandom(20) username = os.urandom(20) @@ -63,7 +63,7 @@ def test_login_view_post_badpass_good_lt(): request = factory.post('/login', {'username':'test', 'password':'badpassword', 'lt':'LT-random'}) request.session = DummySession() - request.session['lt'] = 'LT-random' + request.session['lt'] = ['LT-random'] login = LoginView() login.init_post(request)