From 2bfd4b8da51310da0e11d87f64f57990d93d79e0 Mon Sep 17 00:00:00 2001 From: Tayane Fernandes Date: Thu, 9 Feb 2017 13:33:30 -0200 Subject: [#922] Rename backup account flow To differentiate between the account recovery flow and the set backup email flow, we renamed all resources and url to reflect this. with @anikarni --- .../resources/test_account_recovery_resource.py | 43 ---------------------- .../unit/resources/test_backup_account_resource.py | 43 ++++++++++++++++++++++ 2 files changed, 43 insertions(+), 43 deletions(-) delete mode 100644 service/test/unit/resources/test_account_recovery_resource.py create mode 100644 service/test/unit/resources/test_backup_account_resource.py (limited to 'service/test') diff --git a/service/test/unit/resources/test_account_recovery_resource.py b/service/test/unit/resources/test_account_recovery_resource.py deleted file mode 100644 index 01ffaed2..00000000 --- a/service/test/unit/resources/test_account_recovery_resource.py +++ /dev/null @@ -1,43 +0,0 @@ -# -# Copyright (c) 2017 ThoughtWorks, Inc. -# -# Pixelated is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Pixelated is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with Pixelated. If not, see . - -import os - -from mock import MagicMock, patch -from twisted.trial import unittest -from twisted.web.test.requesthelper import DummyRequest - -from pixelated.resources.account_recovery_resource import AccountRecoveryResource -from test.unit.resources import DummySite - - -class TestAccountRecoveryResource(unittest.TestCase): - def setUp(self): - self.services_factory = MagicMock() - self.resource = AccountRecoveryResource(self.services_factory) - self.web = DummySite(self.resource) - - def test_get(self): - request = DummyRequest(['/recovery']) - request.method = 'GET' - d = self.web.get(request) - - def assert_200_when_user_logged_in(_): - self.assertEqual(200, request.responseCode) - self.assertIn("DOCTYPE html", request.written[0]) - - d.addCallback(assert_200_when_user_logged_in) - return d diff --git a/service/test/unit/resources/test_backup_account_resource.py b/service/test/unit/resources/test_backup_account_resource.py new file mode 100644 index 00000000..21ae5aab --- /dev/null +++ b/service/test/unit/resources/test_backup_account_resource.py @@ -0,0 +1,43 @@ +# +# Copyright (c) 2017 ThoughtWorks, Inc. +# +# Pixelated is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Pixelated is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with Pixelated. If not, see . + +import os + +from mock import MagicMock, patch +from twisted.trial import unittest +from twisted.web.test.requesthelper import DummyRequest + +from pixelated.resources.backup_account_resource import BackupAccountResource +from test.unit.resources import DummySite + + +class TestBackupAccountResource(unittest.TestCase): + def setUp(self): + self.services_factory = MagicMock() + self.resource = BackupAccountResource(self.services_factory) + self.web = DummySite(self.resource) + + def test_get(self): + request = DummyRequest(['/backup-account']) + request.method = 'GET' + d = self.web.get(request) + + def assert_200_when_user_logged_in(_): + self.assertEqual(200, request.responseCode) + self.assertIn("DOCTYPE html", request.written[0]) + + d.addCallback(assert_200_when_user_logged_in) + return d -- cgit v1.2.3 From 29034222ca16c29e9301b769802a2e49446e9075 Mon Sep 17 00:00:00 2001 From: Tulio Casagrande Date: Fri, 10 Feb 2017 14:12:04 -0200 Subject: [#907] Add login status to session --- service/test/unit/resources/test_login_resource.py | 45 +++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) (limited to 'service/test') diff --git a/service/test/unit/resources/test_login_resource.py b/service/test/unit/resources/test_login_resource.py index cec57123..6dea7abb 100644 --- a/service/test/unit/resources/test_login_resource.py +++ b/service/test/unit/resources/test_login_resource.py @@ -259,7 +259,7 @@ class TestLoginPOST(unittest.TestCase): @patch('pixelated.config.leap.BootstrapUserServices.setup') @patch('pixelated.authentication.Authenticator.authenticate') - def test_successful_adds_cookies_to_indicat_logged_in_status_when_services_are_loaded(self, mock_authenticate, mock_user_bootstrap_setup): + def test_successful_adds_cookies_to_indicate_logged_in_status_when_services_are_loaded(self, mock_authenticate, mock_user_bootstrap_setup): mock_authenticate.return_value = self.user_auth irrelevant = None mock_user_bootstrap_setup.return_value = defer.succeed(irrelevant) @@ -271,3 +271,46 @@ class TestLoginPOST(unittest.TestCase): d.addCallback(assert_login_setup_service_for_user) return d + + @patch('pixelated.resources.session.PixelatedSession.login_started') + @patch('pixelated.authentication.Authenticator.authenticate') + def test_session_adds_login_started_status_after_authentication(self, mock_authenticate, mock_login_started): + mock_authenticate.return_value = self.user_auth + + d = self.web.get(self.request) + + def assert_login_started_called(_): + mock_login_started.assert_called_once() + + d.addCallback(assert_login_started_called) + return d + + @patch('pixelated.resources.session.PixelatedSession.login_completed') + @patch('pixelated.config.leap.BootstrapUserServices.setup') + @patch('pixelated.authentication.Authenticator.authenticate') + def test_session_adds_login_completed_status_when_services_setup_finishes(self, mock_authenticate, mock_user_bootstrap_setup, mock_login_completed): + mock_authenticate.return_value = self.user_auth + mock_user_bootstrap_setup.return_value = defer.succeed(None) + + d = self.web.get(self.request) + + def assert_login_completed_called(_): + mock_login_completed.assert_called_once() + + d.addCallback(assert_login_completed_called) + return d + + @patch('pixelated.resources.session.PixelatedSession.login_error') + @patch('pixelated.config.leap.BootstrapUserServices.setup') + @patch('pixelated.authentication.Authenticator.authenticate') + def test_session_adds_login_error_status_when_services_setup_gets_error(self, mock_authenticate, mock_user_bootstrap_setup, mock_login_error): + mock_authenticate.return_value = self.user_auth + mock_user_bootstrap_setup.return_value = defer.fail(Exception('Could not setup user services')) + + d = self.web.get(self.request) + + def assert_login_error_called(_): + mock_login_error.assert_called_once() + + d.addCallback(assert_login_error_called) + return d -- cgit v1.2.3 From 0edf2078caf98be00bcd48846acec563df630616 Mon Sep 17 00:00:00 2001 From: Tulio Casagrande Date: Mon, 13 Feb 2017 12:54:59 -0200 Subject: [#907] Rename successful login variables and methods --- service/test/unit/resources/test_login_resource.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'service/test') diff --git a/service/test/unit/resources/test_login_resource.py b/service/test/unit/resources/test_login_resource.py index 6dea7abb..834b9710 100644 --- a/service/test/unit/resources/test_login_resource.py +++ b/service/test/unit/resources/test_login_resource.py @@ -285,19 +285,19 @@ class TestLoginPOST(unittest.TestCase): d.addCallback(assert_login_started_called) return d - @patch('pixelated.resources.session.PixelatedSession.login_completed') + @patch('pixelated.resources.session.PixelatedSession.login_successful') @patch('pixelated.config.leap.BootstrapUserServices.setup') @patch('pixelated.authentication.Authenticator.authenticate') - def test_session_adds_login_completed_status_when_services_setup_finishes(self, mock_authenticate, mock_user_bootstrap_setup, mock_login_completed): + def test_session_adds_login_successful_status_when_services_setup_finishes(self, mock_authenticate, mock_user_bootstrap_setup, mock_login_successful): mock_authenticate.return_value = self.user_auth mock_user_bootstrap_setup.return_value = defer.succeed(None) d = self.web.get(self.request) - def assert_login_completed_called(_): - mock_login_completed.assert_called_once() + def assert_login_successful_called(_): + mock_login_successful.assert_called_once() - d.addCallback(assert_login_completed_called) + d.addCallback(assert_login_successful_called) return d @patch('pixelated.resources.session.PixelatedSession.login_error') -- cgit v1.2.3 From 9c6e2a7f40f3e96b203e1528ab974286e27a8d32 Mon Sep 17 00:00:00 2001 From: Anike Arni Date: Wed, 18 Jan 2017 14:14:15 -0200 Subject: Revert "Revert "[#888] Fix soledad class contract to be compatible with new merge. with @thaissiqueira."" This reverts commit 1e6e165a3fc397e45884eaec1122ba0cc5ff923e. --- service/test/support/integration/app_test_client.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'service/test') diff --git a/service/test/support/integration/app_test_client.py b/service/test/support/integration/app_test_client.py index d52c85c0..0ff1df31 100644 --- a/service/test/support/integration/app_test_client.py +++ b/service/test/support/integration/app_test_client.py @@ -437,9 +437,7 @@ def initialize_soledad(tempdir, uuid): secret_path, local_db_path, server_url, - cert_file, - defer_encryption=False, - syncable=False) + cert_file) yield SoledadMailAdaptor().initialize_store(_soledad) -- cgit v1.2.3 From 0b966e696c6a99f825510d406008fc9b9936077e Mon Sep 17 00:00:00 2001 From: Tulio Casagrande Date: Mon, 13 Feb 2017 18:43:15 -0200 Subject: [#907] Convert login page to react with @anikarni --- service/test/unit/resources/test_login_resource.py | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'service/test') diff --git a/service/test/unit/resources/test_login_resource.py b/service/test/unit/resources/test_login_resource.py index 834b9710..eeb7349a 100644 --- a/service/test/unit/resources/test_login_resource.py +++ b/service/test/unit/resources/test_login_resource.py @@ -87,23 +87,15 @@ class TestLoginResource(unittest.TestCase): d = self.web.get(request) - def assert_form_rendered(_): + def assert_login_page_rendered(_): self.assertEqual(200, request.responseCode) - form_action = 'action="/login"' - form_method = 'method="post"' - input_username = 'name="username"' - input_password = 'name="password"' - input_submit = 'name="login"' + title = 'Pixelated - Login' default_disclaimer = 'Some disclaimer' written_response = ''.join(request.written) - self.assertIn(form_action, written_response) - self.assertIn(form_method, written_response) - self.assertIn(input_password, written_response) - self.assertIn(input_submit, written_response) - self.assertIn(input_username, written_response) + self.assertIn(title, written_response) self.assertIn(default_disclaimer, written_response) - d.addCallback(assert_form_rendered) + d.addCallback(assert_login_page_rendered) return d def _write(self, filename, content): @@ -238,7 +230,7 @@ class TestLoginPOST(unittest.TestCase): def assert_interstitial_in_response(_): mock_authenticate.assert_called_once_with(self.username, self.password) - interstitial_js_in_template = '' + interstitial_js_in_template = '' self.assertIn(interstitial_js_in_template, self.request.written[0]) d.addCallback(assert_interstitial_in_response) -- cgit v1.2.3 From 64780114ae90bb890d3ffa0a9aebe4686c6b74d3 Mon Sep 17 00:00:00 2001 From: Tulio Casagrande Date: Thu, 16 Feb 2017 13:42:50 -0200 Subject: [#907] Adapt login status to work with single user with @anikarni --- service/test/unit/resources/test_login_resource.py | 35 +++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'service/test') diff --git a/service/test/unit/resources/test_login_resource.py b/service/test/unit/resources/test_login_resource.py index eeb7349a..29592c1d 100644 --- a/service/test/unit/resources/test_login_resource.py +++ b/service/test/unit/resources/test_login_resource.py @@ -23,7 +23,7 @@ from twisted.internet import defer from twisted.trial import unittest from twisted.web.test.requesthelper import DummyRequest -from pixelated.resources.login_resource import LoginResource +from pixelated.resources.login_resource import LoginResource, LoginStatusResource from pixelated.resources.login_resource import parse_accept_language from test.unit.resources import DummySite @@ -306,3 +306,36 @@ class TestLoginPOST(unittest.TestCase): d.addCallback(assert_login_error_called) return d + + +class TestLoginStatus(unittest.TestCase): + def setUp(self): + self.services_factory = mock() + self.resource = LoginStatusResource(self.services_factory) + self.web = DummySite(self.resource) + + self.request = DummyRequest(['/status']) + + def test_login_status_completed_when_single_user(self): + self.services_factory.mode = mock() + self.services_factory.mode.is_single_user = True + d = self.web.get(self.request) + + def assert_login_completed(_): + self.assertIn('completed', self.request.written[0]) + + d.addCallback(assert_login_completed) + return d + + @patch('pixelated.resources.session.PixelatedSession.check_login_status') + def test_login_status_when_multi_user_returns_check_login_status(self, mock_login_status): + self.services_factory.mode = mock() + self.services_factory.mode.is_single_user = False + mock_login_status.return_value = 'started' + d = self.web.get(self.request) + + def assert_login_completed(_): + self.assertIn('started', self.request.written[0]) + + d.addCallback(assert_login_completed) + return d -- cgit v1.2.3 From 957599ae01687d6b3d02a3c34fdbe2ac6bd920f9 Mon Sep 17 00:00:00 2001 From: Anike Arni Date: Thu, 16 Feb 2017 18:51:26 -0200 Subject: [#907] Bundles login static files separately Due to conflicts with public and protected urls, login and interstitial files have to be on a different public url from inbox and resources that require login. Therefore, here, we delegate that logic to webpack. Now we have a '/public' url and a '/assets' url for those static assets. --- service/test/unit/resources/test_helpers.py | 7 +++++++ service/test/unit/resources/test_login_resource.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'service/test') diff --git a/service/test/unit/resources/test_helpers.py b/service/test/unit/resources/test_helpers.py index e21c5373..6c456f51 100644 --- a/service/test/unit/resources/test_helpers.py +++ b/service/test/unit/resources/test_helpers.py @@ -18,6 +18,7 @@ from twisted.trial import unittest import re from pixelated.resources import respond_json, respond_json_deferred +from pixelated.resources import get_public_static_folder, get_protected_static_folder from test.unit.resources import DummySite from twisted.web.test.requesthelper import DummyRequest @@ -44,3 +45,9 @@ class TestHelpers(unittest.TestCase): self.assertEqual(b"{\"test\": \"yep\"}", request.written[0]) self.assertEqual([b"application/json"], request.responseHeaders.getRawHeaders("Content-Type")) + + def test_getting_public_folder_returns_path(self): + self.assertIn('web-ui/dist/public', get_public_static_folder()) + + def test_getting_protected_folder_returns_path(self): + self.assertIn('web-ui/dist/protected', get_protected_static_folder()) diff --git a/service/test/unit/resources/test_login_resource.py b/service/test/unit/resources/test_login_resource.py index 29592c1d..bd0f9122 100644 --- a/service/test/unit/resources/test_login_resource.py +++ b/service/test/unit/resources/test_login_resource.py @@ -230,7 +230,7 @@ class TestLoginPOST(unittest.TestCase): def assert_interstitial_in_response(_): mock_authenticate.assert_called_once_with(self.username, self.password) - interstitial_js_in_template = '' + interstitial_js_in_template = '' self.assertIn(interstitial_js_in_template, self.request.written[0]) d.addCallback(assert_interstitial_in_response) -- cgit v1.2.3 From 2b291aacde05151a0d2a0dccdbbd085f93f255a0 Mon Sep 17 00:00:00 2001 From: Tulio Casagrande Date: Fri, 17 Feb 2017 13:26:47 -0200 Subject: [#907] Fix selectors to work with chromedriver --- service/test/functional/features/steps/attachments.py | 10 ++++++++-- service/test/functional/features/steps/tag_list.py | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'service/test') diff --git a/service/test/functional/features/steps/attachments.py b/service/test/functional/features/steps/attachments.py index 8852b787..37fabb6a 100644 --- a/service/test/functional/features/steps/attachments.py +++ b/service/test/functional/features/steps/attachments.py @@ -13,6 +13,8 @@ # # You should have received a copy of the GNU Affero General Public License # along with Pixelated. If not, see . +import os + from email.MIMEMultipart import MIMEMultipart from email.mime.application import MIMEApplication from email.mime.text import MIMEText @@ -67,8 +69,10 @@ def find_icon(context): def upload_big_file(context): base_dir = "test/functional/features/files/" fname = "over_5mb.data" + path = os.path.abspath(os.path.join(base_dir, fname)) + context.browser.execute_script("$('#fileupload').removeAttr('hidden');") - fill_by_css_selector(context, '#fileupload', base_dir + fname) + fill_by_css_selector(context, '#fileupload', path) find_element_by_css_selector(context, '#upload-error-message') @@ -97,7 +101,9 @@ def should_not_show_upload_error_message(context): def upload_attachment(context): base_dir = "test/functional/features/files/" fname = "5mb.data" - fill_by_css_selector(context, '#fileupload', base_dir + fname) + path = os.path.abspath(os.path.join(base_dir, fname)) + + fill_by_css_selector(context, '#fileupload', path) attachment_list_item = find_element_by_css_selector(context, '#attachment-list-item li a') assert attachment_list_item.text == "%s (5.00 Mb)" % fname diff --git a/service/test/functional/features/steps/tag_list.py b/service/test/functional/features/steps/tag_list.py index daea416d..fcdf1e15 100644 --- a/service/test/functional/features/steps/tag_list.py +++ b/service/test/functional/features/steps/tag_list.py @@ -37,7 +37,7 @@ def expand_side_nav(context): if is_side_nav_expanded(context): return - toggle = find_element_by_class_name(context, 'side-nav-toggle') + toggle = find_element_by_css_selector(context, '.side-nav-toggle-icon i') toggle.click() -- cgit v1.2.3 From 85aa0455d5accb392cf6bc3b5fc44bc8b8da4350 Mon Sep 17 00:00:00 2001 From: Tulio Casagrande Date: Fri, 17 Feb 2017 14:30:28 -0200 Subject: [#907] Add retry when tag reference was lost --- service/test/functional/features/steps/tag_list.py | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'service/test') diff --git a/service/test/functional/features/steps/tag_list.py b/service/test/functional/features/steps/tag_list.py index fcdf1e15..2208a542 100644 --- a/service/test/functional/features/steps/tag_list.py +++ b/service/test/functional/features/steps/tag_list.py @@ -14,11 +14,10 @@ # You should have received a copy of the GNU Affero General Public License # along with Pixelated. If not, see . from behave import when -from selenium.common.exceptions import TimeoutException +from selenium.common.exceptions import TimeoutException, StaleElementReferenceException from common import ( find_element_by_class_name, - find_element_by_id, find_element_by_css_selector, wait_for_user_alert_to_disapear) @@ -37,12 +36,11 @@ def expand_side_nav(context): if is_side_nav_expanded(context): return - toggle = find_element_by_css_selector(context, '.side-nav-toggle-icon i') - toggle.click() + find_element_by_css_selector(context, '.side-nav-toggle-icon i').click() @when('I select the tag \'{tag}\'') -def impl(context, tag): +def select_tag(context, tag): wait_for_user_alert_to_disapear(context) expand_side_nav(context) @@ -51,14 +49,10 @@ def impl(context, tag): success = False while (not success) and (try_again > 0): try: - find_element_by_css_selector(context, '#tag-%s' % tag) - - e = find_element_by_id(context, 'tag-%s' % tag) - e.click() - + find_element_by_css_selector(context, '#tag-%s' % tag).click() find_element_by_css_selector(context, ".mail-list-entry__item[href*='%s']" % tag) success = True - except TimeoutException: + except (TimeoutException, StaleElementReferenceException): pass finally: try_again -= 1 @@ -67,9 +61,8 @@ def impl(context, tag): @when('I am in \'{tag}\'') -def impl(context, tag): +def assert_in_tag(context, tag): expand_side_nav(context) - find_element_by_css_selector(context, '#tag-%s' % tag) - e = find_element_by_id(context, 'tag-%s' % tag) + e = find_element_by_css_selector(context, '#tag-%s' % tag) assert "selected" in e.get_attribute("class") -- cgit v1.2.3 From 200ba568e4c975cc5276676b2406170aa85dcad1 Mon Sep 17 00:00:00 2001 From: Tulio Casagrande Date: Fri, 17 Feb 2017 15:47:01 -0200 Subject: [#907] Change default webdriver to chrome with @anikarni --- service/test/functional/features/environment.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'service/test') diff --git a/service/test/functional/features/environment.py b/service/test/functional/features/environment.py index d49016b6..821a762b 100644 --- a/service/test/functional/features/environment.py +++ b/service/test/functional/features/environment.py @@ -63,7 +63,7 @@ def before_all(context): def _setup_webdriver(context): - browser = context.config.userdata.get('webdriver', 'phantomjs') + browser = context.config.userdata.get('webdriver', 'chrome') supported_webdrivers = { 'phantomjs': webdriver.PhantomJS, 'firefox': webdriver.Firefox, -- cgit v1.2.3 From e560075b89668e4d8c12a89424ff5d7fab638475 Mon Sep 17 00:00:00 2001 From: Tulio Casagrande Date: Fri, 17 Feb 2017 16:34:29 -0200 Subject: [#907] Change functional tests to check for visibility --- service/test/functional/features/steps/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'service/test') diff --git a/service/test/functional/features/steps/common.py b/service/test/functional/features/steps/common.py index edfe2a50..3e1e995e 100644 --- a/service/test/functional/features/steps/common.py +++ b/service/test/functional/features/steps/common.py @@ -61,7 +61,7 @@ def _wait_until_elements_are_visible_by_locator(context, locator_tuple, timeout= def _wait_until_element_is_visible_by_locator(context, locator_tuple, timeout=TIMEOUT_IN_S): wait = WebDriverWait(context.browser, timeout) - wait.until(EC.presence_of_element_located(locator_tuple)) + wait.until(EC.visibility_of_element_located(locator_tuple)) return context.browser.find_element(locator_tuple[0], locator_tuple[1]) -- cgit v1.2.3 From 97cd3a2470e1de74a14fd4c1dad332a5a311e8eb Mon Sep 17 00:00:00 2001 From: Tulio Casagrande Date: Fri, 17 Feb 2017 16:49:54 -0200 Subject: [#907] Fix functional tests on snap --- service/test/functional/features/steps/tag_list.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'service/test') diff --git a/service/test/functional/features/steps/tag_list.py b/service/test/functional/features/steps/tag_list.py index 2208a542..688636b2 100644 --- a/service/test/functional/features/steps/tag_list.py +++ b/service/test/functional/features/steps/tag_list.py @@ -49,7 +49,11 @@ def select_tag(context, tag): success = False while (not success) and (try_again > 0): try: - find_element_by_css_selector(context, '#tag-%s' % tag).click() + find_element_by_css_selector(context, '#tag-%s' % tag) + + e = find_element_by_css_selector(context, '#tag-%s' % tag) + e.click() + find_element_by_css_selector(context, ".mail-list-entry__item[href*='%s']" % tag) success = True except (TimeoutException, StaleElementReferenceException): @@ -58,11 +62,3 @@ def select_tag(context, tag): try_again -= 1 assert success - - -@when('I am in \'{tag}\'') -def assert_in_tag(context, tag): - expand_side_nav(context) - - e = find_element_by_css_selector(context, '#tag-%s' % tag) - assert "selected" in e.get_attribute("class") -- cgit v1.2.3 From 8177127b6b7282f816cb64595249ef1cb42ec0d8 Mon Sep 17 00:00:00 2001 From: Tulio Casagrande Date: Fri, 17 Feb 2017 17:17:27 -0200 Subject: [#907] Click tag child on functional tests with @anikarni --- service/test/functional/features/steps/tag_list.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'service/test') diff --git a/service/test/functional/features/steps/tag_list.py b/service/test/functional/features/steps/tag_list.py index 688636b2..e3382a61 100644 --- a/service/test/functional/features/steps/tag_list.py +++ b/service/test/functional/features/steps/tag_list.py @@ -51,7 +51,7 @@ def select_tag(context, tag): try: find_element_by_css_selector(context, '#tag-%s' % tag) - e = find_element_by_css_selector(context, '#tag-%s' % tag) + e = find_element_by_css_selector(context, '#tag-%s .tag-label' % tag) e.click() find_element_by_css_selector(context, ".mail-list-entry__item[href*='%s']" % tag) -- cgit v1.2.3 From bfd85dff6b086abae1c16014e318c89cba929b66 Mon Sep 17 00:00:00 2001 From: Anike Arni Date: Fri, 17 Feb 2017 09:57:19 -0200 Subject: [#907] Makes login page responsive --- service/test/functional/features/steps/login.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'service/test') 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') -- cgit v1.2.3 From fa21608801f8d2ef710d4c28abbb558883afeaf7 Mon Sep 17 00:00:00 2001 From: Tulio Casagrande Date: Mon, 20 Feb 2017 14:37:37 -0300 Subject: [#907] Translate auth error message on login with @anikarni --- service/test/integration/test_multi_user_login.py | 9 ++++----- service/test/unit/resources/test_login_resource.py | 15 ++++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'service/test') diff --git a/service/test/integration/test_multi_user_login.py b/service/test/integration/test_multi_user_login.py index fe456583..b04a4e9e 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 . -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.uri) 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') -- cgit v1.2.3 From 77916147760ffc6cea8242955a551ce75d8b29e4 Mon Sep 17 00:00:00 2001 From: Tulio Casagrande Date: Mon, 20 Feb 2017 16:15:29 -0300 Subject: [#907] Change auth-error url with @anikarni --- service/test/integration/test_multi_user_login.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'service/test') diff --git a/service/test/integration/test_multi_user_login.py b/service/test/integration/test_multi_user_login.py index b04a4e9e..04cceec3 100644 --- a/service/test/integration/test_multi_user_login.py +++ b/service/test/integration/test_multi_user_login.py @@ -50,4 +50,4 @@ class MultiUserLoginTest(MultiUserSoledadTestBase): response, login_request = self.app_test_client.login('username', 'wrong_password') yield response self.assertEqual(302, login_request.responseCode) - self.assertIn('/login?auth-error', login_request.uri) + self.assertIn('/login?auth-error', login_request.responseHeaders.getRawHeaders('location')) -- cgit v1.2.3 From b67abc5e64206672840320a5e2c89fda5d484c78 Mon Sep 17 00:00:00 2001 From: Tulio Casagrande Date: Wed, 1 Mar 2017 15:06:43 -0300 Subject: Fix soledad shared_db argument when testing --- service/test/support/integration/app_test_client.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'service/test') diff --git a/service/test/support/integration/app_test_client.py b/service/test/support/integration/app_test_client.py index 0ff1df31..538cf633 100644 --- a/service/test/support/integration/app_test_client.py +++ b/service/test/support/integration/app_test_client.py @@ -429,15 +429,15 @@ def initialize_soledad(tempdir, uuid): def __call__(self): return self - Soledad._shared_db = MockSharedDB() - _soledad = Soledad( uuid, passphrase, secret_path, local_db_path, server_url, - cert_file) + cert_file, + shared_db=MockSharedDB() + ) yield SoledadMailAdaptor().initialize_store(_soledad) -- cgit v1.2.3 From 1e62467a7adfafe91025cf6c8955d54770e705aa Mon Sep 17 00:00:00 2001 From: Sriram Viswanathan Date: Fri, 10 Mar 2017 11:25:40 -0300 Subject: |#000|Sriram| Fix functional test - get element by id rather than css selector for cc-bcc collapse --- service/test/functional/features/steps/compose.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'service/test') diff --git a/service/test/functional/features/steps/compose.py b/service/test/functional/features/steps/compose.py index 1dab1b6d..1b90052e 100644 --- a/service/test/functional/features/steps/compose.py +++ b/service/test/functional/features/steps/compose.py @@ -19,7 +19,9 @@ from behave import when from common import ( fill_by_css_selector, - find_element_by_css_selector) + find_element_by_css_selector, + find_element_by_id +) @when('I compose a message with') @@ -52,7 +54,7 @@ def send_impl(context): @when(u'I toggle the cc and bcc fields') def collapse_cc_bcc_fields(context): - cc_and_bcc_chevron = find_element_by_css_selector(context, '#cc-bcc-collapse') + cc_and_bcc_chevron = find_element_by_id(context, 'cc-bcc-collapse') cc_and_bcc_chevron.click() -- cgit v1.2.3 From 908806ee4d2e94c691f8fb7f4ada6d45e7e9a282 Mon Sep 17 00:00:00 2001 From: Sriram Viswanathan Date: Fri, 10 Mar 2017 16:49:21 -0300 Subject: [#923] Fix functional test on login page --- service/test/functional/features/steps/login.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'service/test') diff --git a/service/test/functional/features/steps/login.py b/service/test/functional/features/steps/login.py index fb8f08ef..9ce37370 100644 --- a/service/test/functional/features/steps/login.py +++ b/service/test/functional/features/steps/login.py @@ -35,7 +35,7 @@ def enter_credentials(context, username, password): @when(u'I click on the login button') def click_login(context): - find_element_by_css_selector(context, 'input[type="submit"]').click() + find_element_by_css_selector(context, 'button[type="submit"]').click() @then(u'I should see the fancy interstitial') -- cgit v1.2.3