summaryrefslogtreecommitdiff
path: root/service/test
diff options
context:
space:
mode:
Diffstat (limited to 'service/test')
-rw-r--r--service/test/functional/features/steps/login.py6
-rw-r--r--service/test/integration/test_multi_user_login.py9
-rw-r--r--service/test/unit/resources/test_login_resource.py15
3 files changed, 15 insertions, 15 deletions
diff --git a/service/test/functional/features/steps/login.py b/service/test/functional/features/steps/login.py
index 6ee521e9..fb8f08ef 100644
--- a/service/test/functional/features/steps/login.py
+++ b/service/test/functional/features/steps/login.py
@@ -29,13 +29,13 @@ def login_page(context):
@when(u'I enter {username} and {password} as credentials')
def enter_credentials(context, username, password):
- fill_by_css_selector(context, 'input#email', context.username)
- fill_by_css_selector(context, 'input#password', password)
+ fill_by_css_selector(context, 'input[name="username"]', context.username)
+ fill_by_css_selector(context, 'input[name="password"]', password)
@when(u'I click on the login button')
def click_login(context):
- find_element_by_css_selector(context, 'input[name="login"]').click()
+ find_element_by_css_selector(context, 'input[type="submit"]').click()
@then(u'I should see the fancy interstitial')
diff --git a/service/test/integration/test_multi_user_login.py b/service/test/integration/test_multi_user_login.py
index fe456583..04cceec3 100644
--- a/service/test/integration/test_multi_user_login.py
+++ b/service/test/integration/test_multi_user_login.py
@@ -13,7 +13,6 @@
#
# You should have received a copy of the GNU Affero General Public License
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
-from mock import patch
from twisted.internet import defer
@@ -47,8 +46,8 @@ class MultiUserLoginTest(MultiUserSoledadTestBase):
self.assertEquals(val, response[key])
@defer.inlineCallbacks
- def test_wrong_credentials_cannot_access_resources(self):
+ def test_wrong_credentials_is_redirected_to_login(self):
response, login_request = self.app_test_client.login('username', 'wrong_password')
- response_str = yield response
- self.assertEqual(401, login_request.responseCode)
- self.assertIn('Invalid username or password', login_request.written)
+ yield response
+ self.assertEqual(302, login_request.responseCode)
+ self.assertIn('/login?auth-error', login_request.responseHeaders.getRawHeaders('location'))
diff --git a/service/test/unit/resources/test_login_resource.py b/service/test/unit/resources/test_login_resource.py
index bd0f9122..733583a3 100644
--- a/service/test/unit/resources/test_login_resource.py
+++ b/service/test/unit/resources/test_login_resource.py
@@ -203,22 +203,23 @@ class TestLoginPOST(unittest.TestCase):
return d
@patch('pixelated.config.leap.BootstrapUserServices.setup')
+ @patch('twisted.web.util.redirectTo')
@patch('pixelated.authentication.Authenticator.authenticate')
- def test_should_return_form_back_with_error_message_when_login_fails(self, mock_authenticate,
- mock_user_bootstrap_setup):
+ def test_should_redirect_to_login_with_error_flag_when_login_fails(self, mock_authenticate,
+ mock_redirect,
+ mock_user_bootstrap_setup):
mock_authenticate.side_effect = UnauthorizedLogin()
+ mock_redirect.return_value = "mocked redirection"
d = self.web.get(self.request)
- def assert_error_response_and_user_services_not_setup(_):
+ def assert_redirected_to_login(_):
mock_authenticate.assert_called_once_with(self.username, self.password)
- self.assertEqual(401, self.request.responseCode)
- written_response = ''.join(self.request.written)
- self.assertIn('Invalid username or password', written_response)
+ mock_redirect.assert_called_once_with('/login?auth-error', self.request)
self.assertFalse(mock_user_bootstrap_setup.called)
self.assertFalse(self.resource.get_session(self.request).is_logged_in())
- d.addCallback(assert_error_response_and_user_services_not_setup)
+ d.addCallback(assert_redirected_to_login)
return d
@patch('pixelated.config.leap.BootstrapUserServices.setup')