1 # Copyright (c) 2015 OpenStack Foundation.
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
8 # http://www.apache.org/licenses/LICENSE-2.0
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
16 from neutron.extensions import portsecurity as psec
17 from neutron.plugins.ml2.extensions import port_security
18 from neutron.tests.unit.plugins.ml2 import test_plugin
21 class TestML2ExtensionPortSecurity(test_plugin.Ml2PluginV2TestCase):
22 def test_extend_port_dict_no_port_security(self):
23 """Test _extend_port_security_dict won't crash
24 if port_security item is None
26 for db_data in ({'port_security': None, 'name': 'net1'}, {}):
29 driver = port_security.PortSecurityExtensionDriver()
30 driver._extend_port_security_dict(response_data, db_data)
32 self.assertTrue(response_data[psec.PORTSECURITY])