From dbb434b56e6b161a3b851ae6a81f96dff14a29da Mon Sep 17 00:00:00 2001 From: NavaL Date: Thu, 25 Feb 2016 17:38:07 +0100 Subject: serving the client directly, as the current dependency on proxy strips out xsrf cookies -fixing functional test Issue #612 --- service/test/functional/features/environment.py | 6 ++---- service/test/support/integration/app_test_client.py | 3 +++ web-ui/app/js/page/default.js | 6 +++++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/service/test/functional/features/environment.py b/service/test/functional/features/environment.py index 37b5d612..2c07faf3 100644 --- a/service/test/functional/features/environment.py +++ b/service/test/functional/features/environment.py @@ -44,11 +44,9 @@ def before_all(context): PixelatedSite.disable_csp_requests() client = AppTestClient() start_app_test_client(client, UserAgentMode(is_single_user=True)) - client.listenTCP() - proxy = Proxy(proxy_port='8889', app_port='4567') + client.listenTCP(port=8889) FeaturesResource.DISABLED_FEATURES.append('autoRefresh') context.client = client - context.call_to_terminate_proxy = proxy.run_on_a_thread() multi_user_client = AppTestClient() start_app_test_client(multi_user_client, UserAgentMode(is_single_user=False)) @@ -57,7 +55,7 @@ def before_all(context): def after_all(context): - context.call_to_terminate_proxy() + context.client.stop() def before_feature(context, feature): diff --git a/service/test/support/integration/app_test_client.py b/service/test/support/integration/app_test_client.py index a2360a4e..f3ec5d25 100644 --- a/service/test/support/integration/app_test_client.py +++ b/service/test/support/integration/app_test_client.py @@ -244,6 +244,9 @@ class AppTestClient(object): time.sleep(1) return lambda: process.terminate() + def stop(self): + reactor.stop() + def get(self, path, get_args='', as_json=True, ajax=True, csrf='token'): request = request_mock(path, ajax=ajax, csrf=csrf) request.args = get_args diff --git a/web-ui/app/js/page/default.js b/web-ui/app/js/page/default.js index e33ec723..19b28354 100644 --- a/web-ui/app/js/page/default.js +++ b/web-ui/app/js/page/default.js @@ -51,6 +51,7 @@ define( 'mail_view/data/feedback_sender', 'page/version', 'page/unread_count_title', + 'helpers/browser' ], function ( @@ -88,7 +89,8 @@ define( feedbackBox, feedbackSender, version, - unreadCountTitle) { + unreadCountTitle, + browser) { 'use strict'; function initialize(path) { @@ -129,6 +131,8 @@ define( feedbackSender.attachTo(document); unreadCountTitle.attachTo(document); + + $.ajaxSetup({headers: {'X-XSRF-TOKEN': browser.getCookie('XSRF-TOKEN')}}); } return initialize; -- cgit v1.2.3