# 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/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/tests/unit/key_manager/mock_key_manager.py
# class MockKeyManager(key_manager.KeyManager):
#     def __init__(self, configuration=None):
#     def _generate_hex_key(self, key_length):
#     def _generate_key(self, **kwargs):
#     def create_key(self, context, **kwargs):
#     def _generate_public_and_private_key(self, length, name):
#     def create_key_pair(self, context, algorithm, length,
#                         expiration=None, name=None):
#     def _generate_key_id(self):
#     def store(self, context, managed_object, **kwargs):
#     def get(self, context, managed_object_id, metadata_only=False, **kwargs):
#     def delete(self, context, managed_object_id, **kwargs):
#     def _generate_password(self, length, symbolgroups):
#     def list(self, context, object_type=None, metadata_only=False):
# 
# Path: castellan/tests/unit/key_manager/test_key_manager.py
# CONF = cfg.CONF
# class KeyManagerTestCase(base.TestCase):
# class DefaultKeyManagerImplTestCase(KeyManagerTestCase):
#     def _create_key_manager(self):
#     def setUp(self):
#     def _create_key_manager(self):
#     def test_default_key_manager(self):


from cryptography.hazmat import backends
from cryptography.hazmat.primitives.asymmetric import padding
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives import serialization
from oslo_context import context
from castellan.common import exception
from castellan.common.objects import symmetric_key as sym_key
from castellan.tests.unit.key_manager import mock_key_manager as mock_key_mgr
from castellan.tests.unit.key_manager import test_key_manager as test_key_mgr
        self.assertIsNone(actual_key.get_encoded())
        self.assertTrue(actual_key.is_metadata_only())

        actual_key = self.key_mgr.get(self.context,
                                      key_id,
                                      metadata_only=False)
        self.assertIsNotNone(actual_key.get_encoded())
        self.assertFalse(actual_key.is_metadata_only())

        self.assertIsNotNone(actual_key.id)

    def test_store_null_context(self):
        self.assertRaises(exception.Forbidden,
                          self.key_mgr.store, None, None)

    def test_get_null_context(self):
        self.assertRaises(exception.Forbidden,
                          self.key_mgr.get, None, None)

    def test_get_unknown_key(self):
        self.assertRaises(KeyError, self.key_mgr.get, self.context, None)

    def test_delete_key(self):
        key_id = self.key_mgr.create_key(self.context)
        self.key_mgr.delete(self.context, key_id)

        self.assertRaises(KeyError, self.key_mgr.get, self.context,
                          key_id)

    def test_delete_null_context(self):

# 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/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/tests/unit/key_manager/mock_key_manager.py
# class MockKeyManager(key_manager.KeyManager):
#     def __init__(self, configuration=None):
#     def _generate_hex_key(self, key_length):
#     def _generate_key(self, **kwargs):
#     def create_key(self, context, **kwargs):
#     def _generate_public_and_private_key(self, length, name):
#     def create_key_pair(self, context, algorithm, length,
#                         expiration=None, name=None):
#     def _generate_key_id(self):
#     def store(self, context, managed_object, **kwargs):
#     def get(self, context, managed_object_id, metadata_only=False, **kwargs):
#     def delete(self, context, managed_object_id, **kwargs):
#     def _generate_password(self, length, symbolgroups):
#     def list(self, context, object_type=None, metadata_only=False):
# 
# Path: castellan/tests/unit/key_manager/test_key_manager.py
# CONF = cfg.CONF
# class KeyManagerTestCase(base.TestCase):
# class DefaultKeyManagerImplTestCase(KeyManagerTestCase):
#     def _create_key_manager(self):
#     def setUp(self):
#     def _create_key_manager(self):
#     def test_default_key_manager(self):


# Path: castellan/tests/unit/key_manager/test_mock_key_manager.py
from cryptography.hazmat import backends
from cryptography.hazmat.primitives.asymmetric import padding
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives import serialization
from oslo_context import context
from castellan.common import exception
from castellan.common.objects import symmetric_key as sym_key
from castellan.tests.unit.key_manager import mock_key_manager as mock_key_mgr
from castellan.tests.unit.key_manager import test_key_manager as test_key_mgr

        self.assertIsNone(actual_key.get_encoded())
        self.assertTrue(actual_key.is_metadata_only())

        actual_key = self.key_mgr.get(self.context,
                                      key_id,
                                      metadata_only=False)
        self.assertIsNotNone(actual_key.get_encoded())
        self.assertFalse(actual_key.is_metadata_only())

        self.assertIsNotNone(actual_key.id)

    def test_store_null_context(self):
        self.assertRaises(exception.Forbidden,
                          self.key_mgr.store, None, None)

    def test_get_null_context(self):
        self.assertRaises(exception.Forbidden,
                          self.key_mgr.get, None, None)

    def test_get_unknown_key(self):
        self.assertRaises(KeyError, self.key_mgr.get, self.context, None)

    def test_delete_key(self):
        key_id = self.key_mgr.create_key(self.context)
        self.key_mgr.delete(self.context, key_id)

        self.assertRaises(KeyError, self.key_mgr.get, self.context,
                          key_id)

    def test_delete_null_context(self):

        self.assertRaises(exception.Forbidden,