# Path: castellan/common/exception.py
# _FATAL_EXCEPTION_FORMAT_ERRORS = False
# class RedirectException(Exception):
# class CastellanException(Exception):
# class Forbidden(CastellanException):
# class KeyManagerError(CastellanException):
# class ManagedObjectNotFoundError(CastellanException):
# class InvalidManagedObjectDictError(CastellanException):
# class UnknownManagedObjectTypeError(CastellanException):
# class AuthTypeInvalidError(CastellanException):
# class InsufficientCredentialDataError(CastellanException):
#     def __init__(self, url):
#     def __init__(self, message_arg=None, *args, **kwargs):
# 
# Path: castellan/common/objects/opaque_data.py
# class OpaqueData(managed_object.ManagedObject):
#     def __init__(self, data, name=None, created=None, id=None):
#     def managed_type(cls):
#     def format(self):
#     def get_encoded(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
# 
# Path: castellan/common/objects/passphrase.py
# class Passphrase(managed_object.ManagedObject):
#     def __init__(self, passphrase, name=None, created=None, id=None):
#     def managed_type(cls):
#     def format(self):
#     def get_encoded(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
# 
# Path: castellan/common/objects/private_key.py
# class PrivateKey(key.Key):
#     def __init__(self, algorithm, bit_length, key,
#                  name=None, created=None, id=None):
#     def managed_type(cls):
#     def algorithm(self):
#     def format(self):
#     def bit_length(self):
#     def get_encoded(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
# 
# Path: castellan/common/objects/public_key.py
# class PublicKey(key.Key):
#     def __init__(self, algorithm, bit_length, key,
#                  name=None, created=None, id=None):
#     def managed_type(cls):
#     def algorithm(self):
#     def format(self):
#     def get_encoded(self):
#     def bit_length(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
# 
# Path: castellan/common/objects/symmetric_key.py
# class SymmetricKey(key.Key):
#     def __init__(self, algorithm, bit_length, key,
#                  name=None, created=None, id=None):
#     def managed_type(cls):
#     def algorithm(self):
#     def format(self):
#     def get_encoded(self):
#     def bit_length(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
# 
# Path: castellan/common/objects/x_509.py
# class X509(certificate.Certificate):
#     def __init__(self, data, name=None, created=None, id=None):
#     def managed_type(cls):
#     def format(self):
#     def get_encoded(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
# 
# Path: castellan/tests/utils.py
# def construct_new_test_function(original_func, name, build_params):
#     def test_wrapper(func, test_args, test_kwargs):
#         def wrapper(self):
# def process_parameterized_function(name, func_obj, build_data):
# def parameterized_test_case(cls):
# def parameterized_dataset(build_data):
#     def decorator(func):
# def get_certificate_der():
# def get_private_key_der():
# def get_public_key_der():
# def get_symmetric_key():


from castellan.common import exception
from castellan.common.objects import opaque_data
from castellan.common.objects import passphrase
from castellan.common.objects import private_key
from castellan.common.objects import public_key
from castellan.common.objects import symmetric_key
from castellan.common.objects import x_509
from castellan.tests import utils
    def setUp(self):
        super(KeyManagerTestCase, self).setUp()
        self.key_mgr = self._create_key_manager()
        self.ctxt = None

    def _get_valid_object_uuid(self, managed_object):
        object_uuid = self.key_mgr.store(self.ctxt, managed_object)
        self.assertIsNotNone(object_uuid)
        return object_uuid

    def test_create_key(self):
        key_uuid = self.key_mgr.create_key(self.ctxt,
                                           algorithm='AES',
                                           length=256)
        self.addCleanup(self.key_mgr.delete, self.ctxt, key_uuid)
        self.assertIsNotNone(key_uuid)

    def test_create_key_pair(self):
        private_key_uuid, public_key_uuid = self.key_mgr.create_key_pair(
            self.ctxt,
            algorithm='RSA',
            length=2048)

        self.addCleanup(self.key_mgr.delete, self.ctxt, private_key_uuid)
        self.addCleanup(self.key_mgr.delete, self.ctxt, public_key_uuid)

        self.assertIsNotNone(private_key_uuid)
        self.assertIsNotNone(public_key_uuid)
        self.assertNotEqual(private_key_uuid, public_key_uuid)


# Path: castellan/common/exception.py
# _FATAL_EXCEPTION_FORMAT_ERRORS = False
# class RedirectException(Exception):
# class CastellanException(Exception):
# class Forbidden(CastellanException):
# class KeyManagerError(CastellanException):
# class ManagedObjectNotFoundError(CastellanException):
# class InvalidManagedObjectDictError(CastellanException):
# class UnknownManagedObjectTypeError(CastellanException):
# class AuthTypeInvalidError(CastellanException):
# class InsufficientCredentialDataError(CastellanException):
#     def __init__(self, url):
#     def __init__(self, message_arg=None, *args, **kwargs):
# 
# Path: castellan/common/objects/opaque_data.py
# class OpaqueData(managed_object.ManagedObject):
#     def __init__(self, data, name=None, created=None, id=None):
#     def managed_type(cls):
#     def format(self):
#     def get_encoded(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
# 
# Path: castellan/common/objects/passphrase.py
# class Passphrase(managed_object.ManagedObject):
#     def __init__(self, passphrase, name=None, created=None, id=None):
#     def managed_type(cls):
#     def format(self):
#     def get_encoded(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
# 
# Path: castellan/common/objects/private_key.py
# class PrivateKey(key.Key):
#     def __init__(self, algorithm, bit_length, key,
#                  name=None, created=None, id=None):
#     def managed_type(cls):
#     def algorithm(self):
#     def format(self):
#     def bit_length(self):
#     def get_encoded(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
# 
# Path: castellan/common/objects/public_key.py
# class PublicKey(key.Key):
#     def __init__(self, algorithm, bit_length, key,
#                  name=None, created=None, id=None):
#     def managed_type(cls):
#     def algorithm(self):
#     def format(self):
#     def get_encoded(self):
#     def bit_length(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
# 
# Path: castellan/common/objects/symmetric_key.py
# class SymmetricKey(key.Key):
#     def __init__(self, algorithm, bit_length, key,
#                  name=None, created=None, id=None):
#     def managed_type(cls):
#     def algorithm(self):
#     def format(self):
#     def get_encoded(self):
#     def bit_length(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
# 
# Path: castellan/common/objects/x_509.py
# class X509(certificate.Certificate):
#     def __init__(self, data, name=None, created=None, id=None):
#     def managed_type(cls):
#     def format(self):
#     def get_encoded(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
# 
# Path: castellan/tests/utils.py
# def construct_new_test_function(original_func, name, build_params):
#     def test_wrapper(func, test_args, test_kwargs):
#         def wrapper(self):
# def process_parameterized_function(name, func_obj, build_data):
# def parameterized_test_case(cls):
# def parameterized_dataset(build_data):
#     def decorator(func):
# def get_certificate_der():
# def get_private_key_der():
# def get_public_key_der():
# def get_symmetric_key():


# Path: castellan/tests/functional/key_manager/test_key_manager.py
from castellan.common import exception
from castellan.common.objects import opaque_data
from castellan.common.objects import passphrase
from castellan.common.objects import private_key
from castellan.common.objects import public_key
from castellan.common.objects import symmetric_key
from castellan.common.objects import x_509
from castellan.tests import utils

    def setUp(self):
        super(KeyManagerTestCase, self).setUp()
        self.key_mgr = self._create_key_manager()
        self.ctxt = None

    def _get_valid_object_uuid(self, managed_object):
        object_uuid = self.key_mgr.store(self.ctxt, managed_object)
        self.assertIsNotNone(object_uuid)
        return object_uuid

    def test_create_key(self):
        key_uuid = self.key_mgr.create_key(self.ctxt,
                                           algorithm='AES',
                                           length=256)
        self.addCleanup(self.key_mgr.delete, self.ctxt, key_uuid)
        self.assertIsNotNone(key_uuid)

    def test_create_key_pair(self):
        private_key_uuid, public_key_uuid = self.key_mgr.create_key_pair(
            self.ctxt,
            algorithm='RSA',
            length=2048)

        self.addCleanup(self.key_mgr.delete, self.ctxt, private_key_uuid)
        self.addCleanup(self.key_mgr.delete, self.ctxt, public_key_uuid)

        self.assertIsNotNone(private_key_uuid)
        self.assertIsNotNone(public_key_uuid)
        self.assertNotEqual(private_key_uuid, public_key_uuid)


    @utils.parameterized_dataset({