Example #1
0
    def setUp(self, mock_metrics, mock_distributed_task, mock_storage,
              mock_dns, mock_notification, mock_bootstrap):

        super(DefaultSSLCertificateControllerTests, self).setUp()

        conf = cfg.ConfigOpts()

        self.provider_mocks = {
            'akamai': mock.Mock(provider_name="Akamai"),
            'maxcdn': mock.Mock(provider_name='MaxCDN'),
            'cloudfront': mock.Mock(provider_name='CloudFront'),
            'fastly': mock.Mock(provider_name='Fastly'),
            'mock': mock.Mock(provider_name='Mock')
        }

        # mock a stevedore provider extension
        def get_provider_by_name(name):
            obj_mock = self.provider_mocks[name]
            obj_mock.san_cert_cnames = ["san1", "san2"]
            obj_mock.akamai_sps_api_base_url = 'akamai_base_url/{spsId}'

            provider = mock.Mock(obj=obj_mock)
            return provider

        def provider_membership(key):
            return True if key in self.provider_mocks else False

        self.mock_providers = mock.MagicMock()
        self.mock_providers.__getitem__.side_effect = get_provider_by_name
        self.mock_providers.__contains__.side_effect = provider_membership
        self.manager_driver = driver.DefaultManagerDriver(
            conf, mock_storage, self.mock_providers, mock_dns,
            mock_distributed_task, mock_notification, mock_metrics)
        self.scc = ssl_certificate.DefaultSSLCertificateController(
            self.manager_driver)
Example #2
0
    def setUp(self, mock_metrics, mock_distributed_task, mock_storage,
              mock_dns, mock_notification, mock_bootstrap):

        super(DefaultSSLCertificateControllerTests, self).setUp()

        conf = cfg.ConfigOpts()
        conf.register_opts(aka_driver.AKAMAI_OPTIONS, aka_driver.AKAMAI_GROUP)
        conf.register_opts(n_driver.MAIL_NOTIFICATION_OPTIONS,
                           n_driver.MAIL_NOTIFICATION_GROUP)
        conf.set_override('san_cert_cnames',
                          ["san.example.com", "san2.example.com"],
                          group=aka_driver.AKAMAI_GROUP)
        self.addCleanup(conf.clear_override,
                        'san_cert_cnames',
                        group=aka_driver.AKAMAI_GROUP)
        conf.set_override('sni_cert_cnames',
                          ["sni.example.com", "sni2.example.com"],
                          group=aka_driver.AKAMAI_GROUP)
        self.addCleanup(conf.clear_override,
                        'sni_cert_cnames',
                        group=aka_driver.AKAMAI_GROUP)
        conf.set_override('akamai_https_access_url_suffix',
                          'edge.key.net',
                          group=aka_driver.AKAMAI_GROUP)
        self.addCleanup(conf.clear_override,
                        'akamai_https_access_url_suffix',
                        group=aka_driver.AKAMAI_GROUP)

        self.provider_mocks = {
            'akamai': mock.Mock(provider_name="Akamai"),
            'maxcdn': mock.Mock(provider_name='MaxCDN'),
            'cloudfront': mock.Mock(provider_name='CloudFront'),
            'fastly': mock.Mock(provider_name='Fastly'),
            'mock': mock.Mock(provider_name='Mock')
        }

        # mock a stevedore provider extension
        def get_provider_by_name(name):
            obj_mock = self.provider_mocks[name]
            obj_mock.san_cert_cnames = ["san.example.com", "san2.example.com"]
            obj_mock.akamai_sps_api_base_url = 'akamai_base_url/{spsId}'

            provider = mock.Mock(obj=obj_mock)
            return provider

        def provider_membership(key):
            return True if key in self.provider_mocks else False

        self.mock_storage = mock_storage
        self.mock_providers = mock.MagicMock()
        self.mock_providers.__getitem__.side_effect = get_provider_by_name
        self.mock_providers.__contains__.side_effect = provider_membership
        self.manager_driver = driver.DefaultManagerDriver(
            conf, mock_storage, self.mock_providers, mock_dns,
            mock_distributed_task, mock_notification, mock_metrics)
        self.bgc = background_job.BackgroundJobController(self.manager_driver)
Example #3
0
    def setUp(self, mock_driver, mock_provider):
        super(DefaultManagerServiceTests, self).setUp()

        # create mocked config and driver
        conf = cfg.ConfigOpts()
        manager_driver = driver.DefaultManagerDriver(conf, mock_driver,
                                                     mock_provider)

        # stubbed driver
        self.sc = services.DefaultServicesController(manager_driver)
Example #4
0
    def setUp(self, mock_driver, mock_provider, mock_dns,
              mock_distributed_task, mock_notification):
        super(DefaultManagerFlavorTests, self).setUp()

        # create mocked config and driver
        tests_path = os.path.abspath(
            os.path.dirname(
                os.path.dirname(os.path.dirname(os.path.dirname(__file__)))))
        conf_path = os.path.join(tests_path, 'etc', 'default_functional.conf')
        cfg.CONF(args=[], default_config_files=[conf_path])

        manager_driver = driver.DefaultManagerDriver(cfg.CONF, mock_driver,
                                                     mock_provider, mock_dns,
                                                     mock_distributed_task,
                                                     mock_notification)

        # stubbed driver
        self.fc = flavors.DefaultFlavorsController(manager_driver)
Example #5
0
    def setUp(self, mock_driver, mock_provider, mock_dns,
              mock_distributed_task, mock_notification, mock_metrics):
        super(DefaultManagerFlavorTests, self).setUp()

        # create mocked config and driver
        tests_path = os.path.abspath(
            os.path.dirname(
                os.path.dirname(os.path.dirname(os.path.dirname(__file__)))))
        conf_path = os.path.join(tests_path, 'etc', 'default_functional.conf')
        cfg.CONF(args=[], default_config_files=[conf_path])
        cfg.CONF.register_opts(bootstrap._DEFAULT_OPTIONS)
        cfg.CONF.register_opts(bootstrap._DRIVER_OPTIONS,
                               group=bootstrap._DRIVER_GROUP)

        manager_driver = driver.DefaultManagerDriver(cfg.CONF, mock_driver,
                                                     mock_provider, mock_dns,
                                                     mock_distributed_task,
                                                     mock_notification,
                                                     mock_metrics)

        # stubbed driver
        self.fc = flavors.DefaultFlavorsController(manager_driver)
Example #6
0
    def setUp(self, mock_metrics, mock_distributed_task, mock_storage,
              mock_dns, mock_notification):
        # NOTE(TheSriram): the mock.patch decorator applies mocks
        # in the reverse order of the arguments present
        super(DefaultManagerServiceTests, self).setUp()

        # create mocked config and driver
        conf = cfg.ConfigOpts()

        _DRIVER_DNS_OPTIONS = [
            cfg.IntOpt('retries',
                       default=5,
                       help='Total number of Retries after '
                       'Exponentially Backing Off'),
            cfg.IntOpt(
                'min_backoff_range',
                default=20,
                help='Minimum Number of seconds to sleep between retries'),
            cfg.IntOpt(
                'max_backoff_range',
                default=30,
                help='Maximum Number of seconds to sleep between retries'),
        ]

        _PROVIDER_OPTIONS = [
            cfg.IntOpt('default_cache_ttl',
                       default=86400,
                       help='Default ttl to be set, when no caching '
                       'rules are specified'),
        ]
        _MAX_SERVICE_OPTIONS = [
            cfg.IntOpt('max_services_per_project',
                       default=20,
                       help='Default max service per project_id')
        ]
        _DRIVER_DNS_GROUP = 'driver:dns'
        _PROVIDER_GROUP = 'drivers:provider'
        _MAX_SERVICE_GROUP = 'drivers:storage'

        conf.register_opts(_PROVIDER_OPTIONS, group=_PROVIDER_GROUP)
        conf.register_opts(_DRIVER_DNS_OPTIONS, group=_DRIVER_DNS_GROUP)
        conf.register_opts(_MAX_SERVICE_OPTIONS, group=_MAX_SERVICE_GROUP)
        self.max_services_per_project = \
            conf[_MAX_SERVICE_GROUP].max_services_per_project

        provider_mock = mock.Mock()
        provider_mock.obj = mock.Mock()
        provider_mock.obj.service_controller = mock.Mock()
        provider_mock.obj.service_controller.get_metrics_by_domain = \
            mock.Mock(return_value=dict())

        # mock a stevedore provider extension
        def get_provider_by_name(name):
            name_p_name_mapping = {
                'mock_provider': provider_mock,
                'maxcdn': 'MaxCDN',
                'cloudfront': 'CloudFront',
                'fastly': 'Fastly',
                'mock': 'Mock',
                'Provider': 'Provider'
            }
            if name == 'mock_provider':
                return name_p_name_mapping[name]
            else:
                return mock.Mock(obj=mock.Mock(
                    provider_name=(name_p_name_mapping[name])))

        mock_providers = mock.MagicMock()
        mock_providers.__getitem__.side_effect = get_provider_by_name

        manager_driver = driver.DefaultManagerDriver(conf, mock_storage,
                                                     mock_providers, mock_dns,
                                                     mock_distributed_task,
                                                     mock_notification,
                                                     mock_metrics)

        # stubbed driver

        self.sc = services.DefaultServicesController(manager_driver)
        self.manager = manager_driver
        self.project_id = str(uuid.uuid4())
        self.domain_name = str(uuid.uuid4())
Example #7
0
    def setUp(self, mock_distributed_task, mock_storage, mock_dns,
              mock_notification, mock_bootstrap):
        # NOTE(TheSriram): the mock.patch decorator applies mocks
        # in the reverse order of the arguments present
        super(DefaultManagerServiceTests, self).setUp()

        # create mocked config and driver
        conf = cfg.ConfigOpts()

        _DRIVER_DNS_OPTIONS = [
            cfg.IntOpt('retries',
                       default=5,
                       help='Total number of Retries after '
                       'Exponentially Backing Off'),
            cfg.IntOpt(
                'min_backoff_range',
                default=20,
                help='Minimum Number of seconds to sleep between retries'),
            cfg.IntOpt(
                'max_backoff_range',
                default=30,
                help='Maximum Number of seconds to sleep between retries'),
        ]

        _PROVIDER_OPTIONS = [
            cfg.IntOpt('default_cache_ttl',
                       default=86400,
                       help='Default ttl to be set, when no caching '
                       'rules are specified'),
        ]
        _MAX_SERVICE_OPTIONS = [
            cfg.IntOpt('max_services_per_project',
                       default=20,
                       help='Default max service per project_id')
        ]
        _DRIVER_DNS_GROUP = 'driver:dns'
        _PROVIDER_GROUP = 'drivers:provider'
        _MAX_SERVICE_GROUP = 'drivers:storage'

        conf.register_opts(_PROVIDER_OPTIONS, group=_PROVIDER_GROUP)
        conf.register_opts(_DRIVER_DNS_OPTIONS, group=_DRIVER_DNS_GROUP)
        conf.register_opts(_MAX_SERVICE_OPTIONS, group=_MAX_SERVICE_GROUP)
        self.max_services_per_project = \
            conf[_MAX_SERVICE_GROUP].max_services_per_project
        self.bootstrap_obj = mock_bootstrap(conf)

        # mock a stevedore provider extension
        def get_provider_by_name(name):
            name_p_name_mapping = {
                'maxcdn': 'MaxCDN',
                'cloudfront': 'CloudFront',
                'fastly': 'Fastly',
                'mock': 'Mock'
            }
            return mock.Mock(obj=mock.Mock(
                provider_name=(name_p_name_mapping[name])))

        mock_providers = mock.MagicMock()
        mock_providers.__getitem__.side_effect = get_provider_by_name
        manager_driver = driver.DefaultManagerDriver(conf, mock_storage,
                                                     mock_providers, mock_dns,
                                                     mock_distributed_task,
                                                     mock_notification)

        # stubbed driver
        self.sc = services.DefaultServicesController(manager_driver)
        self.bootstrap_obj.manager = manager_driver
        self.bootstrap_obj.manager.services_controller = self.sc
        self.project_id = str(uuid.uuid4())
        self.service_name = str(uuid.uuid4())
        self.service_id = str(uuid.uuid4())
        self.auth_token = str(uuid.uuid4())
        self.service_json = {
            "name":
            self.service_name,
            "domains": [
                {
                    "domain": "www.mywebsite.com"
                },
                {
                    "domain": "blog.mywebsite.com"
                },
            ],
            "origins": [{
                "origin": "mywebsite.com",
                "port": 80,
                "ssl": False
            }],
            "caching": [{
                "name": "default",
                "ttl": 3600
            }, {
                "name":
                "home",
                "ttl":
                17200,
                "rules": [{
                    "name": "index",
                    "request_url": "/index.htm"
                }]
            }, {
                "name":
                "images",
                "ttl":
                12800,
                "rules": [{
                    "name": "pictures",
                    "request_url": "/pictures.htm"
                }]
            }],
            "flavor_id":
            "standard",
            "log_delivery": {
                "enabled": False
            },
        }

        self.service_obj = service.load_from_json(self.service_json)
Example #8
0
    def setUp(self, mock_storage, mock_provider):
        super(DefaultManagerDriverTests, self).setUp()

        conf = cfg.ConfigOpts()
        self.driver = driver.DefaultManagerDriver(conf, mock_storage,
                                                  mock_provider)