From 0dace623ab1c96b7af8fd64028c9e37d2b10f788 Mon Sep 17 00:00:00 2001 From: Stanislav Levin Date: Sat, 30 Jun 2018 00:21:51 +0300 Subject: [PATCH] Add support for JSON request in HTTP test class "urllib.parse.urlencode()" brokes JSON request's data. Fixes: https://pagure.io/freeipa/issue/7559 Reviewed-By: Alexander Bokovoy Reviewed-By: Christian Heimes Reviewed-By: Petr Vobornik --- ipatests/test_ipaserver/httptest.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ipatests/test_ipaserver/httptest.py b/ipatests/test_ipaserver/httptest.py index 13003bc85..861b9548b 100644 --- a/ipatests/test_ipaserver/httptest.py +++ b/ipatests/test_ipaserver/httptest.py @@ -41,9 +41,10 @@ class Unauthorized_HTTP_test(object): :param key When not None, overrides default app_uri """ if params is not None: - # urlencode *can* take two arguments - # pylint: disable=too-many-function-args - params = urllib.parse.urlencode(params, True) + if self.content_type == 'application/x-www-form-urlencoded': + # urlencode *can* take two arguments + # pylint: disable=too-many-function-args + params = urllib.parse.urlencode(params, True) url = 'https://' + self.host + self.app_uri headers = {'Content-Type' : self.content_type,