# 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/utils.py
# LOG = logging.getLogger(__name__)
# OPT_GROUP = 'key_manager'
# def credential_factory(conf=None, context=None):
# 
# Path: castellan/tests/base.py
# class TestCase(base.BaseTestCase):
# class CertificateTestCase(TestCase):
# class KeyTestCase(TestCase):
#     def _create_cert(self):
#     def setUp(self):
#     def _create_key(self):
#     def setUp(self):


from castellan.common import exception
from castellan.common import utils
from castellan.tests import base
from oslo_config import cfg
from oslo_config import fixture as config_fixture
from oslo_context import context
        ks_token_context = utils.credential_factory(conf=CONF, context=ctxt)
        ks_token_context_class = ks_token_context.__class__.__name__

        self.assertEqual('KeystoneToken', ks_token_context_class)
        self.assertEqual(token_value, ks_token_context.token)

    def test_keystone_token_credential_config_override_context(self):
        ctxt_token_value = 'ec9799cd921e4e0a8ab6111c08ebf065'
        ctxt = context.RequestContext(auth_token=ctxt_token_value)

        conf_token_value = 'ec9799cd921e4e0a8ab6111c08ebf065'

        self.config_fixture.config(
            auth_type='keystone_token',
            token=conf_token_value,
            group='key_manager'
        )

        ks_token_context = utils.credential_factory(conf=CONF, context=ctxt)
        ks_token_context_class = ks_token_context.__class__.__name__

        self.assertEqual('KeystoneToken', ks_token_context_class)
        self.assertEqual(conf_token_value, ks_token_context.token)

    def test_keystone_token_credential_exception(self):
        self.config_fixture.config(
            auth_type='keystone_token',
            group='key_manager'
        )


# 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/utils.py
# LOG = logging.getLogger(__name__)
# OPT_GROUP = 'key_manager'
# def credential_factory(conf=None, context=None):
# 
# Path: castellan/tests/base.py
# class TestCase(base.BaseTestCase):
# class CertificateTestCase(TestCase):
# class KeyTestCase(TestCase):
#     def _create_cert(self):
#     def setUp(self):
#     def _create_key(self):
#     def setUp(self):


# Path: castellan/tests/unit/test_utils.py
from castellan.common import exception
from castellan.common import utils
from castellan.tests import base
from oslo_config import cfg
from oslo_config import fixture as config_fixture
from oslo_context import context

        ks_token_context = utils.credential_factory(conf=CONF, context=ctxt)
        ks_token_context_class = ks_token_context.__class__.__name__

        self.assertEqual('KeystoneToken', ks_token_context_class)
        self.assertEqual(token_value, ks_token_context.token)

    def test_keystone_token_credential_config_override_context(self):
        ctxt_token_value = 'ec9799cd921e4e0a8ab6111c08ebf065'
        ctxt = context.RequestContext(auth_token=ctxt_token_value)

        conf_token_value = 'ec9799cd921e4e0a8ab6111c08ebf065'

        self.config_fixture.config(
            auth_type='keystone_token',
            token=conf_token_value,
            group='key_manager'
        )

        ks_token_context = utils.credential_factory(conf=CONF, context=ctxt)
        ks_token_context_class = ks_token_context.__class__.__name__

        self.assertEqual('KeystoneToken', ks_token_context_class)
        self.assertEqual(conf_token_value, ks_token_context.token)

    def test_keystone_token_credential_exception(self):
        self.config_fixture.config(
            auth_type='keystone_token',
            group='key_manager'
        )


        self.assertRaises(exception.InsufficientCredentialDataError,