Browse Source

Fix issues with keystone-dsvm-py35-functional-v3-only on py35

keystone/token/providers/fernet/token_formatters.py
* decode payload[2] from bytes to string before comparing
  with a string (CONF.identity.default_domain_id)

keystone_tempest_plugin/services/identity/clients.py
keystone_tempest_plugin/services/identity/v3/auth_client.py
keystone_tempest_plugin/services/identity/v3/identity_providers_client.py
* decode the response body from bytes to string before we
  try to parse the json using json.loads

Change-Id: I98053bc498d78c5f0076a66e725ff2d634f5b663
changes/00/412500/20
Davanum Srinivas 5 years ago
committed by Steve Martinelli
parent
commit
b4012e8085
  1. 2
      keystone/token/providers/fernet/token_formatters.py
  2. 7
      keystone_tempest_plugin/services/identity/clients.py
  3. 3
      keystone_tempest_plugin/services/identity/v3/auth_client.py
  4. 9
      keystone_tempest_plugin/services/identity/v3/identity_providers_client.py
  5. 2
      tox.ini

2
keystone/token/providers/fernet/token_formatters.py

@ -428,6 +428,8 @@ class DomainScopedPayload(BasePayload):
domain_id = cls.convert_uuid_bytes_to_hex(payload[2])
except ValueError:
# the default domain ID is configurable, and probably isn't a UUID
if six.PY3 and isinstance(payload[2], six.binary_type):
payload[2] = payload[2].decode('utf-8')
if payload[2] == CONF.identity.default_domain_id:
domain_id = payload[2]
else:

7
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 @@ class Federation(Identity):
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)

3
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 @@ class AuthClient(clients.Identity):
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):

9
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 @@ class IdentityProvidersClient(clients.Federation):
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 @@ class IdentityProvidersClient(clients.Federation):
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 @@ class IdentityProvidersClient(clients.Federation):
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 @@ class IdentityProvidersClient(clients.Federation):
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)

2
tox.ini

@ -1,7 +1,7 @@
[tox]
minversion = 2.3.1
skipsdist = True
envlist = py34,py27,pep8,api-ref,docs,genconfig,releasenotes
envlist = py35,py27,pep8,api-ref,docs,genconfig,releasenotes
[testenv]
usedevelop = True

Loading…
Cancel
Save