diff --git a/requirements.txt b/requirements.txt index e7d3b4c15fe1dde28117f6da318154788c360a61..fa5a7c14be038ab020a18cf2c7e4201737d76b11 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,4 +8,4 @@ python-docx==0.8.6 django-cleanup==0.4.2 django_cron==0.5.0 django-two-factor-auth==1.6.1 -nexmo==2.0.0-alpha1 \ No newline at end of file +nexmo \ No newline at end of file diff --git a/smash/web/tests/test_view_login.py b/smash/web/tests/test_view_login.py index 4e662d9de2085340c9998676081c7f4dcece35f2..f3fa9b05d3152c6fc7a6542e03bbaf4a8937c0d1 100644 --- a/smash/web/tests/test_view_login.py +++ b/smash/web/tests/test_view_login.py @@ -1,4 +1,5 @@ # coding=utf-8 +from django.conf import settings from django.contrib import auth as django_auth from django.test import Client from django.test import TestCase @@ -14,29 +15,31 @@ class TestLoginView(TestCase): user = create_user() password = 'top_secret' username = user.username - login_url = reverse('web.views.login') + login_url = reverse(settings.LOGIN_URL) self.assertFalse(django_auth.get_user(self.client).is_authenticated()) - response = self.client.post(login_url, data={'username': username, 'password': password}, follow=True) + form_data = {'auth-username': username, 'auth-password': password, 'login_view-current_step': 'auth'} + response = self.client.post(login_url, data=form_data, follow=True) self.assertEqual(200, response.status_code) self.assertTrue(django_auth.get_user(self.client).is_authenticated()) worker = Worker.get_by_user(user) self.assertIsNotNone(worker) worker.last_name = 'Grouès' worker.save() - response = self.client.post(login_url, data={'username': username, 'password': password}, follow=True) + response = self.client.post(login_url, data=form_data, follow=True) self.assertEqual(200, response.status_code) def test_login_failed(self): self.client = Client() user = create_user() username = user.username - login_url = reverse('web.views.login') - response = self.client.post(login_url, data={'username': username, 'password': 'wrong_password'}, follow=False) - self.assertEqual(302, response.status_code) - self.assertEqual('/login?error=login_failed', response.url) + login_url = reverse(settings.LOGIN_URL) + response = self.client.post(login_url, data={'auth-username': username, 'auth-password': 'wrong-password', + 'login_view-current_step': 'auth'}, follow=False) + self.assertContains(response, 'Please enter a correct') + self.assertContains(response, 'and password.') self.assertFalse(django_auth.get_user(self.client).is_authenticated()) def test_logout(self): self.test_login() - self.client.get(reverse('web.views.logout')) + self.client.get(reverse('logout')) self.assertFalse(django_auth.get_user(self.client).is_authenticated())