Handles Python3 builtin changes
Some of the builtins (like map) have changed in Python3 in a way that can lead to broken Python2 code. bp python3 Change-Id: I632d857bd29a23db61538755f09da68f0cf7b723
This commit is contained in:
parent
c6e2beaa69
commit
853ca56771
|
@ -27,7 +27,7 @@ import time
|
||||||
|
|
||||||
import memcache
|
import memcache
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
from six.moves import queue
|
from six.moves import queue, zip
|
||||||
|
|
||||||
from keystone import exception
|
from keystone import exception
|
||||||
from keystone.i18n import _
|
from keystone.i18n import _
|
||||||
|
|
|
@ -23,6 +23,7 @@ from dogpile.cache import api
|
||||||
from dogpile.cache.backends import memcached
|
from dogpile.cache.backends import memcached
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
|
from six.moves import range
|
||||||
|
|
||||||
from keystone.common.cache.backends import memcache_pool
|
from keystone.common.cache.backends import memcache_pool
|
||||||
from keystone import exception
|
from keystone import exception
|
||||||
|
|
|
@ -24,6 +24,7 @@ import ldap.filter
|
||||||
import ldappool
|
import ldappool
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
import six
|
import six
|
||||||
|
from six.moves import map, zip
|
||||||
|
|
||||||
from keystone import exception
|
from keystone import exception
|
||||||
from keystone.i18n import _
|
from keystone.i18n import _
|
||||||
|
@ -939,7 +940,7 @@ class KeystoneLDAPHandler(LDAPHandler):
|
||||||
if attrlist is None:
|
if attrlist is None:
|
||||||
attrlist_utf8 = None
|
attrlist_utf8 = None
|
||||||
else:
|
else:
|
||||||
attrlist_utf8 = map(utf8_encode, attrlist)
|
attrlist_utf8 = list(map(utf8_encode, attrlist))
|
||||||
ldap_result = self.conn.search_s(base_utf8, scope,
|
ldap_result = self.conn.search_s(base_utf8, scope,
|
||||||
filterstr_utf8,
|
filterstr_utf8,
|
||||||
attrlist_utf8, attrsonly)
|
attrlist_utf8, attrsonly)
|
||||||
|
@ -990,7 +991,7 @@ class KeystoneLDAPHandler(LDAPHandler):
|
||||||
attrlist_utf8 = None
|
attrlist_utf8 = None
|
||||||
else:
|
else:
|
||||||
attrlist = [attr for attr in attrlist if attr is not None]
|
attrlist = [attr for attr in attrlist if attr is not None]
|
||||||
attrlist_utf8 = map(utf8_encode, attrlist)
|
attrlist_utf8 = list(map(utf8_encode, attrlist))
|
||||||
msgid = self.conn.search_ext(base_utf8,
|
msgid = self.conn.search_ext(base_utf8,
|
||||||
scope,
|
scope,
|
||||||
filterstr_utf8,
|
filterstr_utf8,
|
||||||
|
|
|
@ -509,8 +509,8 @@ class RuleProcessor(object):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def extract_groups(groups_by_domain):
|
def extract_groups(groups_by_domain):
|
||||||
for groups in groups_by_domain.values():
|
for groups in list(groups_by_domain.values()):
|
||||||
for group in {g['name']: g for g in groups}.values():
|
for group in list({g['name']: g for g in groups}.values()):
|
||||||
yield group
|
yield group
|
||||||
|
|
||||||
def normalize_user(user):
|
def normalize_user(user):
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
|
from six.moves import map
|
||||||
|
|
||||||
|
|
||||||
# The set of attributes common between the RevokeEvent
|
# The set of attributes common between the RevokeEvent
|
||||||
|
@ -111,7 +112,7 @@ class RevokeEvent(object):
|
||||||
|
|
||||||
|
|
||||||
def attr_keys(event):
|
def attr_keys(event):
|
||||||
return map(event.key_for_name, _EVENT_NAMES)
|
return list(map(event.key_for_name, _EVENT_NAMES))
|
||||||
|
|
||||||
|
|
||||||
class RevokeTree(object):
|
class RevokeTree(object):
|
||||||
|
@ -176,7 +177,7 @@ class RevokeTree(object):
|
||||||
del parent[key]
|
del parent[key]
|
||||||
|
|
||||||
def add_events(self, revoke_events):
|
def add_events(self, revoke_events):
|
||||||
return map(self.add_event, revoke_events or [])
|
return list(map(self.add_event, revoke_events or []))
|
||||||
|
|
||||||
def is_revoked(self, token_data):
|
def is_revoked(self, token_data):
|
||||||
"""Check if a token matches the revocation event
|
"""Check if a token matches the revocation event
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
from six.moves import range
|
||||||
|
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
|
|
|
@ -12,6 +12,9 @@
|
||||||
|
|
||||||
"""Fixtures for Federation Mapping."""
|
"""Fixtures for Federation Mapping."""
|
||||||
|
|
||||||
|
from six.moves import range, zip
|
||||||
|
|
||||||
|
|
||||||
EMPLOYEE_GROUP_ID = "0cd5e9"
|
EMPLOYEE_GROUP_ID = "0cd5e9"
|
||||||
CONTRACTOR_GROUP_ID = "85a868"
|
CONTRACTOR_GROUP_ID = "85a868"
|
||||||
TESTER_GROUP_ID = "123"
|
TESTER_GROUP_ID = "123"
|
||||||
|
@ -989,8 +992,8 @@ MALFORMED_TESTER_ASSERTION = {
|
||||||
'LastName': 'Account',
|
'LastName': 'Account',
|
||||||
'orgPersonType': 'Tester',
|
'orgPersonType': 'Tester',
|
||||||
'object': object(),
|
'object': object(),
|
||||||
'dictionary': dict(zip('teststring', xrange(10))),
|
'dictionary': dict(zip('teststring', range(10))),
|
||||||
'tuple': tuple(xrange(5))
|
'tuple': tuple(range(5))
|
||||||
}
|
}
|
||||||
|
|
||||||
DEVELOPER_ASSERTION = {
|
DEVELOPER_ASSERTION = {
|
||||||
|
|
|
@ -22,6 +22,7 @@ import mock
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
import six
|
import six
|
||||||
|
from six.moves import range
|
||||||
from testtools import matchers
|
from testtools import matchers
|
||||||
|
|
||||||
from keystone.catalog import core
|
from keystone.catalog import core
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
from six.moves import range
|
||||||
from testtools import matchers
|
from testtools import matchers
|
||||||
|
|
||||||
from keystone import exception
|
from keystone import exception
|
||||||
|
|
|
@ -20,6 +20,7 @@ import uuid
|
||||||
import ldap
|
import ldap
|
||||||
import mock
|
import mock
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
from six.moves import range
|
||||||
from testtools import matchers
|
from testtools import matchers
|
||||||
|
|
||||||
from keystone.common import cache
|
from keystone.common import cache
|
||||||
|
|
|
@ -20,6 +20,7 @@ import mock
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_db import exception as db_exception
|
from oslo_db import exception as db_exception
|
||||||
from oslo_db import options
|
from oslo_db import options
|
||||||
|
from six.moves import range
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
from sqlalchemy import exc
|
from sqlalchemy import exc
|
||||||
from testtools import matchers
|
from testtools import matchers
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
import os
|
import os
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
from six.moves import zip
|
||||||
|
|
||||||
from keystone.tests import unit as tests
|
from keystone.tests import unit as tests
|
||||||
from keystone.tests.unit import default_fixtures
|
from keystone.tests.unit import default_fixtures
|
||||||
from keystone.tests.unit.ksfixtures import database
|
from keystone.tests.unit.ksfixtures import database
|
||||||
|
|
|
@ -20,6 +20,7 @@ import uuid
|
||||||
from dogpile.cache import api
|
from dogpile.cache import api
|
||||||
from dogpile.cache import region as dp_region
|
from dogpile.cache import region as dp_region
|
||||||
import six
|
import six
|
||||||
|
from six.moves import range
|
||||||
|
|
||||||
from keystone.common.cache.backends import mongo
|
from keystone.common.cache.backends import mongo
|
||||||
from keystone import exception
|
from keystone import exception
|
||||||
|
|
|
@ -17,6 +17,7 @@ import uuid
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
from six.moves import range
|
||||||
|
|
||||||
from keystone import cli
|
from keystone import cli
|
||||||
from keystone.common import dependency
|
from keystone.common import dependency
|
||||||
|
|
|
@ -18,6 +18,7 @@ import uuid
|
||||||
import ldap
|
import ldap
|
||||||
import ldap.modlist
|
import ldap.modlist
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
from six.moves import range
|
||||||
|
|
||||||
from keystone import exception
|
from keystone import exception
|
||||||
from keystone.identity.backends import ldap as identity_ldap
|
from keystone.identity.backends import ldap as identity_ldap
|
||||||
|
|
|
@ -16,6 +16,7 @@ import uuid
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
|
from six.moves import range
|
||||||
from testtools import matchers
|
from testtools import matchers
|
||||||
|
|
||||||
from keystone.contrib import revoke
|
from keystone.contrib import revoke
|
||||||
|
|
|
@ -21,6 +21,7 @@ import mock
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
|
from six.moves import range
|
||||||
import webob
|
import webob
|
||||||
|
|
||||||
from keystone.tests import unit as tests
|
from keystone.tests import unit as tests
|
||||||
|
|
|
@ -15,6 +15,7 @@ import uuid
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
import six
|
import six
|
||||||
|
from six.moves import range
|
||||||
|
|
||||||
from keystone.common import controller
|
from keystone.common import controller
|
||||||
from keystone import exception
|
from keystone import exception
|
||||||
|
|
|
@ -23,6 +23,7 @@ import mock
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
import six
|
import six
|
||||||
|
from six.moves import range
|
||||||
from testtools import matchers
|
from testtools import matchers
|
||||||
from testtools import testcase
|
from testtools import testcase
|
||||||
|
|
||||||
|
@ -2921,7 +2922,7 @@ class TestTrustChain(test_v3.RestfulTestCase):
|
||||||
# Create trust chain
|
# Create trust chain
|
||||||
self.user_chain = list()
|
self.user_chain = list()
|
||||||
self.trust_chain = list()
|
self.trust_chain = list()
|
||||||
for _ in xrange(3):
|
for _ in range(3):
|
||||||
user_ref = self.new_user_ref(domain_id=self.domain_id)
|
user_ref = self.new_user_ref(domain_id=self.domain_id)
|
||||||
user = self.identity_api.create_user(user_ref)
|
user = self.identity_api.create_user(user_ref)
|
||||||
user['password'] = user_ref['password']
|
user['password'] = user_ref['password']
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
import six
|
import six
|
||||||
|
from six.moves import range
|
||||||
from testtools import matchers
|
from testtools import matchers
|
||||||
|
|
||||||
from keystone.common import controller
|
from keystone.common import controller
|
||||||
|
|
|
@ -25,7 +25,7 @@ from oslotest import mockpatch
|
||||||
import saml2
|
import saml2
|
||||||
from saml2 import saml
|
from saml2 import saml
|
||||||
from saml2 import sigver
|
from saml2 import sigver
|
||||||
from six.moves import urllib
|
from six.moves import range, urllib, zip
|
||||||
import xmldsig
|
import xmldsig
|
||||||
|
|
||||||
from keystone.auth import controllers as auth_controllers
|
from keystone.auth import controllers as auth_controllers
|
||||||
|
@ -2155,7 +2155,7 @@ class FederatedTokenTests(FederationTests, FederatedSetupMixin):
|
||||||
context = {
|
context = {
|
||||||
'environment': {
|
'environment': {
|
||||||
'malformed_object': object(),
|
'malformed_object': object(),
|
||||||
'another_bad_idea': tuple(xrange(10)),
|
'another_bad_idea': tuple(range(10)),
|
||||||
'yet_another_bad_param': dict(zip(uuid.uuid4().hex,
|
'yet_another_bad_param': dict(zip(uuid.uuid4().hex,
|
||||||
range(32)))
|
range(32)))
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ import uuid
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
|
from six.moves import range
|
||||||
|
|
||||||
from keystone.tests.unit import filtering
|
from keystone.tests.unit import filtering
|
||||||
from keystone.tests.unit.ksfixtures import temporaryfile
|
from keystone.tests.unit.ksfixtures import temporaryfile
|
||||||
|
|
|
@ -15,6 +15,7 @@ import uuid
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
|
from six.moves import range
|
||||||
|
|
||||||
from keystone import exception
|
from keystone import exception
|
||||||
from keystone.models import token_model
|
from keystone.models import token_model
|
||||||
|
|
|
@ -21,7 +21,7 @@ from oslo_config import cfg
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
import six
|
import six
|
||||||
from six.moves import urllib
|
from six.moves import map, urllib
|
||||||
|
|
||||||
from keystone.auth import plugins as auth_plugins
|
from keystone.auth import plugins as auth_plugins
|
||||||
from keystone import exception
|
from keystone import exception
|
||||||
|
@ -508,12 +508,13 @@ class FederatedPayload(BasePayload):
|
||||||
|
|
||||||
b_user_id = cls.attempt_convert_uuid_hex_to_bytes(user_id)
|
b_user_id = cls.attempt_convert_uuid_hex_to_bytes(user_id)
|
||||||
methods = auth_plugins.convert_method_list_to_integer(methods)
|
methods = auth_plugins.convert_method_list_to_integer(methods)
|
||||||
b_group_ids = map(pack_group_ids, federated_info['group_ids'])
|
b_group_ids = list(map(pack_group_ids, federated_info['group_ids']))
|
||||||
b_idp_id = cls.attempt_convert_uuid_hex_to_bytes(
|
b_idp_id = cls.attempt_convert_uuid_hex_to_bytes(
|
||||||
federated_info['idp_id'])
|
federated_info['idp_id'])
|
||||||
protocol_id = federated_info['protocol_id']
|
protocol_id = federated_info['protocol_id']
|
||||||
expires_at_int = cls._convert_time_string_to_int(expires_at)
|
expires_at_int = cls._convert_time_string_to_int(expires_at)
|
||||||
b_audit_ids = map(provider.random_urlsafe_str_to_bytes, audit_ids)
|
b_audit_ids = list(map(provider.random_urlsafe_str_to_bytes,
|
||||||
|
audit_ids))
|
||||||
|
|
||||||
return (b_user_id, methods, b_group_ids, b_idp_id, protocol_id,
|
return (b_user_id, methods, b_group_ids, b_idp_id, protocol_id,
|
||||||
expires_at_int, b_audit_ids)
|
expires_at_int, b_audit_ids)
|
||||||
|
@ -535,11 +536,11 @@ class FederatedPayload(BasePayload):
|
||||||
|
|
||||||
user_id = cls.attempt_convert_uuid_bytes_to_hex(payload[0])
|
user_id = cls.attempt_convert_uuid_bytes_to_hex(payload[0])
|
||||||
methods = auth_plugins.convert_integer_to_method_list(payload[1])
|
methods = auth_plugins.convert_integer_to_method_list(payload[1])
|
||||||
group_ids = map(unpack_group_ids, payload[2])
|
group_ids = list(map(unpack_group_ids, payload[2]))
|
||||||
idp_id = cls.attempt_convert_uuid_bytes_to_hex(payload[3])
|
idp_id = cls.attempt_convert_uuid_bytes_to_hex(payload[3])
|
||||||
protocol_id = payload[4]
|
protocol_id = payload[4]
|
||||||
expires_at_str = cls._convert_int_to_time_string(payload[5])
|
expires_at_str = cls._convert_int_to_time_string(payload[5])
|
||||||
audit_ids = map(provider.base64_encode, payload[6])
|
audit_ids = list(map(provider.base64_encode, payload[6]))
|
||||||
federated_info = dict(group_ids=group_ids, idp_id=idp_id,
|
federated_info = dict(group_ids=group_ids, idp_id=idp_id,
|
||||||
protocol_id=protocol_id)
|
protocol_id=protocol_id)
|
||||||
return (user_id, methods, expires_at_str, audit_ids, federated_info)
|
return (user_id, methods, expires_at_str, audit_ids, federated_info)
|
||||||
|
|
|
@ -16,6 +16,7 @@ import time
|
||||||
|
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
|
from six.moves import range
|
||||||
|
|
||||||
from keystone.common import sql
|
from keystone.common import sql
|
||||||
from keystone import exception
|
from keystone import exception
|
||||||
|
|
|
@ -19,6 +19,7 @@ import abc
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
import six
|
import six
|
||||||
|
from six.moves import zip
|
||||||
|
|
||||||
from keystone.common import dependency
|
from keystone.common import dependency
|
||||||
from keystone.common import manager
|
from keystone.common import manager
|
||||||
|
|
Loading…
Reference in New Issue