From 20b1922794d3179b32dd930706ec5693a3562464 Mon Sep 17 00:00:00 2001 From: Roald de Vries Date: Thu, 1 Dec 2016 18:08:12 +0100 Subject: fix csrf in drafts tests --- service/test/support/integration/app_test_client.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'service/test/support') diff --git a/service/test/support/integration/app_test_client.py b/service/test/support/integration/app_test_client.py index 9ab74261..f04f67fd 100644 --- a/service/test/support/integration/app_test_client.py +++ b/service/test/support/integration/app_test_client.py @@ -286,8 +286,10 @@ class AppTestClient(object): request.session = session return self._render(request) - def put(self, path, body, ajax=True, csrf='token'): + def put(self, path, body, ajax=True, csrf='token', session=None): request = request_mock(path=path, method="PUT", body=body, headers={'Content-Type': ['application/json']}, ajax=ajax, csrf=csrf) + if session: + request.session = session return self._render(request) def delete(self, path, body="", ajax=True, csrf='token', session=None): @@ -375,8 +377,9 @@ class AppTestClient(object): res = yield deferred_result defer.returnValue((res, req)) - def put_mail(self, data): - res, req = self.put('/mails', data) + def put_mail(self, data, session): + csrf = IPixelatedSession(session).get_csrf_token() + res, req = self.put('/mails', data, csrf=csrf, session=session) return res, req def post_tags(self, mail_ident, tags_json): -- cgit v1.2.3