Correct some tests

This commit is contained in:
Valentin Samir 2015-11-20 17:38:03 +01:00
parent 7beefa537f
commit 6bdff5ac86
3 changed files with 8 additions and 5 deletions

View File

@ -281,7 +281,7 @@ class LoginView(View, LogoutMixin):
) )
if self.ajax: if self.ajax:
data = {"status": "error", "detail": "confirmation needed"} data = {"status": "error", "detail": "confirmation needed"}
return JsonResponse(request, data) return JsonResponse(self.request, data)
else: else:
return render( return render(
self.request, self.request,
@ -291,7 +291,7 @@ class LoginView(View, LogoutMixin):
service_pattern, service_pattern,
renew=self.renew renew=self.renew
)} )}
) )
else: else:
# redirect, using method ? # redirect, using method ?
list(messages.get_messages(self.request)) # clean messages before leaving django list(messages.get_messages(self.request)) # clean messages before leaving django

View File

@ -128,6 +128,9 @@ class DummySession(dict):
def set_expiry(self, int): def set_expiry(self, int):
pass pass
def flush(self):
self.clear()
class DummyQuerySet(set): class DummyQuerySet(set):
pass pass

View File

@ -18,7 +18,7 @@ def test_login_view_post_goodpass_goodlt():
request = factory.post('/login', {'username':'test', 'password':'test', 'lt':'LT-random'}) request = factory.post('/login', {'username':'test', 'password':'test', 'lt':'LT-random'})
request.session = DummySession() request.session = DummySession()
request.session['lt'] = 'LT-random' request.session['lt'] = ['LT-random']
request.session["username"] = os.urandom(20) request.session["username"] = os.urandom(20)
request.session["warn"] = 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 = factory.post('/login', {'username':'test', 'password':'test', 'lt':'LT-random1'})
request.session = DummySession() request.session = DummySession()
request.session['lt'] = 'LT-random2' request.session['lt'] = ['LT-random2']
authenticated = os.urandom(20) authenticated = os.urandom(20)
username = 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 = factory.post('/login', {'username':'test', 'password':'badpassword', 'lt':'LT-random'})
request.session = DummySession() request.session = DummySession()
request.session['lt'] = 'LT-random' request.session['lt'] = ['LT-random']
login = LoginView() login = LoginView()
login.init_post(request) login.init_post(request)