Merge "Fix issues with keystone-dsvm-py35-functional-v3-only on py35"
diff --git a/keystone_tempest_plugin/services/identity/clients.py b/keystone_tempest_plugin/services/identity/clients.py
index caf8b52..aac45d3 100644
--- a/keystone_tempest_plugin/services/identity/clients.py
+++ b/keystone_tempest_plugin/services/identity/clients.py
@@ -14,6 +14,7 @@
 
 import json
 
+import six
 from six.moves import http_client
 from tempest import config
 from tempest.lib.common import rest_client
@@ -59,19 +60,19 @@
         url = self._build_path(entity_id)
         resp, body = super(Federation, self).get(url, **kwargs)
         self.expected_success(http_client.OK, resp.status)
-        body = json.loads(body)
+        body = json.loads(body if six.PY2 else body.decode('utf-8'))
         return rest_client.ResponseBody(resp, body)
 
     def _patch(self, entity_id, body, **kwargs):
         url = self._build_path(entity_id)
         resp, body = super(Federation, self).patch(url, body, **kwargs)
         self.expected_success(http_client.OK, resp.status)
-        body = json.loads(body)
+        body = json.loads(body if six.PY2 else body.decode('utf-8'))
         return rest_client.ResponseBody(resp, body)
 
     def _put(self, entity_id, body, **kwargs):
         url = self._build_path(entity_id)
         resp, body = super(Federation, self).put(url, body, **kwargs)
         self.expected_success(http_client.CREATED, resp.status)
-        body = json.loads(body)
+        body = json.loads(body if six.PY2 else body.decode('utf-8'))
         return rest_client.ResponseBody(resp, body)
diff --git a/keystone_tempest_plugin/services/identity/v3/auth_client.py b/keystone_tempest_plugin/services/identity/v3/auth_client.py
index 72dc35e..f6cd660 100644
--- a/keystone_tempest_plugin/services/identity/v3/auth_client.py
+++ b/keystone_tempest_plugin/services/identity/v3/auth_client.py
@@ -14,6 +14,7 @@
 
 import json
 
+import six
 from tempest.lib.common import rest_client
 
 from keystone_tempest_plugin.services.identity import clients
@@ -25,7 +26,7 @@
         resp, body = self.raw_request(
             url, 'GET', headers={'X-Auth-Token': token_id})
         self.expected_success(200, resp.status)
-        body = json.loads(body)
+        body = json.loads(body if six.PY2 else body.decode('utf-8'))
         return rest_client.ResponseBody(resp, body)
 
     def get_available_projects_scopes(self, keystone_v3_endpoint, token_id):
diff --git a/keystone_tempest_plugin/services/identity/v3/identity_providers_client.py b/keystone_tempest_plugin/services/identity/v3/identity_providers_client.py
index 34f6899..98f49c7 100644
--- a/keystone_tempest_plugin/services/identity/v3/identity_providers_client.py
+++ b/keystone_tempest_plugin/services/identity/v3/identity_providers_client.py
@@ -14,6 +14,7 @@
 
 import json
 
+import six
 from tempest.lib.common import rest_client
 
 from keystone_tempest_plugin.services.identity import clients
@@ -62,7 +63,7 @@
             self._build_path(entity_id=idp_id), 'protocols', protocol_id)
         resp, body = self.put(url, put_body)
         self.expected_success(201, resp.status)
-        body = json.loads(body)
+        body = json.loads(body if six.PY2 else body.decode('utf-8'))
         return rest_client.ResponseBody(resp, body)
 
     def delete_protocol_and_mapping(self, idp_id, protocol_id):
@@ -79,7 +80,7 @@
             self._build_path(entity_id=idp_id), 'protocols', protocol_id)
         resp, body = self.get(url)
         self.expected_success(200, resp.status)
-        body = json.loads(body)
+        body = json.loads(body if six.PY2 else body.decode('utf-8'))
         return rest_client.ResponseBody(resp, body)
 
     def list_protocols_and_mappings(self, idp_id):
@@ -87,7 +88,7 @@
         url = '%s/%s' % (self._build_path(entity_id=idp_id), 'protocols')
         resp, body = self.get(url)
         self.expected_success(200, resp.status)
-        body = json.loads(body)
+        body = json.loads(body if six.PY2 else body.decode('utf-8'))
         return rest_client.ResponseBody(resp, body)
 
     def update_protocol_mapping(self, idp_id, protocol_id, mapping_id):
@@ -97,5 +98,5 @@
             self._build_path(entity_id=idp_id), 'protocols', protocol_id)
         resp, body = self.patch(url, patch_body)
         self.expected_success(200, resp.status)
-        body = json.loads(body)
+        body = json.loads(body if six.PY2 else body.decode('utf-8'))
         return rest_client.ResponseBody(resp, body)