Merge "Fix AttributeError in check allowed port fields"
This commit is contained in:
commit
2381c081f0
@ -443,10 +443,10 @@ class PortsController(rest.RestController):
|
||||
if ('local_link_connection/network_type' in fields
|
||||
and not api_utils.allow_local_link_connection_network_type()):
|
||||
raise exception.NotAcceptable()
|
||||
if isinstance(fields, dict):
|
||||
if (isinstance(fields, dict)
|
||||
and fields.get('local_link_connection') is not None):
|
||||
if (not api_utils.allow_local_link_connection_network_type()
|
||||
and 'network_type' in fields.get('local_link_connection',
|
||||
{}).keys()):
|
||||
and 'network_type' in fields['local_link_connection']):
|
||||
raise exception.NotAcceptable()
|
||||
|
||||
@METRICS.timer('PortsController.get_all')
|
||||
|
@ -185,6 +185,15 @@ class TestPortsController__CheckAllowedPortFields(base.TestCase):
|
||||
self.assertFalse(mock_allow_portgroup.called)
|
||||
mock_allow_physnet.assert_called_once_with()
|
||||
|
||||
def test__check_allowed_port_fields_local_link_connection_none_type(
|
||||
self, mock_allow_port, mock_allow_portgroup, mock_allow_physnet):
|
||||
mock_allow_port.return_value = True
|
||||
mock_allow_physnet.return_value = True
|
||||
self.assertIsNone(
|
||||
self.controller._check_allowed_port_fields(
|
||||
{'local_link_connection': None}))
|
||||
mock_allow_port.assert_called_once_with()
|
||||
|
||||
|
||||
class TestListPorts(test_api_base.BaseApiTest):
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user