Merge "Remove six"
This commit is contained in:
commit
ca6c205e87
@ -12,7 +12,6 @@ Barbican Specific Commandments
|
|||||||
- [B310] Check for improper use of logging format arguments.
|
- [B310] Check for improper use of logging format arguments.
|
||||||
- [B311] Use assertIsNone(...) instead of assertEqual(None, ...).
|
- [B311] Use assertIsNone(...) instead of assertEqual(None, ...).
|
||||||
- [B312] Use assertTrue(...) rather than assertEqual(True, ...).
|
- [B312] Use assertTrue(...) rather than assertEqual(True, ...).
|
||||||
- [B314] str() and unicode() cannot be used on an exception. Remove or use six.text_type().
|
|
||||||
- [B317] `oslo_` should be used instead of `oslo`.
|
- [B317] `oslo_` should be used instead of `oslo`.
|
||||||
- [B318] Must use a dict comprehension instead of a dict constructor
|
- [B318] Must use a dict comprehension instead of a dict constructor
|
||||||
with a sequence of key-value pairs.
|
with a sequence of key-value pairs.
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
API handler for Barbican
|
API handler for Barbican
|
||||||
"""
|
"""
|
||||||
import pkgutil
|
import pkgutil
|
||||||
import six
|
|
||||||
|
|
||||||
from oslo_policy import policy
|
from oslo_policy import policy
|
||||||
from oslo_serialization import jsonutils as json
|
from oslo_serialization import jsonutils as json
|
||||||
@ -69,7 +68,7 @@ def load_body(req, resp=None, validator=None):
|
|||||||
try:
|
try:
|
||||||
parsed_body = validator.validate(parsed_body)
|
parsed_body = validator.validate(parsed_body)
|
||||||
except exception.BarbicanHTTPException as e:
|
except exception.BarbicanHTTPException as e:
|
||||||
LOG.exception(six.text_type(e))
|
LOG.exception(str(e))
|
||||||
pecan.abort(e.status_code, e.client_message)
|
pecan.abort(e.status_code, e.client_message)
|
||||||
|
|
||||||
return parsed_body
|
return parsed_body
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
|
|
||||||
import pecan
|
import pecan
|
||||||
import six
|
|
||||||
|
|
||||||
from barbican import api
|
from barbican import api
|
||||||
from barbican.api import controllers
|
from barbican.api import controllers
|
||||||
@ -104,8 +103,8 @@ class SecretACLsController(controllers.ACLMixin):
|
|||||||
|
|
||||||
existing_acls_map = {acl.operation: acl for acl in
|
existing_acls_map = {acl.operation: acl for acl in
|
||||||
self.secret.secret_acls}
|
self.secret.secret_acls}
|
||||||
for operation in six.moves.filter(lambda x: data.get(x),
|
for operation in filter(lambda x: data.get(x),
|
||||||
validators.ACL_OPERATIONS):
|
validators.ACL_OPERATIONS):
|
||||||
project_access = data[operation].get('project-access')
|
project_access = data[operation].get('project-access')
|
||||||
user_ids = data[operation].get('users')
|
user_ids = data[operation].get('users')
|
||||||
s_acl = None
|
s_acl = None
|
||||||
@ -165,8 +164,8 @@ class SecretACLsController(controllers.ACLMixin):
|
|||||||
|
|
||||||
existing_acls_map = {acl.operation: acl for acl in
|
existing_acls_map = {acl.operation: acl for acl in
|
||||||
self.secret.secret_acls}
|
self.secret.secret_acls}
|
||||||
for operation in six.moves.filter(lambda x: data.get(x),
|
for operation in filter(lambda x: data.get(x),
|
||||||
validators.ACL_OPERATIONS):
|
validators.ACL_OPERATIONS):
|
||||||
project_access = data[operation].get('project-access', True)
|
project_access = data[operation].get('project-access', True)
|
||||||
user_ids = data[operation].get('users', [])
|
user_ids = data[operation].get('users', [])
|
||||||
s_acl = None
|
s_acl = None
|
||||||
@ -270,8 +269,8 @@ class ContainerACLsController(controllers.ACLMixin):
|
|||||||
|
|
||||||
existing_acls_map = {acl.operation: acl for acl in
|
existing_acls_map = {acl.operation: acl for acl in
|
||||||
self.container.container_acls}
|
self.container.container_acls}
|
||||||
for operation in six.moves.filter(lambda x: data.get(x),
|
for operation in filter(lambda x: data.get(x),
|
||||||
validators.ACL_OPERATIONS):
|
validators.ACL_OPERATIONS):
|
||||||
project_access = data[operation].get('project-access')
|
project_access = data[operation].get('project-access')
|
||||||
user_ids = data[operation].get('users')
|
user_ids = data[operation].get('users')
|
||||||
if operation in existing_acls_map: # update if matching acl exists
|
if operation in existing_acls_map: # update if matching acl exists
|
||||||
@ -334,8 +333,8 @@ class ContainerACLsController(controllers.ACLMixin):
|
|||||||
|
|
||||||
existing_acls_map = {acl.operation: acl for acl in
|
existing_acls_map = {acl.operation: acl for acl in
|
||||||
self.container.container_acls}
|
self.container.container_acls}
|
||||||
for operation in six.moves.filter(lambda x: data.get(x),
|
for operation in filter(lambda x: data.get(x),
|
||||||
validators.ACL_OPERATIONS):
|
validators.ACL_OPERATIONS):
|
||||||
project_access = data[operation].get('project-access', True)
|
project_access = data[operation].get('project-access', True)
|
||||||
user_ids = data[operation].get('users', [])
|
user_ids = data[operation].get('users', [])
|
||||||
if operation in existing_acls_map: # update if matching acl exists
|
if operation in existing_acls_map: # update if matching acl exists
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
import pecan
|
import pecan
|
||||||
from six.moves.urllib import parse
|
from urllib import parse
|
||||||
|
|
||||||
from barbican import api
|
from barbican import api
|
||||||
from barbican.api import controllers
|
from barbican.api import controllers
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import pecan
|
import pecan
|
||||||
from six.moves.urllib import parse
|
from urllib import parse
|
||||||
|
|
||||||
from barbican import api
|
from barbican import api
|
||||||
from barbican.api import controllers
|
from barbican.api import controllers
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import pecan
|
import pecan
|
||||||
from six.moves.urllib import parse
|
from urllib import parse
|
||||||
|
|
||||||
from barbican.api import controllers
|
from barbican.api import controllers
|
||||||
from barbican.api.controllers import containers
|
from barbican.api.controllers import containers
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
import argparse
|
import argparse
|
||||||
import six
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from barbican.plugin.crypto import pkcs11
|
from barbican.plugin.crypto import pkcs11
|
||||||
@ -30,7 +29,7 @@ class KeyGenerator(object):
|
|||||||
self.add_hmac_args()
|
self.add_hmac_args()
|
||||||
self.args = self.parser.parse_args()
|
self.args = self.parser.parse_args()
|
||||||
if not self.args.passphrase:
|
if not self.args.passphrase:
|
||||||
password = six.moves.input("Please enter your password: ")
|
password = input("Please enter your password: ")
|
||||||
self.pkcs11 = pkcs11.PKCS11(
|
self.pkcs11 = pkcs11.PKCS11(
|
||||||
library_path=self.args.library_path,
|
library_path=self.args.library_path,
|
||||||
login_passphrase=self.args.passphrase or password,
|
login_passphrase=self.args.passphrase or password,
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import base64
|
import base64
|
||||||
import six
|
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
from oslo_db.sqlalchemy import session
|
from oslo_db.sqlalchemy import session
|
||||||
@ -62,7 +61,7 @@ class KekSignatureMigrator(object):
|
|||||||
self.pkcs11.verify_hmac(hmac_key, hmac, kek_data, self.session)
|
self.pkcs11.verify_hmac(hmac_key, hmac, kek_data, self.session)
|
||||||
sig_good = True
|
sig_good = True
|
||||||
except P11CryptoPluginException as e:
|
except P11CryptoPluginException as e:
|
||||||
if 'CKR_SIGNATURE_INVALID' in six.text_type(e):
|
if 'CKR_SIGNATURE_INVALID' in str(e):
|
||||||
sig_good = False
|
sig_good = False
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
@ -80,7 +79,7 @@ class KekSignatureMigrator(object):
|
|||||||
)
|
)
|
||||||
sig_bad = True
|
sig_bad = True
|
||||||
except P11CryptoPluginException as e:
|
except P11CryptoPluginException as e:
|
||||||
if 'CKR_SIGNATURE_INVALID' in six.text_type(e):
|
if 'CKR_SIGNATURE_INVALID' in str(e):
|
||||||
sig_bad = False
|
sig_bad = False
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
"""
|
"""
|
||||||
Common utilities for Barbican.
|
Common utilities for Barbican.
|
||||||
"""
|
"""
|
||||||
|
import builtins
|
||||||
import collections
|
import collections
|
||||||
import importlib
|
import importlib
|
||||||
import mimetypes
|
import mimetypes
|
||||||
@ -25,8 +26,7 @@ from oslo_log import log
|
|||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
import pecan
|
import pecan
|
||||||
import re
|
import re
|
||||||
import six
|
from urllib import parse
|
||||||
from six.moves.urllib import parse
|
|
||||||
|
|
||||||
from barbican.common import config
|
from barbican.common import config
|
||||||
from barbican import i18n as u
|
from barbican import i18n as u
|
||||||
@ -179,7 +179,7 @@ def generate_fullname_for(instance):
|
|||||||
module = type(instance).__module__
|
module = type(instance).__module__
|
||||||
class_name = type(instance).__name__
|
class_name = type(instance).__name__
|
||||||
|
|
||||||
if module is None or module == six.moves.builtins.__name__:
|
if module is None or module == builtins.__name__:
|
||||||
return class_name
|
return class_name
|
||||||
return "{module}.{class_name}".format(module=module, class_name=class_name)
|
return "{module}.{class_name}".format(module=module, class_name=class_name)
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@ from ldap3.core import exceptions as ldap_exceptions
|
|||||||
from ldap3.utils.dn import parse_dn
|
from ldap3.utils.dn import parse_dn
|
||||||
from OpenSSL import crypto
|
from OpenSSL import crypto
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
import six
|
|
||||||
|
|
||||||
from barbican.api import controllers
|
from barbican.api import controllers
|
||||||
from barbican.common import config
|
from barbican.common import config
|
||||||
@ -46,7 +45,7 @@ ACL_OPERATIONS = ['read', 'write', 'delete', 'list']
|
|||||||
|
|
||||||
|
|
||||||
def secret_too_big(data):
|
def secret_too_big(data):
|
||||||
if isinstance(data, six.text_type):
|
if isinstance(data, str):
|
||||||
return len(data.encode('UTF-8')) > CONF.max_allowed_secret_in_bytes
|
return len(data.encode('UTF-8')) > CONF.max_allowed_secret_in_bytes
|
||||||
else:
|
else:
|
||||||
return len(data) > CONF.max_allowed_secret_in_bytes
|
return len(data) > CONF.max_allowed_secret_in_bytes
|
||||||
@ -234,7 +233,7 @@ class NewSecretValidator(ValidatorBase):
|
|||||||
def _extract_name(self, json_data):
|
def _extract_name(self, json_data):
|
||||||
"""Extracts and returns the name from the JSON data."""
|
"""Extracts and returns the name from the JSON data."""
|
||||||
name = json_data.get('name')
|
name = json_data.get('name')
|
||||||
if isinstance(name, six.string_types):
|
if isinstance(name, str):
|
||||||
return name.strip()
|
return name.strip()
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -346,13 +345,13 @@ class NewSecretMetadataValidator(ValidatorBase):
|
|||||||
|
|
||||||
for key in list(metadata):
|
for key in list(metadata):
|
||||||
# make sure key is a string and url-safe.
|
# make sure key is a string and url-safe.
|
||||||
if not isinstance(key, six.string_types):
|
if not isinstance(key, str):
|
||||||
raise exception.InvalidMetadataRequest()
|
raise exception.InvalidMetadataRequest()
|
||||||
self._check_string_url_safe(key)
|
self._check_string_url_safe(key)
|
||||||
|
|
||||||
# make sure value is a string.
|
# make sure value is a string.
|
||||||
value = metadata[key]
|
value = metadata[key]
|
||||||
if not isinstance(value, six.string_types):
|
if not isinstance(value, str):
|
||||||
raise exception.InvalidMetadataRequest()
|
raise exception.InvalidMetadataRequest()
|
||||||
|
|
||||||
# If key is not lowercase, then change it
|
# If key is not lowercase, then change it
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
import ast
|
import ast
|
||||||
import re
|
import re
|
||||||
import six
|
|
||||||
|
|
||||||
from hacking import core
|
from hacking import core
|
||||||
import pycodestyle
|
import pycodestyle
|
||||||
@ -117,7 +116,7 @@ class CheckLoggingFormatArgs(BaseASTChecker):
|
|||||||
if obj_name is None:
|
if obj_name is None:
|
||||||
return None
|
return None
|
||||||
return obj_name + '.' + method_name
|
return obj_name + '.' + method_name
|
||||||
elif isinstance(node, six.string_types):
|
elif isinstance(node, str):
|
||||||
return node
|
return node
|
||||||
else: # could be Subscript, Call or many more
|
else: # could be Subscript, Call or many more
|
||||||
return None
|
return None
|
||||||
|
@ -20,7 +20,6 @@ import hashlib
|
|||||||
|
|
||||||
from oslo_serialization import jsonutils as json
|
from oslo_serialization import jsonutils as json
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
import six
|
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
from sqlalchemy.ext import compiler
|
from sqlalchemy.ext import compiler
|
||||||
from sqlalchemy.ext import declarative
|
from sqlalchemy.ext import declarative
|
||||||
@ -195,7 +194,7 @@ class ModelBase(object):
|
|||||||
|
|
||||||
def _iso_to_datetime(self, expiration):
|
def _iso_to_datetime(self, expiration):
|
||||||
"""Convert ISO formatted string to datetime."""
|
"""Convert ISO formatted string to datetime."""
|
||||||
if isinstance(expiration, six.string_types):
|
if isinstance(expiration, str):
|
||||||
expiration_iso = timeutils.parse_isotime(expiration.strip())
|
expiration_iso = timeutils.parse_isotime(expiration.strip())
|
||||||
expiration = timeutils.normalize_time(expiration_iso)
|
expiration = timeutils.normalize_time(expiration_iso)
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
from oslo_serialization import jsonutils as json
|
from oslo_serialization import jsonutils as json
|
||||||
from oslo_versionedobjects import fields
|
from oslo_versionedobjects import fields
|
||||||
import six
|
|
||||||
|
|
||||||
# Import field errors from oslo.versionedobjects
|
# Import field errors from oslo.versionedobjects
|
||||||
KeyTypeError = fields.KeyTypeError
|
KeyTypeError = fields.KeyTypeError
|
||||||
@ -75,7 +74,7 @@ IPV6Network = fields.IPV6Network
|
|||||||
|
|
||||||
class Json(FieldType):
|
class Json(FieldType):
|
||||||
def coerce(self, obj, attr, value):
|
def coerce(self, obj, attr, value):
|
||||||
if isinstance(value, six.string_types):
|
if isinstance(value, str):
|
||||||
loaded = json.loads(value)
|
loaded = json.loads(value)
|
||||||
return loaded
|
return loaded
|
||||||
return value
|
return value
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
import abc
|
import abc
|
||||||
import base64
|
import base64
|
||||||
import six
|
|
||||||
|
|
||||||
from castellan.common.objects import key
|
from castellan.common.objects import key
|
||||||
from castellan.common.objects import opaque_data
|
from castellan.common.objects import opaque_data
|
||||||
@ -126,7 +125,7 @@ class CastellanSecretStore(ss.SecretStoreBase, metaclass=abc.ABCMeta):
|
|||||||
return ss.SecretDTO(secret_type, data, ss.KeySpec(), None)
|
return ss.SecretDTO(secret_type, data, ss.KeySpec(), None)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOG.exception("Error retrieving secret {}: {}".format(
|
LOG.exception("Error retrieving secret {}: {}".format(
|
||||||
secret_ref, six.text_type(e)))
|
secret_ref, str(e)))
|
||||||
raise ss.SecretGeneralException(e)
|
raise ss.SecretGeneralException(e)
|
||||||
|
|
||||||
def store_secret(self, secret_dto):
|
def store_secret(self, secret_dto):
|
||||||
@ -142,7 +141,7 @@ class CastellanSecretStore(ss.SecretStoreBase, metaclass=abc.ABCMeta):
|
|||||||
return self._meta_dict(secret_id)
|
return self._meta_dict(secret_id)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOG.exception("Error storing secret: {}".format(
|
LOG.exception("Error storing secret: {}".format(
|
||||||
six.text_type(e)))
|
str(e)))
|
||||||
raise ss.SecretGeneralException(e)
|
raise ss.SecretGeneralException(e)
|
||||||
|
|
||||||
def delete_secret(self, secret_metadata):
|
def delete_secret(self, secret_metadata):
|
||||||
@ -156,7 +155,7 @@ class CastellanSecretStore(ss.SecretStoreBase, metaclass=abc.ABCMeta):
|
|||||||
secret_ref))
|
secret_ref))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOG.exception("Error deleting secret: {}".format(
|
LOG.exception("Error deleting secret: {}".format(
|
||||||
six.text_type(e)))
|
str(e)))
|
||||||
raise ss.SecretGeneralException(e)
|
raise ss.SecretGeneralException(e)
|
||||||
|
|
||||||
def generate_symmetric_key(self, key_spec):
|
def generate_symmetric_key(self, key_spec):
|
||||||
@ -172,7 +171,7 @@ class CastellanSecretStore(ss.SecretStoreBase, metaclass=abc.ABCMeta):
|
|||||||
return self._meta_dict(secret_id)
|
return self._meta_dict(secret_id)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOG.exception("Error generating symmetric key: {}".format(
|
LOG.exception("Error generating symmetric key: {}".format(
|
||||||
six.text_type(e)))
|
str(e)))
|
||||||
raise ss.SecretGeneralException(e)
|
raise ss.SecretGeneralException(e)
|
||||||
|
|
||||||
def generate_asymmetric_key(self, key_spec):
|
def generate_asymmetric_key(self, key_spec):
|
||||||
@ -205,7 +204,7 @@ class CastellanSecretStore(ss.SecretStoreBase, metaclass=abc.ABCMeta):
|
|||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOG.exception("Error generating asymmetric key: {}".format(
|
LOG.exception("Error generating asymmetric key: {}".format(
|
||||||
six.text_type(e)))
|
str(e)))
|
||||||
raise ss.SecretGeneralException(e)
|
raise ss.SecretGeneralException(e)
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
|
@ -16,7 +16,6 @@ import textwrap
|
|||||||
|
|
||||||
import cffi
|
import cffi
|
||||||
from cryptography.hazmat.primitives import padding
|
from cryptography.hazmat.primitives import padding
|
||||||
import six
|
|
||||||
|
|
||||||
from barbican.common import exception
|
from barbican.common import exception
|
||||||
from barbican.common import utils
|
from barbican.common import utils
|
||||||
@ -950,7 +949,7 @@ class PKCS11(object):
|
|||||||
|
|
||||||
|
|
||||||
def _to_bytes(string):
|
def _to_bytes(string):
|
||||||
if isinstance(string, six.binary_type):
|
if isinstance(string, bytes):
|
||||||
return string
|
return string
|
||||||
else:
|
else:
|
||||||
return string.encode('UTF-8')
|
return string.encode('UTF-8')
|
||||||
|
@ -19,7 +19,6 @@ from cryptography.hazmat.primitives.asymmetric import rsa
|
|||||||
from cryptography.hazmat.primitives import serialization
|
from cryptography.hazmat.primitives import serialization
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_utils import encodeutils
|
from oslo_utils import encodeutils
|
||||||
import six
|
|
||||||
|
|
||||||
from barbican.common import config
|
from barbican.common import config
|
||||||
from barbican.common import utils
|
from barbican.common import utils
|
||||||
@ -67,7 +66,7 @@ class SimpleCryptoPlugin(c.CryptoPluginBase):
|
|||||||
# the kek is stored encrypted. Need to decrypt.
|
# the kek is stored encrypted. Need to decrypt.
|
||||||
encryptor = fernet.Fernet(self.master_kek)
|
encryptor = fernet.Fernet(self.master_kek)
|
||||||
# Note : If plugin_meta type is unicode, encode to byte.
|
# Note : If plugin_meta type is unicode, encode to byte.
|
||||||
if isinstance(kek_meta_dto.plugin_meta, six.text_type):
|
if isinstance(kek_meta_dto.plugin_meta, str):
|
||||||
kek_meta_dto.plugin_meta = kek_meta_dto.plugin_meta.encode('utf-8')
|
kek_meta_dto.plugin_meta = kek_meta_dto.plugin_meta.encode('utf-8')
|
||||||
|
|
||||||
return encryptor.decrypt(kek_meta_dto.plugin_meta)
|
return encryptor.decrypt(kek_meta_dto.plugin_meta)
|
||||||
@ -75,7 +74,7 @@ class SimpleCryptoPlugin(c.CryptoPluginBase):
|
|||||||
def encrypt(self, encrypt_dto, kek_meta_dto, project_id):
|
def encrypt(self, encrypt_dto, kek_meta_dto, project_id):
|
||||||
kek = self._get_kek(kek_meta_dto)
|
kek = self._get_kek(kek_meta_dto)
|
||||||
unencrypted = encrypt_dto.unencrypted
|
unencrypted = encrypt_dto.unencrypted
|
||||||
if not isinstance(unencrypted, six.binary_type):
|
if not isinstance(unencrypted, bytes):
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
u._(
|
u._(
|
||||||
'Unencrypted data must be a byte type, but was '
|
'Unencrypted data must be a byte type, but was '
|
||||||
@ -174,7 +173,7 @@ class SimpleCryptoPlugin(c.CryptoPluginBase):
|
|||||||
|
|
||||||
passphrase_dto = None
|
passphrase_dto = None
|
||||||
if generate_dto.passphrase:
|
if generate_dto.passphrase:
|
||||||
if isinstance(generate_dto.passphrase, six.text_type):
|
if isinstance(generate_dto.passphrase, str):
|
||||||
generate_dto.passphrase = generate_dto.passphrase.encode(
|
generate_dto.passphrase = generate_dto.passphrase.encode(
|
||||||
'utf-8')
|
'utf-8')
|
||||||
|
|
||||||
|
@ -38,7 +38,6 @@ import pki.key as key
|
|||||||
import pki.kra
|
import pki.kra
|
||||||
import pki.profile
|
import pki.profile
|
||||||
from requests import exceptions as request_exceptions
|
from requests import exceptions as request_exceptions
|
||||||
import six
|
|
||||||
|
|
||||||
from barbican.common import exception
|
from barbican.common import exception
|
||||||
from barbican.common import utils
|
from barbican.common import utils
|
||||||
@ -94,7 +93,7 @@ def _setup_nss_db_services(conf):
|
|||||||
return None
|
return None
|
||||||
if nss_password is None:
|
if nss_password is None:
|
||||||
raise ValueError(u._("nss_password is required"))
|
raise ValueError(u._("nss_password is required"))
|
||||||
if type(nss_password) is not six.binary_type:
|
if type(nss_password) is not bytes:
|
||||||
# Password needs to be a bytes object in Python 3
|
# Password needs to be a bytes object in Python 3
|
||||||
nss_password = nss_password.encode('UTF-8')
|
nss_password = nss_password.encode('UTF-8')
|
||||||
|
|
||||||
|
@ -17,8 +17,6 @@
|
|||||||
Barbican defined mime-types
|
Barbican defined mime-types
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from barbican.common import utils
|
from barbican.common import utils
|
||||||
|
|
||||||
|
|
||||||
@ -65,7 +63,7 @@ CTYPES_TO_ENCODINGS = {'text/plain': None,
|
|||||||
|
|
||||||
def normalize_content_type(mime_type):
|
def normalize_content_type(mime_type):
|
||||||
"""Normalize the supplied content-type to an internal form."""
|
"""Normalize the supplied content-type to an internal form."""
|
||||||
stripped = list(six.moves.map(lambda x: x.strip(), mime_type.split(';')))
|
stripped = list(map(lambda x: x.strip(), mime_type.split(';')))
|
||||||
mime = stripped[0].lower()
|
mime = stripped[0].lower()
|
||||||
if len(stripped) > 1:
|
if len(stripped) > 1:
|
||||||
# mime type includes charset
|
# mime type includes charset
|
||||||
@ -74,7 +72,7 @@ def normalize_content_type(mime_type):
|
|||||||
# charset is malformed
|
# charset is malformed
|
||||||
return mime_type
|
return mime_type
|
||||||
else:
|
else:
|
||||||
charset = list(six.moves.map(lambda x: x.strip(),
|
charset = list(map(lambda x: x.strip(),
|
||||||
charset_type.split('=')))[1]
|
charset_type.split('=')))[1]
|
||||||
if charset not in PLAIN_TEXT_CHARSETS:
|
if charset not in PLAIN_TEXT_CHARSETS:
|
||||||
# unsupported charset
|
# unsupported charset
|
||||||
|
@ -15,7 +15,6 @@ from cryptography.hazmat.backends import default_backend
|
|||||||
from cryptography.hazmat.primitives import serialization
|
from cryptography.hazmat.primitives import serialization
|
||||||
from OpenSSL import crypto
|
from OpenSSL import crypto
|
||||||
from oslo_serialization import base64
|
from oslo_serialization import base64
|
||||||
import six
|
|
||||||
|
|
||||||
from barbican import i18n as u # noqa
|
from barbican import i18n as u # noqa
|
||||||
from barbican.plugin.interface import secret_store as s
|
from barbican.plugin.interface import secret_store as s
|
||||||
@ -56,7 +55,7 @@ def normalize_before_encryption(unencrypted, content_type, content_encoding,
|
|||||||
if not content_encoding:
|
if not content_encoding:
|
||||||
b64payload = base64.encode_as_bytes(unencrypted)
|
b64payload = base64.encode_as_bytes(unencrypted)
|
||||||
elif content_encoding.lower() == 'base64':
|
elif content_encoding.lower() == 'base64':
|
||||||
if not isinstance(unencrypted, six.binary_type):
|
if not isinstance(unencrypted, bytes):
|
||||||
b64payload = unencrypted.encode('utf-8')
|
b64payload = unencrypted.encode('utf-8')
|
||||||
else:
|
else:
|
||||||
b64payload = unencrypted
|
b64payload = unencrypted
|
||||||
|
@ -21,7 +21,6 @@ transport key resource classes.
|
|||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
import pecan
|
import pecan
|
||||||
from six import moves
|
|
||||||
import webtest
|
import webtest
|
||||||
|
|
||||||
from barbican.api import app
|
from barbican.api import app
|
||||||
@ -132,7 +131,7 @@ class WhenGettingTransKeysListUsingTransportKeysResource(FunctionalTest):
|
|||||||
|
|
||||||
self.tkeys = [create_transport_key(
|
self.tkeys = [create_transport_key(
|
||||||
id_ref='id' + str(tkid), **tk_params)
|
id_ref='id' + str(tkid), **tk_params)
|
||||||
for tkid in moves.range(self.num_keys)]
|
for tkid in range(self.num_keys)]
|
||||||
self.total = len(self.tkeys)
|
self.total = len(self.tkeys)
|
||||||
self.repo = mock.MagicMock()
|
self.repo = mock.MagicMock()
|
||||||
self.repo.get_by_create_date.return_value = (self.tkeys,
|
self.repo.get_by_create_date.return_value = (self.tkeys,
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import six
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from barbican.common import exception as excep
|
from barbican.common import exception as excep
|
||||||
@ -234,10 +233,10 @@ class WhenTestingQuotaEnforcingFunctions(database_utils.RepositoryTestCase):
|
|||||||
quota_enforcer.enforce,
|
quota_enforcer.enforce,
|
||||||
self.project
|
self.project
|
||||||
)
|
)
|
||||||
self.assertIn('Quota reached for project', six.text_type(exception))
|
self.assertIn('Quota reached for project', str(exception))
|
||||||
self.assertIn('my_keystone_id', six.text_type(exception))
|
self.assertIn('my_keystone_id', str(exception))
|
||||||
self.assertIn('secrets', six.text_type(exception))
|
self.assertIn('secrets', str(exception))
|
||||||
self.assertIn(str(0), six.text_type(exception))
|
self.assertIn(str(0), str(exception))
|
||||||
|
|
||||||
def test_should_pass_below_limit(self):
|
def test_should_pass_below_limit(self):
|
||||||
test_repo = DummyRepoForTestingQuotaEnforcement(4)
|
test_repo = DummyRepoForTestingQuotaEnforcement(4)
|
||||||
@ -262,10 +261,10 @@ class WhenTestingQuotaEnforcingFunctions(database_utils.RepositoryTestCase):
|
|||||||
quota_enforcer.enforce,
|
quota_enforcer.enforce,
|
||||||
self.project
|
self.project
|
||||||
)
|
)
|
||||||
self.assertIn('Quota reached for project', six.text_type(exception))
|
self.assertIn('Quota reached for project', str(exception))
|
||||||
self.assertIn('my_keystone_id', six.text_type(exception))
|
self.assertIn('my_keystone_id', str(exception))
|
||||||
self.assertIn('secrets', six.text_type(exception))
|
self.assertIn('secrets', str(exception))
|
||||||
self.assertIn(str(5), six.text_type(exception))
|
self.assertIn(str(5), str(exception))
|
||||||
|
|
||||||
def test_should_raise_above_limit(self):
|
def test_should_raise_above_limit(self):
|
||||||
test_repo = DummyRepoForTestingQuotaEnforcement(6)
|
test_repo = DummyRepoForTestingQuotaEnforcement(6)
|
||||||
@ -280,10 +279,10 @@ class WhenTestingQuotaEnforcingFunctions(database_utils.RepositoryTestCase):
|
|||||||
quota_enforcer.enforce,
|
quota_enforcer.enforce,
|
||||||
self.project
|
self.project
|
||||||
)
|
)
|
||||||
self.assertIn('Quota reached for project', six.text_type(exception))
|
self.assertIn('Quota reached for project', str(exception))
|
||||||
self.assertIn('my_keystone_id', six.text_type(exception))
|
self.assertIn('my_keystone_id', str(exception))
|
||||||
self.assertIn('secrets', six.text_type(exception))
|
self.assertIn('secrets', str(exception))
|
||||||
self.assertIn(str(5), six.text_type(exception))
|
self.assertIn(str(5), str(exception))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -12,10 +12,10 @@
|
|||||||
# implied.
|
# implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
import builtins
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
import six
|
|
||||||
|
|
||||||
from barbican.common import config
|
from barbican.common import config
|
||||||
from barbican.common import utils
|
from barbican.common import utils
|
||||||
@ -157,7 +157,7 @@ class WhenTestingGenerateFullClassnameForInstance(test_utils.BaseTestCase):
|
|||||||
test_string = "foo"
|
test_string = "foo"
|
||||||
fullname = utils.generate_fullname_for(test_string)
|
fullname = utils.generate_fullname_for(test_string)
|
||||||
self.assertEqual(0, fullname.count("."))
|
self.assertEqual(0, fullname.count("."))
|
||||||
self.assertNotIn(six.moves.builtins.__name__, fullname)
|
self.assertNotIn(builtins.__name__, fullname)
|
||||||
|
|
||||||
def test_returns_class_name_on_null_module(self):
|
def test_returns_class_name_on_null_module(self):
|
||||||
self.instance.__class__.__module__ = None
|
self.instance.__class__.__module__ = None
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import six
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from oslo_serialization import base64
|
from oslo_serialization import base64
|
||||||
@ -242,7 +241,7 @@ class WhenTestingSecretValidator(utils.BaseTestCase):
|
|||||||
self.secret_req,
|
self.secret_req,
|
||||||
)
|
)
|
||||||
self.assertEqual('bit_length', exception.invalid_property)
|
self.assertEqual('bit_length', exception.invalid_property)
|
||||||
self.assertIn('bit_length', six.text_type(exception))
|
self.assertIn('bit_length', str(exception))
|
||||||
|
|
||||||
def test_should_raise_non_integer_bit_length(self):
|
def test_should_raise_non_integer_bit_length(self):
|
||||||
self.secret_req['bit_length'] = "23"
|
self.secret_req['bit_length'] = "23"
|
||||||
@ -253,7 +252,7 @@ class WhenTestingSecretValidator(utils.BaseTestCase):
|
|||||||
self.secret_req,
|
self.secret_req,
|
||||||
)
|
)
|
||||||
self.assertEqual('bit_length', exception.invalid_property)
|
self.assertEqual('bit_length', exception.invalid_property)
|
||||||
self.assertIn('bit_length', six.text_type(exception))
|
self.assertIn('bit_length', str(exception))
|
||||||
|
|
||||||
def test_should_raise_bit_length_less_than_min(self):
|
def test_should_raise_bit_length_less_than_min(self):
|
||||||
self.secret_req['bit_length'] = 0
|
self.secret_req['bit_length'] = 0
|
||||||
@ -264,7 +263,7 @@ class WhenTestingSecretValidator(utils.BaseTestCase):
|
|||||||
self.secret_req,
|
self.secret_req,
|
||||||
)
|
)
|
||||||
self.assertEqual('bit_length', exception.invalid_property)
|
self.assertEqual('bit_length', exception.invalid_property)
|
||||||
self.assertIn('bit_length', six.text_type(exception))
|
self.assertIn('bit_length', str(exception))
|
||||||
|
|
||||||
def test_should_raise_bit_length_greater_than_max(self):
|
def test_should_raise_bit_length_greater_than_max(self):
|
||||||
self.secret_req['bit_length'] = 32768
|
self.secret_req['bit_length'] = 32768
|
||||||
@ -275,7 +274,7 @@ class WhenTestingSecretValidator(utils.BaseTestCase):
|
|||||||
self.secret_req,
|
self.secret_req,
|
||||||
)
|
)
|
||||||
self.assertEqual('bit_length', exception.invalid_property)
|
self.assertEqual('bit_length', exception.invalid_property)
|
||||||
self.assertIn('bit_length', six.text_type(exception))
|
self.assertIn('bit_length', str(exception))
|
||||||
|
|
||||||
def test_should_raise_mode_length_greater_than_max(self):
|
def test_should_raise_mode_length_greater_than_max(self):
|
||||||
self.secret_req['mode'] = 'a' * 256
|
self.secret_req['mode'] = 'a' * 256
|
||||||
@ -286,7 +285,7 @@ class WhenTestingSecretValidator(utils.BaseTestCase):
|
|||||||
self.secret_req,
|
self.secret_req,
|
||||||
)
|
)
|
||||||
self.assertEqual('mode', exception.invalid_property)
|
self.assertEqual('mode', exception.invalid_property)
|
||||||
self.assertIn('mode', six.text_type(exception))
|
self.assertIn('mode', str(exception))
|
||||||
|
|
||||||
def test_should_raise_mode_is_non_string(self):
|
def test_should_raise_mode_is_non_string(self):
|
||||||
self.secret_req['mode'] = 123
|
self.secret_req['mode'] = 123
|
||||||
@ -297,7 +296,7 @@ class WhenTestingSecretValidator(utils.BaseTestCase):
|
|||||||
self.secret_req,
|
self.secret_req,
|
||||||
)
|
)
|
||||||
self.assertEqual('mode', exception.invalid_property)
|
self.assertEqual('mode', exception.invalid_property)
|
||||||
self.assertIn('mode', six.text_type(exception))
|
self.assertIn('mode', str(exception))
|
||||||
|
|
||||||
def test_validation_should_raise_with_empty_payload(self):
|
def test_validation_should_raise_with_empty_payload(self):
|
||||||
self.secret_req['payload'] = ' '
|
self.secret_req['payload'] = ' '
|
||||||
@ -308,7 +307,7 @@ class WhenTestingSecretValidator(utils.BaseTestCase):
|
|||||||
self.secret_req,
|
self.secret_req,
|
||||||
)
|
)
|
||||||
self.assertEqual('payload', exception.invalid_property)
|
self.assertEqual('payload', exception.invalid_property)
|
||||||
self.assertIn('payload', six.text_type(exception))
|
self.assertIn('payload', str(exception))
|
||||||
|
|
||||||
def test_should_raise_already_expired(self):
|
def test_should_raise_already_expired(self):
|
||||||
self.secret_req['expiration'] = '2004-02-28T19:14:44.180394'
|
self.secret_req['expiration'] = '2004-02-28T19:14:44.180394'
|
||||||
@ -319,7 +318,7 @@ class WhenTestingSecretValidator(utils.BaseTestCase):
|
|||||||
self.secret_req,
|
self.secret_req,
|
||||||
)
|
)
|
||||||
self.assertEqual('expiration', exception.invalid_property)
|
self.assertEqual('expiration', exception.invalid_property)
|
||||||
self.assertIn('expiration', six.text_type(exception))
|
self.assertIn('expiration', str(exception))
|
||||||
|
|
||||||
def test_should_raise_expiration_nonsense(self):
|
def test_should_raise_expiration_nonsense(self):
|
||||||
self.secret_req['expiration'] = 'nonsense'
|
self.secret_req['expiration'] = 'nonsense'
|
||||||
@ -330,7 +329,7 @@ class WhenTestingSecretValidator(utils.BaseTestCase):
|
|||||||
self.secret_req,
|
self.secret_req,
|
||||||
)
|
)
|
||||||
self.assertEqual('expiration', exception.invalid_property)
|
self.assertEqual('expiration', exception.invalid_property)
|
||||||
self.assertIn('expiration', six.text_type(exception))
|
self.assertIn('expiration', str(exception))
|
||||||
|
|
||||||
def test_should_raise_expiration_is_non_string(self):
|
def test_should_raise_expiration_is_non_string(self):
|
||||||
self.secret_req['expiration'] = 123
|
self.secret_req['expiration'] = 123
|
||||||
@ -341,7 +340,7 @@ class WhenTestingSecretValidator(utils.BaseTestCase):
|
|||||||
self.secret_req,
|
self.secret_req,
|
||||||
)
|
)
|
||||||
self.assertEqual('expiration', exception.invalid_property)
|
self.assertEqual('expiration', exception.invalid_property)
|
||||||
self.assertIn('expiration', six.text_type(exception))
|
self.assertIn('expiration', str(exception))
|
||||||
|
|
||||||
def test_should_raise_expiration_greater_than_max(self):
|
def test_should_raise_expiration_greater_than_max(self):
|
||||||
self.secret_req['expiration'] = 'a' * 256
|
self.secret_req['expiration'] = 'a' * 256
|
||||||
@ -352,7 +351,7 @@ class WhenTestingSecretValidator(utils.BaseTestCase):
|
|||||||
self.secret_req,
|
self.secret_req,
|
||||||
)
|
)
|
||||||
self.assertEqual('expiration', exception.invalid_property)
|
self.assertEqual('expiration', exception.invalid_property)
|
||||||
self.assertIn('expiration', six.text_type(exception))
|
self.assertIn('expiration', str(exception))
|
||||||
|
|
||||||
def test_should_raise_algorithm_is_non_string(self):
|
def test_should_raise_algorithm_is_non_string(self):
|
||||||
self.secret_req['algorithm'] = 123
|
self.secret_req['algorithm'] = 123
|
||||||
@ -363,7 +362,7 @@ class WhenTestingSecretValidator(utils.BaseTestCase):
|
|||||||
self.secret_req,
|
self.secret_req,
|
||||||
)
|
)
|
||||||
self.assertEqual('algorithm', exception.invalid_property)
|
self.assertEqual('algorithm', exception.invalid_property)
|
||||||
self.assertIn('algorithm', six.text_type(exception))
|
self.assertIn('algorithm', str(exception))
|
||||||
|
|
||||||
def test_should_raise_algorithm_greater_than_max(self):
|
def test_should_raise_algorithm_greater_than_max(self):
|
||||||
self.secret_req['algorithm'] = 'a' * 256
|
self.secret_req['algorithm'] = 'a' * 256
|
||||||
@ -374,7 +373,7 @@ class WhenTestingSecretValidator(utils.BaseTestCase):
|
|||||||
self.secret_req,
|
self.secret_req,
|
||||||
)
|
)
|
||||||
self.assertEqual('algorithm', exception.invalid_property)
|
self.assertEqual('algorithm', exception.invalid_property)
|
||||||
self.assertIn('algorithm', six.text_type(exception))
|
self.assertIn('algorithm', str(exception))
|
||||||
|
|
||||||
def test_should_raise_all_nulls(self):
|
def test_should_raise_all_nulls(self):
|
||||||
self.secret_req = {'name': None,
|
self.secret_req = {'name': None,
|
||||||
@ -416,7 +415,7 @@ class WhenTestingSecretValidator(utils.BaseTestCase):
|
|||||||
self.validator.validate(self.secret_req)
|
self.validator.validate(self.secret_req)
|
||||||
except excep.InvalidObject as e:
|
except excep.InvalidObject as e:
|
||||||
self.assertIsNotNone(e)
|
self.assertIsNotNone(e)
|
||||||
self.assertIsNotNone(six.text_type(e))
|
self.assertIsNotNone(str(e))
|
||||||
else:
|
else:
|
||||||
self.fail('No validation exception was raised')
|
self.fail('No validation exception was raised')
|
||||||
|
|
||||||
@ -454,7 +453,7 @@ class WhenTestingSecretValidator(utils.BaseTestCase):
|
|||||||
self.secret_req,
|
self.secret_req,
|
||||||
)
|
)
|
||||||
self.assertEqual('payload_content_type', exception.invalid_property)
|
self.assertEqual('payload_content_type', exception.invalid_property)
|
||||||
self.assertIn('payload_content_type', six.text_type(exception))
|
self.assertIn('payload_content_type', str(exception))
|
||||||
|
|
||||||
def test_should_raise_with_payload_content_encoding_greater_than_max(self):
|
def test_should_raise_with_payload_content_encoding_greater_than_max(self):
|
||||||
self.secret_req['payload_content_encoding'] = 'a' * 256
|
self.secret_req['payload_content_encoding'] = 'a' * 256
|
||||||
@ -465,7 +464,7 @@ class WhenTestingSecretValidator(utils.BaseTestCase):
|
|||||||
)
|
)
|
||||||
self.assertEqual('payload_content_encoding',
|
self.assertEqual('payload_content_encoding',
|
||||||
exception.invalid_property)
|
exception.invalid_property)
|
||||||
self.assertIn('payload_content_encoding', six.text_type(exception))
|
self.assertIn('payload_content_encoding', str(exception))
|
||||||
|
|
||||||
def test_should_raise_with_plain_text_and_encoding(self):
|
def test_should_raise_with_plain_text_and_encoding(self):
|
||||||
self.secret_req['payload_content_encoding'] = 'base64'
|
self.secret_req['payload_content_encoding'] = 'base64'
|
||||||
@ -515,7 +514,7 @@ class WhenTestingSecretValidator(utils.BaseTestCase):
|
|||||||
def test_validation_should_raise_with_unicode_payload(self):
|
def test_validation_should_raise_with_unicode_payload(self):
|
||||||
self.secret_req['payload_content_type'] = 'application/octet-stream'
|
self.secret_req['payload_content_type'] = 'application/octet-stream'
|
||||||
self.secret_req['payload_content_encoding'] = 'base64'
|
self.secret_req['payload_content_encoding'] = 'base64'
|
||||||
self.secret_req['payload'] = six.unichr(0x0080)
|
self.secret_req['payload'] = chr(0x0080)
|
||||||
|
|
||||||
exception = self.assertRaises(
|
exception = self.assertRaises(
|
||||||
excep.InvalidObject,
|
excep.InvalidObject,
|
||||||
@ -624,7 +623,7 @@ class WhenTestingContainerValidator(utils.BaseTestCase):
|
|||||||
self.container_req,
|
self.container_req,
|
||||||
)
|
)
|
||||||
self.assertEqual('name', exception.invalid_property)
|
self.assertEqual('name', exception.invalid_property)
|
||||||
self.assertIn('name', six.text_type(exception))
|
self.assertIn('name', str(exception))
|
||||||
|
|
||||||
def test_should_raise_nonstring_secret_name(self):
|
def test_should_raise_nonstring_secret_name(self):
|
||||||
self.secret_refs[0]["name"] = 5
|
self.secret_refs[0]["name"] = 5
|
||||||
@ -668,7 +667,7 @@ class WhenTestingContainerValidator(utils.BaseTestCase):
|
|||||||
self.container_req,
|
self.container_req,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertIn('type', six.text_type(exception))
|
self.assertIn('type', str(exception))
|
||||||
|
|
||||||
def test_should_raise_empty_type(self):
|
def test_should_raise_empty_type(self):
|
||||||
self.container_req['type'] = ''
|
self.container_req['type'] = ''
|
||||||
@ -1258,7 +1257,7 @@ class WhenTestingKeyTypeOrderValidator(utils.BaseTestCase):
|
|||||||
self.validator.validate,
|
self.validator.validate,
|
||||||
self.key_order_req)
|
self.key_order_req)
|
||||||
self.assertIn("bit_length' is required field for key type order",
|
self.assertIn("bit_length' is required field for key type order",
|
||||||
six.text_type(exception))
|
str(exception))
|
||||||
|
|
||||||
def test_should_raise_with_zero_bit_length_in_order_refs(self):
|
def test_should_raise_with_zero_bit_length_in_order_refs(self):
|
||||||
self.key_order_req['meta']['bit_length'] = 0
|
self.key_order_req['meta']['bit_length'] = 0
|
||||||
@ -1347,7 +1346,7 @@ class WhenTestingAsymmetricTypeOrderValidator(utils.BaseTestCase):
|
|||||||
self.asymmetric_order_req)
|
self.asymmetric_order_req)
|
||||||
self.assertIn(
|
self.assertIn(
|
||||||
"bit_length' is required field for asymmetric key type order",
|
"bit_length' is required field for asymmetric key type order",
|
||||||
six.text_type(exception))
|
str(exception))
|
||||||
|
|
||||||
def test_should_raise_with_zero_bit_length_in_asymmetric_order_refs(self):
|
def test_should_raise_with_zero_bit_length_in_asymmetric_order_refs(self):
|
||||||
self.asymmetric_order_req['meta']['bit_length'] = 0
|
self.asymmetric_order_req['meta']['bit_length'] = 0
|
||||||
@ -1814,7 +1813,7 @@ class WhenTestingSecretMetadataValidator(utils.BaseTestCase):
|
|||||||
self.validator.validate,
|
self.validator.validate,
|
||||||
self.metadata_req)
|
self.metadata_req)
|
||||||
self.assertIn("metadata' is a required property",
|
self.assertIn("metadata' is a required property",
|
||||||
six.text_type(exception))
|
str(exception))
|
||||||
|
|
||||||
def test_should_raise_invalid_key_non_string(self):
|
def test_should_raise_invalid_key_non_string(self):
|
||||||
self.key1 = 0
|
self.key1 = 0
|
||||||
@ -1827,7 +1826,7 @@ class WhenTestingSecretMetadataValidator(utils.BaseTestCase):
|
|||||||
self.validator.validate,
|
self.validator.validate,
|
||||||
metadata_req)
|
metadata_req)
|
||||||
self.assertIn("Invalid Metadata. Keys and Values must be Strings.",
|
self.assertIn("Invalid Metadata. Keys and Values must be Strings.",
|
||||||
six.text_type(exception))
|
str(exception))
|
||||||
|
|
||||||
def test_should_raise_invalid_key_non_url_safe_string(self):
|
def test_should_raise_invalid_key_non_url_safe_string(self):
|
||||||
self.key1 = "key/01"
|
self.key1 = "key/01"
|
||||||
@ -1840,7 +1839,7 @@ class WhenTestingSecretMetadataValidator(utils.BaseTestCase):
|
|||||||
self.validator.validate,
|
self.validator.validate,
|
||||||
metadata_req)
|
metadata_req)
|
||||||
self.assertIn("Invalid Key. Key must be URL safe.",
|
self.assertIn("Invalid Key. Key must be URL safe.",
|
||||||
six.text_type(exception))
|
str(exception))
|
||||||
|
|
||||||
def test_should_raise_invalid_value_non_string(self):
|
def test_should_raise_invalid_value_non_string(self):
|
||||||
self.value1 = 0
|
self.value1 = 0
|
||||||
@ -1853,7 +1852,7 @@ class WhenTestingSecretMetadataValidator(utils.BaseTestCase):
|
|||||||
self.validator.validate,
|
self.validator.validate,
|
||||||
metadata_req)
|
metadata_req)
|
||||||
self.assertIn("Invalid Metadata. Keys and Values must be Strings.",
|
self.assertIn("Invalid Metadata. Keys and Values must be Strings.",
|
||||||
six.text_type(exception))
|
str(exception))
|
||||||
|
|
||||||
|
|
||||||
@utils.parameterized_test_case
|
@utils.parameterized_test_case
|
||||||
@ -1896,7 +1895,7 @@ class WhenTestingSecretMetadatumValidator(utils.BaseTestCase):
|
|||||||
self.metadata_req)
|
self.metadata_req)
|
||||||
self.assertIn("Provided object does not match schema "
|
self.assertIn("Provided object does not match schema "
|
||||||
"'SecretMetadatum'",
|
"'SecretMetadatum'",
|
||||||
six.text_type(exception))
|
str(exception))
|
||||||
|
|
||||||
def test_should_raise_invalid_key_no_key(self):
|
def test_should_raise_invalid_key_no_key(self):
|
||||||
del self.metadata_req[self.key2]
|
del self.metadata_req[self.key2]
|
||||||
@ -1905,7 +1904,7 @@ class WhenTestingSecretMetadatumValidator(utils.BaseTestCase):
|
|||||||
self.metadata_req)
|
self.metadata_req)
|
||||||
self.assertIn("Provided object does not match schema "
|
self.assertIn("Provided object does not match schema "
|
||||||
"'SecretMetadatum'",
|
"'SecretMetadatum'",
|
||||||
six.text_type(exception))
|
str(exception))
|
||||||
|
|
||||||
def test_should_raise_invalid_key_no_value(self):
|
def test_should_raise_invalid_key_no_value(self):
|
||||||
del self.metadata_req[self.key1]
|
del self.metadata_req[self.key1]
|
||||||
@ -1914,7 +1913,7 @@ class WhenTestingSecretMetadatumValidator(utils.BaseTestCase):
|
|||||||
self.metadata_req)
|
self.metadata_req)
|
||||||
self.assertIn("Provided object does not match schema "
|
self.assertIn("Provided object does not match schema "
|
||||||
"'SecretMetadatum'",
|
"'SecretMetadatum'",
|
||||||
six.text_type(exception))
|
str(exception))
|
||||||
|
|
||||||
def test_should_raise_invalid_key_non_string(self):
|
def test_should_raise_invalid_key_non_string(self):
|
||||||
self.value1 = 0
|
self.value1 = 0
|
||||||
@ -1928,7 +1927,7 @@ class WhenTestingSecretMetadatumValidator(utils.BaseTestCase):
|
|||||||
metadata_req)
|
metadata_req)
|
||||||
self.assertIn("Provided object does not match schema "
|
self.assertIn("Provided object does not match schema "
|
||||||
"'SecretMetadatum'",
|
"'SecretMetadatum'",
|
||||||
six.text_type(exception))
|
str(exception))
|
||||||
|
|
||||||
def test_should_raise_invalid_key_non_url_safe_string(self):
|
def test_should_raise_invalid_key_non_url_safe_string(self):
|
||||||
self.value1 = "key/01"
|
self.value1 = "key/01"
|
||||||
@ -1941,7 +1940,7 @@ class WhenTestingSecretMetadatumValidator(utils.BaseTestCase):
|
|||||||
self.validator.validate,
|
self.validator.validate,
|
||||||
metadata_req)
|
metadata_req)
|
||||||
self.assertIn("Invalid Key. Key must be URL safe.",
|
self.assertIn("Invalid Key. Key must be URL safe.",
|
||||||
six.text_type(exception))
|
str(exception))
|
||||||
|
|
||||||
def test_should_raise_invalid_value_non_string(self):
|
def test_should_raise_invalid_value_non_string(self):
|
||||||
self.value2 = 0
|
self.value2 = 0
|
||||||
@ -1955,7 +1954,7 @@ class WhenTestingSecretMetadatumValidator(utils.BaseTestCase):
|
|||||||
metadata_req)
|
metadata_req)
|
||||||
self.assertIn("Provided object does not match schema "
|
self.assertIn("Provided object does not match schema "
|
||||||
"'SecretMetadatum'",
|
"'SecretMetadatum'",
|
||||||
six.text_type(exception))
|
str(exception))
|
||||||
|
|
||||||
def test_should_raise_invalid_extra_sent_key(self):
|
def test_should_raise_invalid_extra_sent_key(self):
|
||||||
self.value2 = 0
|
self.value2 = 0
|
||||||
@ -1970,7 +1969,7 @@ class WhenTestingSecretMetadatumValidator(utils.BaseTestCase):
|
|||||||
metadata_req)
|
metadata_req)
|
||||||
self.assertIn("Provided object does not match schema "
|
self.assertIn("Provided object does not match schema "
|
||||||
"'SecretMetadatum'",
|
"'SecretMetadatum'",
|
||||||
six.text_type(exception))
|
str(exception))
|
||||||
|
|
||||||
|
|
||||||
class WhenTestingSecretConsumerValidator(utils.BaseTestCase):
|
class WhenTestingSecretConsumerValidator(utils.BaseTestCase):
|
||||||
|
@ -14,7 +14,6 @@ from unittest import mock
|
|||||||
|
|
||||||
from alembic import script as alembic_script
|
from alembic import script as alembic_script
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
import six
|
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
|
|
||||||
from barbican.common import config
|
from barbican.common import config
|
||||||
@ -120,7 +119,7 @@ class WhenInvokingExceptionMethods(utils.BaseTestCase):
|
|||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
"No test_entity found with ID 123456",
|
"No test_entity found with ID 123456",
|
||||||
six.text_type(exception_result))
|
str(exception_result))
|
||||||
|
|
||||||
def test_should_raise_for_entity_id_not_found(self):
|
def test_should_raise_for_entity_id_not_found(self):
|
||||||
|
|
||||||
@ -131,7 +130,7 @@ class WhenInvokingExceptionMethods(utils.BaseTestCase):
|
|||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
"Entity ID 123456 not found",
|
"Entity ID 123456 not found",
|
||||||
six.text_type(exception_result))
|
str(exception_result))
|
||||||
|
|
||||||
def test_should_raise_for_no_entities_found(self):
|
def test_should_raise_for_no_entities_found(self):
|
||||||
|
|
||||||
@ -142,7 +141,7 @@ class WhenInvokingExceptionMethods(utils.BaseTestCase):
|
|||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
"No entities of type test_entity found",
|
"No entities of type test_entity found",
|
||||||
six.text_type(exception_result))
|
str(exception_result))
|
||||||
|
|
||||||
|
|
||||||
class WhenTestingBaseRepository(database_utils.RepositoryTestCase):
|
class WhenTestingBaseRepository(database_utils.RepositoryTestCase):
|
||||||
@ -159,7 +158,7 @@ class WhenTestingBaseRepository(database_utils.RepositoryTestCase):
|
|||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
"Must supply non-None Entity.",
|
"Must supply non-None Entity.",
|
||||||
six.text_type(exception_result))
|
str(exception_result))
|
||||||
|
|
||||||
def test_should_raise_invalid_create_from_entity_with_id(self):
|
def test_should_raise_invalid_create_from_entity_with_id(self):
|
||||||
entity = models.ModelBase()
|
entity = models.ModelBase()
|
||||||
@ -172,7 +171,7 @@ class WhenTestingBaseRepository(database_utils.RepositoryTestCase):
|
|||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
"Must supply Entity with id=None (i.e. new entity).",
|
"Must supply Entity with id=None (i.e. new entity).",
|
||||||
six.text_type(exception_result))
|
str(exception_result))
|
||||||
|
|
||||||
def test_should_raise_invalid_do_validate_no_status(self):
|
def test_should_raise_invalid_do_validate_no_status(self):
|
||||||
exception_result = self.assertRaises(
|
exception_result = self.assertRaises(
|
||||||
@ -182,7 +181,7 @@ class WhenTestingBaseRepository(database_utils.RepositoryTestCase):
|
|||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
"Entity status is required.",
|
"Entity status is required.",
|
||||||
six.text_type(exception_result))
|
str(exception_result))
|
||||||
|
|
||||||
def test_should_raise_invalid_do_validate_bad_status(self):
|
def test_should_raise_invalid_do_validate_bad_status(self):
|
||||||
exception_result = self.assertRaises(
|
exception_result = self.assertRaises(
|
||||||
@ -192,7 +191,7 @@ class WhenTestingBaseRepository(database_utils.RepositoryTestCase):
|
|||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
"Invalid status 'BOGUS_STATUS' for Entity.",
|
"Invalid status 'BOGUS_STATUS' for Entity.",
|
||||||
six.text_type(exception_result))
|
str(exception_result))
|
||||||
|
|
||||||
|
|
||||||
class WhenTestingWrapDbError(utils.BaseTestCase):
|
class WhenTestingWrapDbError(utils.BaseTestCase):
|
||||||
@ -239,7 +238,7 @@ class WhenTestingGetEnginePrivate(utils.BaseTestCase):
|
|||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'Error configuring registry database with supplied '
|
'Error configuring registry database with supplied '
|
||||||
'sql_connection. Got error: Abort!',
|
'sql_connection. Got error: Abort!',
|
||||||
six.text_type(exception_result))
|
str(exception_result))
|
||||||
|
|
||||||
@mock.patch('barbican.model.repositories._create_engine')
|
@mock.patch('barbican.model.repositories._create_engine')
|
||||||
def test_should_complete_with_no_alembic_create_default_configs(
|
def test_should_complete_with_no_alembic_create_default_configs(
|
||||||
|
@ -9,8 +9,6 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
import six
|
|
||||||
|
|
||||||
from barbican.common import exception
|
from barbican.common import exception
|
||||||
from barbican.model import models
|
from barbican.model import models
|
||||||
from barbican.model import repositories
|
from barbican.model import repositories
|
||||||
@ -89,7 +87,7 @@ class WhenTestingContainerConsumerRepository(utils.RepositoryTestCase):
|
|||||||
session=session)
|
session=session)
|
||||||
self.assertIn(
|
self.assertIn(
|
||||||
"SQL constraint check failed",
|
"SQL constraint check failed",
|
||||||
six.text_type(exception_result))
|
str(exception_result))
|
||||||
|
|
||||||
def test_should_raise_no_result_found_get_container_id(self):
|
def test_should_raise_no_result_found_get_container_id(self):
|
||||||
session = self.repo.get_session()
|
session = self.repo.get_session()
|
||||||
|
@ -11,8 +11,6 @@
|
|||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
import six
|
|
||||||
|
|
||||||
from barbican.common import exception
|
from barbican.common import exception
|
||||||
from barbican.model import models
|
from barbican.model import models
|
||||||
from barbican.model import repositories
|
from barbican.model import repositories
|
||||||
@ -119,7 +117,7 @@ class WhenTestingSecretConsumerRepository(utils.RepositoryTestCase):
|
|||||||
exception.ConstraintCheck, self._create_consumer
|
exception.ConstraintCheck, self._create_consumer
|
||||||
)
|
)
|
||||||
self.assertIn(
|
self.assertIn(
|
||||||
"SQL constraint check failed", six.text_type(exception_result)
|
"SQL constraint check failed", str(exception_result)
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_should_get_count_zero(self):
|
def test_should_get_count_zero(self):
|
||||||
|
@ -15,7 +15,6 @@ from barbican.common import exception
|
|||||||
from barbican.model import models
|
from barbican.model import models
|
||||||
from barbican.model import repositories
|
from barbican.model import repositories
|
||||||
from barbican.tests import database_utils
|
from barbican.tests import database_utils
|
||||||
import six
|
|
||||||
|
|
||||||
|
|
||||||
class WhenTestingSecretStoresRepo(database_utils.RepositoryTestCase):
|
class WhenTestingSecretStoresRepo(database_utils.RepositoryTestCase):
|
||||||
@ -171,7 +170,7 @@ class WhenTestingSecretStoresRepo(database_utils.RepositoryTestCase):
|
|||||||
self._create_secret_store(name, store_plugin, crypto_plugin, False)
|
self._create_secret_store(name, store_plugin, crypto_plugin, False)
|
||||||
self.assertFail()
|
self.assertFail()
|
||||||
except exception.ConstraintCheck as ex:
|
except exception.ConstraintCheck as ex:
|
||||||
self.assertIn("SQL constraint check failed", six.text_type(ex))
|
self.assertIn("SQL constraint check failed", str(ex))
|
||||||
|
|
||||||
|
|
||||||
class WhenTestingProjectSecretStoreRepo(database_utils.RepositoryTestCase):
|
class WhenTestingProjectSecretStoreRepo(database_utils.RepositoryTestCase):
|
||||||
@ -315,7 +314,7 @@ class WhenTestingProjectSecretStoreRepo(database_utils.RepositoryTestCase):
|
|||||||
self._create_project_store(project1.id, s_store2.id)
|
self._create_project_store(project1.id, s_store2.id)
|
||||||
self.assertFail()
|
self.assertFail()
|
||||||
except exception.ConstraintCheck as ex:
|
except exception.ConstraintCheck as ex:
|
||||||
self.assertIn("SQL constraint check failed", six.text_type(ex))
|
self.assertIn("SQL constraint check failed", str(ex))
|
||||||
|
|
||||||
def test_get_secret_store_for_project(self):
|
def test_get_secret_store_for_project(self):
|
||||||
project1 = self._create_project()
|
project1 = self._create_project()
|
||||||
|
@ -11,8 +11,6 @@
|
|||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
import six
|
|
||||||
|
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
|
|
||||||
from barbican.common import exception
|
from barbican.common import exception
|
||||||
@ -150,7 +148,7 @@ class TestProjectSecretStore(test_ovo_base.OVOTestCase):
|
|||||||
self._create_project_secret_store(project1.id, secret_stores2.id)
|
self._create_project_secret_store(project1.id, secret_stores2.id)
|
||||||
self.assertFail()
|
self.assertFail()
|
||||||
except exception.ConstraintCheck as ex:
|
except exception.ConstraintCheck as ex:
|
||||||
self.assertIn("SQL constraint check failed", six.text_type(ex))
|
self.assertIn("SQL constraint check failed", str(ex))
|
||||||
|
|
||||||
def test_ovo_get_secret_store_for_project(self):
|
def test_ovo_get_secret_store_for_project(self):
|
||||||
project1 = self._create_project()
|
project1 = self._create_project()
|
||||||
|
@ -19,7 +19,6 @@ from unittest import mock
|
|||||||
from cryptography import fernet
|
from cryptography import fernet
|
||||||
from cryptography.hazmat.backends import default_backend
|
from cryptography.hazmat.backends import default_backend
|
||||||
from cryptography.hazmat.primitives import serialization
|
from cryptography.hazmat.primitives import serialization
|
||||||
import six
|
|
||||||
|
|
||||||
from barbican.model import models
|
from barbican.model import models
|
||||||
from barbican.plugin.crypto import base as plugin
|
from barbican.plugin.crypto import base as plugin
|
||||||
@ -68,7 +67,7 @@ class WhenTestingSimpleCryptoPlugin(utils.BaseTestCase):
|
|||||||
project_kek = fernet.Fernet.generate_key()
|
project_kek = fernet.Fernet.generate_key()
|
||||||
encryptor = fernet.Fernet(self.plugin.master_kek)
|
encryptor = fernet.Fernet(self.plugin.master_kek)
|
||||||
ENC_project_kek = encryptor.encrypt(project_kek)
|
ENC_project_kek = encryptor.encrypt(project_kek)
|
||||||
UENC_project_kek = six.u(ENC_project_kek)
|
UENC_project_kek = ENC_project_kek
|
||||||
kek_meta_dto = self._get_mocked_kek_meta_dto()
|
kek_meta_dto = self._get_mocked_kek_meta_dto()
|
||||||
kek_meta_dto.plugin_meta = UENC_project_kek
|
kek_meta_dto.plugin_meta = UENC_project_kek
|
||||||
|
|
||||||
|
@ -13,10 +13,9 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
import builtins
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from barbican.common import exception as ex
|
from barbican.common import exception as ex
|
||||||
from barbican.model import models
|
from barbican.model import models
|
||||||
from barbican.plugin.crypto import base as plugin_import
|
from barbican.plugin.crypto import base as plugin_import
|
||||||
@ -309,7 +308,7 @@ class WhenTestingP11CryptoPlugin(utils.BaseTestCase):
|
|||||||
d = '01234567' * 4
|
d = '01234567' * 4
|
||||||
mo = mock.mock_open(read_data=d)
|
mo = mock.mock_open(read_data=d)
|
||||||
|
|
||||||
with mock.patch(six.moves.builtins.__name__ + '.open',
|
with mock.patch(builtins.__name__ + '.open',
|
||||||
mo,
|
mo,
|
||||||
create=True):
|
create=True):
|
||||||
p11 = self.plugin._create_pkcs11(ffi)
|
p11 = self.plugin._create_pkcs11(ffi)
|
||||||
|
@ -15,19 +15,17 @@
|
|||||||
|
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from barbican.common import utils as common_utils
|
from barbican.common import utils as common_utils
|
||||||
from barbican.plugin.crypto import base
|
from barbican.plugin.crypto import base
|
||||||
from barbican.plugin.crypto import manager as cm
|
from barbican.plugin.crypto import manager as cm
|
||||||
from barbican.plugin.crypto import p11_crypto
|
from barbican.plugin.crypto import p11_crypto
|
||||||
from barbican.plugin.interface import secret_store as str
|
from barbican.plugin.interface import secret_store as ss
|
||||||
from barbican.plugin import kmip_secret_store as kss
|
from barbican.plugin import kmip_secret_store as kss
|
||||||
from barbican.plugin import store_crypto
|
from barbican.plugin import store_crypto
|
||||||
from barbican.tests import utils
|
from barbican.tests import utils
|
||||||
|
|
||||||
|
|
||||||
class TestSecretStore(str.SecretStoreBase):
|
class TestSecretStore(ss.SecretStoreBase):
|
||||||
"""Secret store plugin for testing support."""
|
"""Secret store plugin for testing support."""
|
||||||
|
|
||||||
def __init__(self, supported_alg_list):
|
def __init__(self, supported_alg_list):
|
||||||
@ -59,7 +57,7 @@ class TestSecretStore(str.SecretStoreBase):
|
|||||||
return key_spec.alg in self.alg_list
|
return key_spec.alg in self.alg_list
|
||||||
|
|
||||||
|
|
||||||
class TestSecretStoreWithTransportKey(str.SecretStoreBase):
|
class TestSecretStoreWithTransportKey(ss.SecretStoreBase):
|
||||||
"""Secret store plugin for testing support.
|
"""Secret store plugin for testing support.
|
||||||
|
|
||||||
This plugin will override the relevant methods for key wrapping.
|
This plugin will override the relevant methods for key wrapping.
|
||||||
@ -104,19 +102,19 @@ class WhenTestingSecretStorePluginManager(utils.BaseTestCase):
|
|||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(WhenTestingSecretStorePluginManager, self).setUp()
|
super(WhenTestingSecretStorePluginManager, self).setUp()
|
||||||
self.manager = str.SecretStorePluginManager()
|
self.manager = ss.SecretStorePluginManager()
|
||||||
|
|
||||||
def test_get_store_supported_plugin_no_plugin_name(self):
|
def test_get_store_supported_plugin_no_plugin_name(self):
|
||||||
plugin = TestSecretStore([str.KeyAlgorithm.AES])
|
plugin = TestSecretStore([ss.KeyAlgorithm.AES])
|
||||||
plugin_mock = mock.MagicMock(obj=plugin)
|
plugin_mock = mock.MagicMock(obj=plugin)
|
||||||
self.manager.extensions = [plugin_mock]
|
self.manager.extensions = [plugin_mock]
|
||||||
keySpec = str.KeySpec(str.KeyAlgorithm.AES, 128)
|
keySpec = ss.KeySpec(ss.KeyAlgorithm.AES, 128)
|
||||||
|
|
||||||
self.assertEqual(plugin,
|
self.assertEqual(plugin,
|
||||||
self.manager.get_plugin_store(keySpec))
|
self.manager.get_plugin_store(keySpec))
|
||||||
|
|
||||||
def test_get_store_supported_plugin_with_plugin_name(self):
|
def test_get_store_supported_plugin_with_plugin_name(self):
|
||||||
plugin = TestSecretStore([str.KeyAlgorithm.AES])
|
plugin = TestSecretStore([ss.KeyAlgorithm.AES])
|
||||||
plugin_mock = mock.MagicMock(obj=plugin)
|
plugin_mock = mock.MagicMock(obj=plugin)
|
||||||
self.manager.extensions = [plugin_mock]
|
self.manager.extensions = [plugin_mock]
|
||||||
|
|
||||||
@ -125,33 +123,33 @@ class WhenTestingSecretStorePluginManager(utils.BaseTestCase):
|
|||||||
self.assertEqual(plugin, plugin_found)
|
self.assertEqual(plugin, plugin_found)
|
||||||
|
|
||||||
def test_get_generate_supported_plugin(self):
|
def test_get_generate_supported_plugin(self):
|
||||||
plugin = TestSecretStore([str.KeyAlgorithm.AES])
|
plugin = TestSecretStore([ss.KeyAlgorithm.AES])
|
||||||
plugin_mock = mock.MagicMock(obj=plugin)
|
plugin_mock = mock.MagicMock(obj=plugin)
|
||||||
self.manager.extensions = [plugin_mock]
|
self.manager.extensions = [plugin_mock]
|
||||||
keySpec = str.KeySpec(str.KeyAlgorithm.AES, 128)
|
keySpec = ss.KeySpec(ss.KeyAlgorithm.AES, 128)
|
||||||
|
|
||||||
self.assertEqual(plugin,
|
self.assertEqual(plugin,
|
||||||
self.manager.get_plugin_generate(keySpec))
|
self.manager.get_plugin_generate(keySpec))
|
||||||
|
|
||||||
def test_get_store_no_plugin_found(self):
|
def test_get_store_no_plugin_found(self):
|
||||||
self.manager.extensions = []
|
self.manager.extensions = []
|
||||||
keySpec = str.KeySpec(str.KeyAlgorithm.AES, 128)
|
keySpec = ss.KeySpec(ss.KeyAlgorithm.AES, 128)
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
str.SecretStorePluginsNotConfigured,
|
ss.SecretStorePluginsNotConfigured,
|
||||||
self.manager.get_plugin_store,
|
self.manager.get_plugin_store,
|
||||||
keySpec,
|
keySpec,
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_get_store_no_plugin_found_by_name(self):
|
def test_get_store_no_plugin_found_by_name(self):
|
||||||
plugin = TestSecretStore([str.KeyAlgorithm.AES])
|
plugin = TestSecretStore([ss.KeyAlgorithm.AES])
|
||||||
plugin_mock = mock.MagicMock(obj=plugin)
|
plugin_mock = mock.MagicMock(obj=plugin)
|
||||||
self.manager.extensions = [plugin_mock]
|
self.manager.extensions = [plugin_mock]
|
||||||
|
|
||||||
keySpec = str.KeySpec(str.KeyAlgorithm.AES, 128)
|
keySpec = ss.KeySpec(ss.KeyAlgorithm.AES, 128)
|
||||||
plugin_name = 'plugin'
|
plugin_name = 'plugin'
|
||||||
|
|
||||||
exception_result = self.assertRaises(
|
exception_result = self.assertRaises(
|
||||||
str.SecretStorePluginNotFound,
|
ss.SecretStorePluginNotFound,
|
||||||
self.manager.get_plugin_store,
|
self.manager.get_plugin_store,
|
||||||
keySpec,
|
keySpec,
|
||||||
plugin_name=plugin_name
|
plugin_name=plugin_name
|
||||||
@ -159,13 +157,13 @@ class WhenTestingSecretStorePluginManager(utils.BaseTestCase):
|
|||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'Secret store plugin "{name}" not found.'.format(name=plugin_name),
|
'Secret store plugin "{name}" not found.'.format(name=plugin_name),
|
||||||
six.text_type(exception_result))
|
str(exception_result))
|
||||||
|
|
||||||
def test_get_generate_no_plugin_found(self):
|
def test_get_generate_no_plugin_found(self):
|
||||||
self.manager.extensions = []
|
self.manager.extensions = []
|
||||||
keySpec = str.KeySpec(str.KeyAlgorithm.AES, 128)
|
keySpec = ss.KeySpec(ss.KeyAlgorithm.AES, 128)
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
str.SecretStorePluginsNotConfigured,
|
ss.SecretStorePluginsNotConfigured,
|
||||||
self.manager.get_plugin_generate,
|
self.manager.get_plugin_generate,
|
||||||
keySpec,
|
keySpec,
|
||||||
)
|
)
|
||||||
@ -174,9 +172,9 @@ class WhenTestingSecretStorePluginManager(utils.BaseTestCase):
|
|||||||
plugin = TestSecretStore([])
|
plugin = TestSecretStore([])
|
||||||
plugin_mock = mock.MagicMock(obj=plugin)
|
plugin_mock = mock.MagicMock(obj=plugin)
|
||||||
self.manager.extensions = [plugin_mock]
|
self.manager.extensions = [plugin_mock]
|
||||||
keySpec = str.KeySpec(str.KeyAlgorithm.AES, 128)
|
keySpec = ss.KeySpec(ss.KeyAlgorithm.AES, 128)
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
str.SecretStoreSupportedPluginNotFound,
|
ss.SecretStoreSupportedPluginNotFound,
|
||||||
self.manager.get_plugin_store,
|
self.manager.get_plugin_store,
|
||||||
keySpec,
|
keySpec,
|
||||||
)
|
)
|
||||||
@ -185,9 +183,9 @@ class WhenTestingSecretStorePluginManager(utils.BaseTestCase):
|
|||||||
plugin = TestSecretStore([])
|
plugin = TestSecretStore([])
|
||||||
plugin_mock = mock.MagicMock(obj=plugin)
|
plugin_mock = mock.MagicMock(obj=plugin)
|
||||||
self.manager.extensions = [plugin_mock]
|
self.manager.extensions = [plugin_mock]
|
||||||
keySpec = str.KeySpec(str.KeyAlgorithm.AES, 128)
|
keySpec = ss.KeySpec(ss.KeyAlgorithm.AES, 128)
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
str.SecretGenerateSupportedPluginNotFound,
|
ss.SecretGenerateSupportedPluginNotFound,
|
||||||
self.manager.get_plugin_generate,
|
self.manager.get_plugin_generate,
|
||||||
keySpec,
|
keySpec,
|
||||||
)
|
)
|
||||||
@ -196,9 +194,9 @@ class WhenTestingSecretStorePluginManager(utils.BaseTestCase):
|
|||||||
plugin = TestSecretStore([])
|
plugin = TestSecretStore([])
|
||||||
plugin_mock = mock.MagicMock(obj=plugin)
|
plugin_mock = mock.MagicMock(obj=plugin)
|
||||||
self.manager.extensions = [plugin_mock]
|
self.manager.extensions = [plugin_mock]
|
||||||
keySpec = str.KeySpec(str.KeyAlgorithm.AES, 128)
|
keySpec = ss.KeySpec(ss.KeyAlgorithm.AES, 128)
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
str.SecretStoreSupportedPluginNotFound,
|
ss.SecretStoreSupportedPluginNotFound,
|
||||||
self.manager.get_plugin_store,
|
self.manager.get_plugin_store,
|
||||||
key_spec=keySpec,
|
key_spec=keySpec,
|
||||||
transport_key_needed=True,
|
transport_key_needed=True,
|
||||||
@ -208,21 +206,21 @@ class WhenTestingSecretStorePluginManager(utils.BaseTestCase):
|
|||||||
plugin = TestSecretStoreWithTransportKey([])
|
plugin = TestSecretStoreWithTransportKey([])
|
||||||
plugin_mock = mock.MagicMock(obj=plugin)
|
plugin_mock = mock.MagicMock(obj=plugin)
|
||||||
self.manager.extensions = [plugin_mock]
|
self.manager.extensions = [plugin_mock]
|
||||||
keySpec = str.KeySpec(str.KeyAlgorithm.AES, 128)
|
keySpec = ss.KeySpec(ss.KeyAlgorithm.AES, 128)
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
str.SecretStoreSupportedPluginNotFound,
|
ss.SecretStoreSupportedPluginNotFound,
|
||||||
self.manager.get_plugin_store,
|
self.manager.get_plugin_store,
|
||||||
key_spec=keySpec,
|
key_spec=keySpec,
|
||||||
transport_key_needed=True,
|
transport_key_needed=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_get_store_plugin_with_no_tkey_and_supports_storage(self):
|
def test_get_store_plugin_with_no_tkey_and_supports_storage(self):
|
||||||
plugin = TestSecretStore([str.KeyAlgorithm.AES])
|
plugin = TestSecretStore([ss.KeyAlgorithm.AES])
|
||||||
plugin_mock = mock.MagicMock(obj=plugin)
|
plugin_mock = mock.MagicMock(obj=plugin)
|
||||||
self.manager.extensions = [plugin_mock]
|
self.manager.extensions = [plugin_mock]
|
||||||
keySpec = str.KeySpec(str.KeyAlgorithm.AES, 128)
|
keySpec = ss.KeySpec(ss.KeyAlgorithm.AES, 128)
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
str.SecretStoreSupportedPluginNotFound,
|
ss.SecretStoreSupportedPluginNotFound,
|
||||||
self.manager.get_plugin_store,
|
self.manager.get_plugin_store,
|
||||||
key_spec=keySpec,
|
key_spec=keySpec,
|
||||||
transport_key_needed=True,
|
transport_key_needed=True,
|
||||||
@ -231,7 +229,7 @@ class WhenTestingSecretStorePluginManager(utils.BaseTestCase):
|
|||||||
@mock.patch('barbican.common.utils.generate_fullname_for')
|
@mock.patch('barbican.common.utils.generate_fullname_for')
|
||||||
def test_get_retrieve_plugin_raises_when_not_available(
|
def test_get_retrieve_plugin_raises_when_not_available(
|
||||||
self, generate_full_name_for):
|
self, generate_full_name_for):
|
||||||
plugin = TestSecretStore([str.KeyAlgorithm.AES])
|
plugin = TestSecretStore([ss.KeyAlgorithm.AES])
|
||||||
plugin_mock = mock.MagicMock(obj=plugin)
|
plugin_mock = mock.MagicMock(obj=plugin)
|
||||||
self.manager.extensions = [plugin_mock]
|
self.manager.extensions = [plugin_mock]
|
||||||
|
|
||||||
@ -239,19 +237,19 @@ class WhenTestingSecretStorePluginManager(utils.BaseTestCase):
|
|||||||
plugin_name = 'plugin name searched for'
|
plugin_name = 'plugin name searched for'
|
||||||
|
|
||||||
exception_result = self.assertRaises(
|
exception_result = self.assertRaises(
|
||||||
str.StorePluginNotAvailableOrMisconfigured,
|
ss.StorePluginNotAvailableOrMisconfigured,
|
||||||
self.manager.get_plugin_retrieve_delete,
|
self.manager.get_plugin_retrieve_delete,
|
||||||
plugin_name=plugin_name,
|
plugin_name=plugin_name,
|
||||||
)
|
)
|
||||||
self.assertIn(plugin_name, six.text_type(exception_result))
|
self.assertIn(plugin_name, str(exception_result))
|
||||||
|
|
||||||
def test_get_store_plugin_with_tkey_and_supports_storage(self):
|
def test_get_store_plugin_with_tkey_and_supports_storage(self):
|
||||||
plugin1 = TestSecretStore([str.KeyAlgorithm.AES])
|
plugin1 = TestSecretStore([ss.KeyAlgorithm.AES])
|
||||||
plugin1_mock = mock.MagicMock(obj=plugin1)
|
plugin1_mock = mock.MagicMock(obj=plugin1)
|
||||||
plugin2 = TestSecretStoreWithTransportKey([str.KeyAlgorithm.AES])
|
plugin2 = TestSecretStoreWithTransportKey([ss.KeyAlgorithm.AES])
|
||||||
plugin2_mock = mock.MagicMock(obj=plugin2)
|
plugin2_mock = mock.MagicMock(obj=plugin2)
|
||||||
self.manager.extensions = [plugin1_mock, plugin2_mock]
|
self.manager.extensions = [plugin1_mock, plugin2_mock]
|
||||||
keySpec = str.KeySpec(str.KeyAlgorithm.AES, 128)
|
keySpec = ss.KeySpec(ss.KeyAlgorithm.AES, 128)
|
||||||
self.assertEqual(plugin2,
|
self.assertEqual(plugin2,
|
||||||
self.manager.get_plugin_store(
|
self.manager.get_plugin_store(
|
||||||
key_spec=keySpec,
|
key_spec=keySpec,
|
||||||
@ -274,7 +272,7 @@ class TestSecretStorePluginManagerMultipleBackend(
|
|||||||
'_create_pkcs11') as m_pkcs11, \
|
'_create_pkcs11') as m_pkcs11, \
|
||||||
mock.patch('kmip.pie.client.ProxyKmipClient') as m_kmip:
|
mock.patch('kmip.pie.client.ProxyKmipClient') as m_kmip:
|
||||||
|
|
||||||
manager = str.SecretStorePluginManager()
|
manager = ss.SecretStorePluginManager()
|
||||||
|
|
||||||
# check pkcs11 and kmip plugin instantiation call is invoked
|
# check pkcs11 and kmip plugin instantiation call is invoked
|
||||||
m_pkcs11.assert_called_once_with(None)
|
m_pkcs11.assert_called_once_with(None)
|
||||||
@ -284,7 +282,7 @@ class TestSecretStorePluginManagerMultipleBackend(
|
|||||||
username='sample_username',
|
username='sample_username',
|
||||||
password='sample_password')
|
password='sample_password')
|
||||||
# check store crypto adapter is matched as its defined first.
|
# check store crypto adapter is matched as its defined first.
|
||||||
keySpec = str.KeySpec(str.KeyAlgorithm.AES, 128)
|
keySpec = ss.KeySpec(ss.KeyAlgorithm.AES, 128)
|
||||||
plugin_found = manager.get_plugin_store(keySpec)
|
plugin_found = manager.get_plugin_store(keySpec)
|
||||||
self.assertIsInstance(plugin_found,
|
self.assertIsInstance(plugin_found,
|
||||||
store_crypto.StoreCryptoAdapterPlugin)
|
store_crypto.StoreCryptoAdapterPlugin)
|
||||||
@ -311,7 +309,7 @@ class TestSecretStorePluginManagerMultipleBackend(
|
|||||||
'_create_pkcs11') as m_pkcs11, \
|
'_create_pkcs11') as m_pkcs11, \
|
||||||
mock.patch('kmip.pie.client.ProxyKmipClient') as m_kmip:
|
mock.patch('kmip.pie.client.ProxyKmipClient') as m_kmip:
|
||||||
|
|
||||||
manager = str.SecretStorePluginManager()
|
manager = ss.SecretStorePluginManager()
|
||||||
|
|
||||||
# check pkcs11 and kmip plugin instantiation call is invoked
|
# check pkcs11 and kmip plugin instantiation call is invoked
|
||||||
m_pkcs11.assert_called_once_with(None)
|
m_pkcs11.assert_called_once_with(None)
|
||||||
@ -321,6 +319,6 @@ class TestSecretStorePluginManagerMultipleBackend(
|
|||||||
username='sample_username',
|
username='sample_username',
|
||||||
password='sample_password')
|
password='sample_password')
|
||||||
# check kmip store is matched as its global default store.
|
# check kmip store is matched as its global default store.
|
||||||
keySpec = str.KeySpec(str.KeyAlgorithm.AES, 128)
|
keySpec = ss.KeySpec(ss.KeyAlgorithm.AES, 128)
|
||||||
plugin_found = manager.get_plugin_store(keySpec)
|
plugin_found = manager.get_plugin_store(keySpec)
|
||||||
self.assertIsInstance(plugin_found, kss.KMIPSecretStore)
|
self.assertIsInstance(plugin_found, kss.KMIPSecretStore)
|
||||||
|
@ -15,8 +15,6 @@
|
|||||||
import datetime
|
import datetime
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from barbican.model import models
|
from barbican.model import models
|
||||||
from barbican.model import repositories
|
from barbican.model import repositories
|
||||||
from barbican.queue import server
|
from barbican.queue import server
|
||||||
@ -412,10 +410,9 @@ class WhenUsingTaskServer(database_utils.RepositoryTestCase):
|
|||||||
|
|
||||||
self.assertEqual(models.States.ERROR, order_result.status)
|
self.assertEqual(models.States.ERROR, order_result.status)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
six.u(
|
('Process TypeOrder failure seen - '
|
||||||
'Process TypeOrder failure seen - '
|
'please contact site administrator.'),
|
||||||
'please contact site administrator.'),
|
|
||||||
order_result.error_reason)
|
order_result.error_reason)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
six.u('500'),
|
'500',
|
||||||
order_result.error_status_code)
|
order_result.error_status_code)
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
import six
|
|
||||||
|
|
||||||
from barbican import i18n as u
|
from barbican import i18n as u
|
||||||
from barbican.model import models
|
from barbican.model import models
|
||||||
@ -349,7 +348,7 @@ class WhenUpdatingOrder(BaseOrderTestCase):
|
|||||||
self.meta
|
self.meta
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual('Abort!', six.text_type(exception))
|
self.assertEqual('Abort!', str(exception))
|
||||||
|
|
||||||
mock_mod_cert.assert_called_once_with(self.order, self.meta)
|
mock_mod_cert.assert_called_once_with(self.order, self.meta)
|
||||||
|
|
||||||
@ -526,7 +525,7 @@ class WhenCheckingCertificateStatus(BaseOrderTestCase):
|
|||||||
# Order state should be set to ERROR.
|
# Order state should be set to ERROR.
|
||||||
self.assertEqual(models.States.ERROR, self.order.status)
|
self.assertEqual(models.States.ERROR, self.order.status)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
six.u('Check Certificate Order Status failure seen - '
|
('Check Certificate Order Status failure seen - '
|
||||||
'please contact site administrator.'),
|
'please contact site administrator.'),
|
||||||
self.order.error_reason)
|
self.order.error_reason)
|
||||||
self.assertEqual(500, self.order.error_status_code)
|
self.assertEqual(500, self.order.error_status_code)
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from six.moves import http_client
|
from http import client as http_client
|
||||||
|
|
||||||
|
|
||||||
host = "localhost"
|
host = "localhost"
|
||||||
|
@ -26,8 +26,7 @@ from oslo_config import cfg
|
|||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
import oslotest.base as oslotest
|
import oslotest.base as oslotest
|
||||||
from oslotest import createfile
|
from oslotest import createfile
|
||||||
import six
|
from urllib import parse
|
||||||
from six.moves.urllib import parse
|
|
||||||
import webtest
|
import webtest
|
||||||
|
|
||||||
from barbican.api import app
|
from barbican.api import app
|
||||||
@ -374,11 +373,11 @@ def construct_new_test_function(original_func, name, build_params):
|
|||||||
:return: A new function object
|
:return: A new function object
|
||||||
"""
|
"""
|
||||||
new_func = types.FunctionType(
|
new_func = types.FunctionType(
|
||||||
six.get_function_code(original_func),
|
original_func.__code__,
|
||||||
six.get_function_globals(original_func),
|
original_func.__globals__,
|
||||||
name=name,
|
name=name,
|
||||||
argdefs=six.get_function_defaults(original_func),
|
argdefs=original_func.__defaults__,
|
||||||
closure=six.get_function_closure(original_func)
|
closure=original_func.__closure__
|
||||||
)
|
)
|
||||||
|
|
||||||
for key, val in original_func.__dict__.items():
|
for key, val in original_func.__dict__.items():
|
||||||
|
@ -20,7 +20,6 @@ import os
|
|||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
|
|
||||||
import oslotest.base as oslotest
|
import oslotest.base as oslotest
|
||||||
import six
|
|
||||||
from testtools import testcase
|
from testtools import testcase
|
||||||
|
|
||||||
from barbican.tests import utils
|
from barbican.tests import utils
|
||||||
@ -88,8 +87,7 @@ class TestCase(oslotest.BaseTestCase):
|
|||||||
return name
|
return name
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
class PagingTestCase(TestCase, metaclass=abc.ABCMeta):
|
||||||
class PagingTestCase(TestCase):
|
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
# super(PagingTestCase, self).setUp()
|
# super(PagingTestCase, self).setUp()
|
||||||
|
@ -15,7 +15,6 @@ limitations under the License.
|
|||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import six
|
|
||||||
|
|
||||||
|
|
||||||
class BaseBehaviors(object):
|
class BaseBehaviors(object):
|
||||||
@ -33,7 +32,7 @@ class BaseBehaviors(object):
|
|||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
self.LOG.exception(e)
|
self.LOG.exception(e)
|
||||||
self.LOG.error("Error converting response to JSON: %s",
|
self.LOG.error("Error converting response to JSON: %s",
|
||||||
six.text_type(e))
|
str(e))
|
||||||
self.LOG.error("Response Content: %s", response.content)
|
self.LOG.error("Response Content: %s", response.content)
|
||||||
|
|
||||||
return json_data
|
return json_data
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
import datetime
|
import datetime
|
||||||
from oslo_serialization import base64 as oslo_base64
|
from oslo_serialization import base64 as oslo_base64
|
||||||
from oslo_serialization import jsonutils as json
|
from oslo_serialization import jsonutils as json
|
||||||
import six
|
|
||||||
import sys
|
import sys
|
||||||
import testtools
|
import testtools
|
||||||
import time
|
import time
|
||||||
@ -884,8 +883,8 @@ class SecretsTestCase(base.TestCase):
|
|||||||
'array': [['boom']],
|
'array': [['boom']],
|
||||||
'int': [123],
|
'int': [123],
|
||||||
'none': [None],
|
'none': [None],
|
||||||
'bad_character': [six.unichr(0x0080)],
|
'bad_character': [chr(0x0080)],
|
||||||
'bad_characters': [six.unichr(0x1111) + six.unichr(0xffff)]
|
'bad_characters': [chr(0x1111) + chr(0xffff)]
|
||||||
})
|
})
|
||||||
@testcase.attr('negative')
|
@testcase.attr('negative')
|
||||||
def test_secret_create_defaults_invalid_payload(self, payload):
|
def test_secret_create_defaults_invalid_payload(self, payload):
|
||||||
|
@ -18,9 +18,8 @@ import os
|
|||||||
|
|
||||||
from oslo_serialization import base64
|
from oslo_serialization import base64
|
||||||
import requests
|
import requests
|
||||||
import six
|
|
||||||
from six.moves import urllib
|
|
||||||
from tempest.lib.common.utils import test_utils
|
from tempest.lib.common.utils import test_utils
|
||||||
|
import urllib
|
||||||
|
|
||||||
from functionaltests.common import auth
|
from functionaltests.common import auth
|
||||||
from functionaltests.common import config
|
from functionaltests.common import config
|
||||||
@ -94,7 +93,7 @@ class BarbicanClient(object):
|
|||||||
Throw an encode or decode exception is text can not be
|
Throw an encode or decode exception is text can not be
|
||||||
presented in ascii.
|
presented in ascii.
|
||||||
"""
|
"""
|
||||||
if isinstance(text, six.text_type):
|
if isinstance(text, str):
|
||||||
return text.encode('ascii')
|
return text.encode('ascii')
|
||||||
else:
|
else:
|
||||||
return text.decode('ascii')
|
return text.decode('ascii')
|
||||||
|
@ -26,7 +26,6 @@ pecan!=1.0.2,!=1.0.3,!=1.0.4,!=1.2,>=1.0.0 # BSD
|
|||||||
pyOpenSSL>=17.1.0 # Apache-2.0
|
pyOpenSSL>=17.1.0 # Apache-2.0
|
||||||
ldap3>=1.0.2 # LGPLv3
|
ldap3>=1.0.2 # LGPLv3
|
||||||
keystonemiddleware>=9.5.0 # Apache-2.0
|
keystonemiddleware>=9.5.0 # Apache-2.0
|
||||||
six>=1.10.0 # MIT
|
|
||||||
SQLAlchemy!=1.1.5,!=1.1.6,!=1.1.7,!=1.1.8,>=1.0.10 # MIT
|
SQLAlchemy!=1.1.5,!=1.1.6,!=1.1.7,!=1.1.8,>=1.0.10 # MIT
|
||||||
stevedore>=1.20.0 # Apache-2.0
|
stevedore>=1.20.0 # Apache-2.0
|
||||||
WebOb>=1.7.1 # MIT
|
WebOb>=1.7.1 # MIT
|
||||||
|
Loading…
x
Reference in New Issue
Block a user