# 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
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

"""
Test cases for the mock key manager.
"""




def get_cryptography_private_key(private_key):
    crypto_private_key = serialization.load_der_private_key(
        bytes(private_key.get_encoded()),
        password=None,
        backend=backends.default_backend())
    return crypto_private_key


def get_cryptography_public_key(public_key):
    crypto_public_key = serialization.load_der_public_key(
        bytes(public_key.get_encoded()),
        backend=backends.default_backend())
    return crypto_public_key



# 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

#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

"""
Test cases for the mock key manager.
"""




def get_cryptography_private_key(private_key):
    crypto_private_key = serialization.load_der_private_key(
        bytes(private_key.get_encoded()),
        password=None,
        backend=backends.default_backend())
    return crypto_private_key


def get_cryptography_public_key(public_key):
    crypto_public_key = serialization.load_der_public_key(
        bytes(public_key.get_encoded()),
        backend=backends.default_backend())
    return crypto_public_key



class MockKeyManagerTestCase(test_key_mgr.KeyManagerTestCase):