# Path: oslo_middleware/cors.py
# LOG = logging.getLogger(__name__)
# CORS_OPTS = [
#     cfg.ListOpt('allowed_origin',
#                 help='Indicate whether this resource may be shared with the '
#                      'domain received in the requests "origin" header. '
#                      'Format: "<protocol>://<host>[:<port>]", no trailing '
#                      'slash. Example: https://horizon.example.com'),
#     cfg.BoolOpt('allow_credentials',
#                 default=True,
#                 help='Indicate that the actual request can include user '
#                      'credentials'),
#     cfg.ListOpt('expose_headers',
#                 default=[],
#                 help='Indicate which headers are safe to expose to the API. '
#                      'Defaults to HTTP Simple Headers.'),
#     cfg.IntOpt('max_age',
#                default=3600,
#                help='Maximum cache age of CORS preflight requests.'),
#     cfg.ListOpt('allow_methods',
#                 default=['OPTIONS', 'GET', 'HEAD', 'POST', 'PUT', 'DELETE',
#                          'TRACE', 'PATCH'],  # RFC 2616, RFC 5789
#                 help='Indicate which methods can be used during the actual '
#                      'request.'),
#     cfg.ListOpt('allow_headers',
#                 default=[],
#                 help='Indicate which header field names may be used during '
#                      'the actual request.')
# ]
# def set_defaults(**kwargs):
#     def __init__(self, origin):
#     def __init__(self, application, *args, **kwargs):
#         def sanitize(csv_list):
#     def factory(cls, global_conf, **local_conf):
#     def _init_conf(self):
#     def add_origin(self, allowed_origin, allow_credentials=True,
#                    expose_headers=None, max_age=None, allow_methods=None,
#                    allow_headers=None):
#     def process_response(self, response, request=None):
#     def _split_header_values(request, header_name):
#     def _apply_cors_preflight_headers(self, request, response):
#     def _get_cors_config_by_origin(self, origin):
#     def _apply_cors_request_headers(self, request, response):
# class InvalidOriginError(Exception):
# class CORS(base.ConfigurableMiddleware):


from oslo_config import fixture
from oslotest import base as test_base
from oslo_middleware import cors
import webob
import webob.dec
import webob.exc as exc
                                max_age='',
                                expose_headers='',
                                allow_methods='GET',
                                allow_headers='')

        fixture.load_raw_values(group='cors.credentials',
                                allowed_origin='http://creds.example.com',
                                allow_credentials='True')

        fixture.load_raw_values(group='cors.exposed-headers',
                                allowed_origin='http://headers.example.com',
                                expose_headers='X-Header-1,X-Header-2',
                                allow_headers='X-Header-1,X-Header-2')

        fixture.load_raw_values(group='cors.cached',
                                allowed_origin='http://cached.example.com',
                                max_age='3600')

        fixture.load_raw_values(group='cors.get-only',
                                allowed_origin='http://get.example.com',
                                allow_methods='GET')
        fixture.load_raw_values(group='cors.all-methods',
                                allowed_origin='http://all.example.com',
                                allow_methods='GET,PUT,POST,DELETE,HEAD')

        fixture.load_raw_values(group='cors.duplicate',
                                allowed_origin='http://domain1.example.com,'
                                               'http://domain2.example.com')

        # Now that the config is set up, create our application.

# Path: oslo_middleware/cors.py
# LOG = logging.getLogger(__name__)
# CORS_OPTS = [
#     cfg.ListOpt('allowed_origin',
#                 help='Indicate whether this resource may be shared with the '
#                      'domain received in the requests "origin" header. '
#                      'Format: "<protocol>://<host>[:<port>]", no trailing '
#                      'slash. Example: https://horizon.example.com'),
#     cfg.BoolOpt('allow_credentials',
#                 default=True,
#                 help='Indicate that the actual request can include user '
#                      'credentials'),
#     cfg.ListOpt('expose_headers',
#                 default=[],
#                 help='Indicate which headers are safe to expose to the API. '
#                      'Defaults to HTTP Simple Headers.'),
#     cfg.IntOpt('max_age',
#                default=3600,
#                help='Maximum cache age of CORS preflight requests.'),
#     cfg.ListOpt('allow_methods',
#                 default=['OPTIONS', 'GET', 'HEAD', 'POST', 'PUT', 'DELETE',
#                          'TRACE', 'PATCH'],  # RFC 2616, RFC 5789
#                 help='Indicate which methods can be used during the actual '
#                      'request.'),
#     cfg.ListOpt('allow_headers',
#                 default=[],
#                 help='Indicate which header field names may be used during '
#                      'the actual request.')
# ]
# def set_defaults(**kwargs):
#     def __init__(self, origin):
#     def __init__(self, application, *args, **kwargs):
#         def sanitize(csv_list):
#     def factory(cls, global_conf, **local_conf):
#     def _init_conf(self):
#     def add_origin(self, allowed_origin, allow_credentials=True,
#                    expose_headers=None, max_age=None, allow_methods=None,
#                    allow_headers=None):
#     def process_response(self, response, request=None):
#     def _split_header_values(request, header_name):
#     def _apply_cors_preflight_headers(self, request, response):
#     def _get_cors_config_by_origin(self, origin):
#     def _apply_cors_request_headers(self, request, response):
# class InvalidOriginError(Exception):
# class CORS(base.ConfigurableMiddleware):


# Path: oslo_middleware/tests/test_cors.py
from oslo_config import fixture
from oslotest import base as test_base
from oslo_middleware import cors
import webob
import webob.dec
import webob.exc as exc

                                max_age='',
                                expose_headers='',
                                allow_methods='GET',
                                allow_headers='')

        fixture.load_raw_values(group='cors.credentials',
                                allowed_origin='http://creds.example.com',
                                allow_credentials='True')

        fixture.load_raw_values(group='cors.exposed-headers',
                                allowed_origin='http://headers.example.com',
                                expose_headers='X-Header-1,X-Header-2',
                                allow_headers='X-Header-1,X-Header-2')

        fixture.load_raw_values(group='cors.cached',
                                allowed_origin='http://cached.example.com',
                                max_age='3600')

        fixture.load_raw_values(group='cors.get-only',
                                allowed_origin='http://get.example.com',
                                allow_methods='GET')
        fixture.load_raw_values(group='cors.all-methods',
                                allowed_origin='http://all.example.com',
                                allow_methods='GET,PUT,POST,DELETE,HEAD')

        fixture.load_raw_values(group='cors.duplicate',
                                allowed_origin='http://domain1.example.com,'
                                               'http://domain2.example.com')

        # Now that the config is set up, create our application.

        self.application = cors.CORS(test_application, self.config)