# Path: barbicanclient/client.py
# LOG = logging.getLogger(__name__)
# _DEFAULT_SERVICE_TYPE = 'key-manager'
# _DEFAULT_SERVICE_INTERFACE = 'public'
# _DEFAULT_API_VERSION = 'v1'
# _SUPPORTED_API_VERSION_MAP = {'v1': 'barbicanclient.v1.client.Client'}
# class _HTTPClient(adapter.Adapter):
# class _LazyImporter(object):
#     def __init__(self, session, project_id=None, **kwargs):
#     def request(self, *args, **kwargs):
#     def get(self, *args, **kwargs):
#     def post(self, path, *args, **kwargs):
#     def _fix_path(self, path):
#     def _get_raw(self, path, *args, **kwargs):
#     def _check_status_code(self, resp):
#     def _get_error_message(self, resp):
# def Client(version=None, session=None, *args, **kwargs):
# def env(*vars, **kwargs):
#     def __init__(self, module):
#     def __getattr__(self, name):
# 
# Path: barbicanclient/exceptions.py
# class BarbicanException(Exception):
# class PayloadException(BarbicanException):
# class UnsupportedVersion(BarbicanException):
# class HTTPError(Exception):
# class HTTPServerError(HTTPError):
# class HTTPClientError(HTTPError):
# class HTTPAuthError(HTTPError):
#     def __init__(self, message, status_code=0):
#     def __init__(self, message, status_code=401):
# 
# Path: functionaltests/common/config.py
# TEST_CONF = None
#     TEST_CONF = cfg.ConfigOpts()
# def setup_config(config_file=''):
# def get_config():


from barbicanclient import client
from barbicanclient import exceptions
from functionaltests.base import BaseTestCase
from functionaltests.common import config
from keystoneauth1 import exceptions as ks_exceptions
from keystoneauth1 import identity
from keystoneauth1 import session
                username=CONF.keymanager.username,
                user_domain_name=CONF.identity.domain_name,
                password=CONF.keymanager.password,
                project_name=CONF.keymanager.project_name,
                project_domain_name=CONF.keymanager.project_domain_name)

        # enables the tests in this class to share a keystone token
        cls.sess = session.Session(auth=cls.auth)

    def setUp(self):
        self.LOG.info('Starting: %s', self._testMethodName)
        super(WhenTestingClientConnectivity, self).setUp()

    def assert_client_can_contact_barbican(self, client):
        """Asserts that the client has connectivity to Barbican.

        If there was an error with the connectivity, the operations that are
        attempted through the client would throw an exception.
        """
        containers = client.containers.list()
        orders = client.orders.list()
        secrets = client.secrets.list()

        self.assertIsNotNone(containers)
        self.assertIsNotNone(orders)
        self.assertIsNotNone(secrets)

    def assert_client_cannot_contact_barbican(self, client):
        self.assertRaises(exceptions.HTTPClientError, client.containers.list)
        self.assertRaises(exceptions.HTTPClientError, client.orders.list)

# Path: barbicanclient/client.py
# LOG = logging.getLogger(__name__)
# _DEFAULT_SERVICE_TYPE = 'key-manager'
# _DEFAULT_SERVICE_INTERFACE = 'public'
# _DEFAULT_API_VERSION = 'v1'
# _SUPPORTED_API_VERSION_MAP = {'v1': 'barbicanclient.v1.client.Client'}
# class _HTTPClient(adapter.Adapter):
# class _LazyImporter(object):
#     def __init__(self, session, project_id=None, **kwargs):
#     def request(self, *args, **kwargs):
#     def get(self, *args, **kwargs):
#     def post(self, path, *args, **kwargs):
#     def _fix_path(self, path):
#     def _get_raw(self, path, *args, **kwargs):
#     def _check_status_code(self, resp):
#     def _get_error_message(self, resp):
# def Client(version=None, session=None, *args, **kwargs):
# def env(*vars, **kwargs):
#     def __init__(self, module):
#     def __getattr__(self, name):
# 
# Path: barbicanclient/exceptions.py
# class BarbicanException(Exception):
# class PayloadException(BarbicanException):
# class UnsupportedVersion(BarbicanException):
# class HTTPError(Exception):
# class HTTPServerError(HTTPError):
# class HTTPClientError(HTTPError):
# class HTTPAuthError(HTTPError):
#     def __init__(self, message, status_code=0):
#     def __init__(self, message, status_code=401):
# 
# Path: functionaltests/common/config.py
# TEST_CONF = None
#     TEST_CONF = cfg.ConfigOpts()
# def setup_config(config_file=''):
# def get_config():


# Path: functionaltests/client/test_client_connectivity.py
from barbicanclient import client
from barbicanclient import exceptions
from functionaltests.base import BaseTestCase
from functionaltests.common import config
from keystoneauth1 import exceptions as ks_exceptions
from keystoneauth1 import identity
from keystoneauth1 import session

                username=CONF.keymanager.username,
                user_domain_name=CONF.identity.domain_name,
                password=CONF.keymanager.password,
                project_name=CONF.keymanager.project_name,
                project_domain_name=CONF.keymanager.project_domain_name)

        # enables the tests in this class to share a keystone token
        cls.sess = session.Session(auth=cls.auth)

    def setUp(self):
        self.LOG.info('Starting: %s', self._testMethodName)
        super(WhenTestingClientConnectivity, self).setUp()

    def assert_client_can_contact_barbican(self, client):
        """Asserts that the client has connectivity to Barbican.

        If there was an error with the connectivity, the operations that are
        attempted through the client would throw an exception.
        """
        containers = client.containers.list()
        orders = client.orders.list()
        secrets = client.secrets.list()

        self.assertIsNotNone(containers)
        self.assertIsNotNone(orders)
        self.assertIsNotNone(secrets)

    def assert_client_cannot_contact_barbican(self, client):
        self.assertRaises(exceptions.HTTPClientError, client.containers.list)
        self.assertRaises(exceptions.HTTPClientError, client.orders.list)

        self.assertRaises(exceptions.HTTPClientError, client.secrets.list)