Debian Codegraph @

neutron_fwaas/tests/unit/services/firewall/service_drivers/agents/test_firewall_service.py

raw symbols SCIP
1 # Copyright 2014 OpenStack Foundation.
2 # All Rights Reserved.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License"); you may
5 # not use this file except in compliance with the License. You may obtain
6 # a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 # License for the specific language governing permissions and limitations
14 # under the License.
15
16 from neutron.tests import base
17 from oslo_config import cfg
18
19 from neutron_fwaas.services.firewall.service_drivers.agents import\
20 firewall_service
21
22 FWAAS_NOP_DEVICE = ('neutron_fwaas.tests.unit.services.firewall.'
23 'service_drivers.agents.test_firewall_agent_api.'
24 'NoopFwaasDriverV2')
25
26
27 class TestFirewallDeviceDriverLoading(base.BaseTestCase):
28
29 def setUp(self):
30 super().setUp()
31 self.service = firewall_service.FirewallService()
32
33 def test_loading_firewall_device_driver(self):
34 """Get the sole device driver for FWaaS."""
35 cfg.CONF.set_override('driver',
36 FWAAS_NOP_DEVICE,
37 'fwaas')
38 driver = self.service.load_device_drivers()
39 self.assertIsNotNone(driver)
40 self.assertIn(driver.__class__.__name__, FWAAS_NOP_DEVICE)
41
42 def test_fail_no_such_firewall_device_driver(self):
43 """Failure test of import error for FWaaS device driver."""
44 cfg.CONF.set_override('driver',
45 'no.such.class',
46 'fwaas')
47 self.assertRaises(ImportError,
48 self.service.load_device_drivers)
49
50 def test_fail_firewall_no_device_driver_specified(self):
51 """Failure test when no FWaaS device driver is specified.
52
53 This is a configuration error, as the user must specify a device
54 driver, when enabling the firewall service (and there is no default
55 configuration set. We'll simulate that by using an empty string.
56 """
57 cfg.CONF.set_override('driver',
58 '',
59 'fwaas')
60 self.assertRaises(ValueError,
61 self.service.load_device_drivers)