# Path: glanceclient/exc.py
# class BaseException(Exception):
# class CommandError(BaseException):
# class InvalidEndpoint(BaseException):
# class CommunicationError(BaseException):
# class ClientException(Exception):
# class HTTPException(ClientException):
# class HTTPMultipleChoices(HTTPException):
# class BadRequest(HTTPException):
# class HTTPBadRequest(BadRequest):
# class Unauthorized(HTTPException):
# class HTTPUnauthorized(Unauthorized):
# class Forbidden(HTTPException):
# class HTTPForbidden(Forbidden):
# class NotFound(HTTPException):
# class HTTPNotFound(NotFound):
# class HTTPMethodNotAllowed(HTTPException):
# class Conflict(HTTPException):
# class HTTPConflict(Conflict):
# class OverLimit(HTTPException):
# class HTTPOverLimit(OverLimit):
# class HTTPInternalServerError(HTTPException):
# class HTTPNotImplemented(HTTPException):
# class HTTPBadGateway(HTTPException):
# class ServiceUnavailable(HTTPException):
# class HTTPServiceUnavailable(ServiceUnavailable):
# class NoTokenLookupException(Exception):
# class EndpointNotFound(Exception):
# class SSLConfigurationError(BaseException):
# class SSLCertificateError(BaseException):
#     def __init__(self, message=None):
#     def __str__(self):
#     def __init__(self, details=None):
#     def __str__(self):
#     def __str__(self):
# def from_response(response, body=None):


import os
import ssl
import testtools
import threading
import socketserver
from unittest import mock
from glanceclient import Client
from glanceclient import exc
from glanceclient import v1
from glanceclient import v2
    @mock.patch('sys.stderr')
    def test_v2_requests_valid_cert_verification(self, __):
        """Test absence of SSL key file."""
        port = self.port
        url = 'https://0.0.0.0:%d' % port
        cacert = os.path.join(TEST_VAR_DIR, 'ca.crt')

        try:
            gc = Client('2', url,
                        insecure=False,
                        ssl_compression=True,
                        cacert=cacert)
            gc.images.get('image123')
        except exc.CommunicationError as e:
            if 'certificate verify failed' in e.message:
                self.fail('Certificate failure message is received')

    @mock.patch('sys.stderr')
    def test_v2_requests_valid_cert_verification_no_compression(self, __):
        """Test VerifiedHTTPSConnection: absence of SSL key file."""
        port = self.port
        url = 'https://0.0.0.0:%d' % port
        cacert = os.path.join(TEST_VAR_DIR, 'ca.crt')

        try:
            gc = Client('2', url,
                        insecure=False,
                        ssl_compression=False,
                        cacert=cacert)
            gc.images.get('image123')

# Path: glanceclient/exc.py
# class BaseException(Exception):
# class CommandError(BaseException):
# class InvalidEndpoint(BaseException):
# class CommunicationError(BaseException):
# class ClientException(Exception):
# class HTTPException(ClientException):
# class HTTPMultipleChoices(HTTPException):
# class BadRequest(HTTPException):
# class HTTPBadRequest(BadRequest):
# class Unauthorized(HTTPException):
# class HTTPUnauthorized(Unauthorized):
# class Forbidden(HTTPException):
# class HTTPForbidden(Forbidden):
# class NotFound(HTTPException):
# class HTTPNotFound(NotFound):
# class HTTPMethodNotAllowed(HTTPException):
# class Conflict(HTTPException):
# class HTTPConflict(Conflict):
# class OverLimit(HTTPException):
# class HTTPOverLimit(OverLimit):
# class HTTPInternalServerError(HTTPException):
# class HTTPNotImplemented(HTTPException):
# class HTTPBadGateway(HTTPException):
# class ServiceUnavailable(HTTPException):
# class HTTPServiceUnavailable(ServiceUnavailable):
# class NoTokenLookupException(Exception):
# class EndpointNotFound(Exception):
# class SSLConfigurationError(BaseException):
# class SSLCertificateError(BaseException):
#     def __init__(self, message=None):
#     def __str__(self):
#     def __init__(self, details=None):
#     def __str__(self):
#     def __str__(self):
# def from_response(response, body=None):


# Path: glanceclient/tests/unit/test_ssl.py
import os
import ssl
import testtools
import threading
import socketserver
from unittest import mock
from glanceclient import Client
from glanceclient import exc
from glanceclient import v1
from glanceclient import v2

    @mock.patch('sys.stderr')
    def test_v2_requests_valid_cert_verification(self, __):
        """Test absence of SSL key file."""
        port = self.port
        url = 'https://0.0.0.0:%d' % port
        cacert = os.path.join(TEST_VAR_DIR, 'ca.crt')

        try:
            gc = Client('2', url,
                        insecure=False,
                        ssl_compression=True,
                        cacert=cacert)
            gc.images.get('image123')
        except exc.CommunicationError as e:
            if 'certificate verify failed' in e.message:
                self.fail('Certificate failure message is received')

    @mock.patch('sys.stderr')
    def test_v2_requests_valid_cert_verification_no_compression(self, __):
        """Test VerifiedHTTPSConnection: absence of SSL key file."""
        port = self.port
        url = 'https://0.0.0.0:%d' % port
        cacert = os.path.join(TEST_VAR_DIR, 'ca.crt')

        try:
            gc = Client('2', url,
                        insecure=False,
                        ssl_compression=False,
                        cacert=cacert)
            gc.images.get('image123')

        except exc.CommunicationError as e: