diff options
author | Tzu-Mainn Chen <tzumainn@redhat.com> | 2020-02-18 19:21:12 +0000 |
---|---|---|
committer | Tzu-Mainn Chen <tzumainn@redhat.com> | 2020-04-03 14:32:57 +0000 |
commit | d15d2f09fb143273510f58ff0175c352bb931b7e (patch) | |
tree | 5f193b5eb6aa8fd55fd2abede3c7917a1cdf0aa6 /ironic/tests/unit/drivers/modules/network/test_common.py | |
parent | b148cabdb2cc6810b09e8bfbc500d15969c0f164 (diff) | |
download | ironic-d15d2f09fb143273510f58ff0175c352bb931b7e.tar.gz |
Use auth values from neutron conf when managing Neutron ports
Using the auth values from the neutron section of the Ironic
configuration prevents issues where a non-admin user is not
allowed to manage Neutron ports.
Change-Id: I66cf1acba10a7b7b82f5a2a55453c3d5a29a086e
Story: #2006506
Task: #38789
Diffstat (limited to 'ironic/tests/unit/drivers/modules/network/test_common.py')
-rw-r--r-- | ironic/tests/unit/drivers/modules/network/test_common.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/ironic/tests/unit/drivers/modules/network/test_common.py b/ironic/tests/unit/drivers/modules/network/test_common.py index b8b418230..eedd907f6 100644 --- a/ironic/tests/unit/drivers/modules/network/test_common.py +++ b/ironic/tests/unit/drivers/modules/network/test_common.py @@ -400,22 +400,26 @@ class TestCommonFunctions(db_base.DbTestCase): common.get_free_port_like_object, task, self.vif_id, {'physnet2'}) + @mock.patch.object(neutron_common, 'update_neutron_port', autospec=True) @mock.patch.object(neutron_common, 'get_client', autospec=True) - def test_plug_port_to_tenant_network_client(self, mock_gc): + def test_plug_port_to_tenant_network_client(self, mock_gc, mock_update): self.port.internal_info = {common.TENANT_VIF_KEY: self.vif_id} self.port.save() with task_manager.acquire(self.context, self.node.id) as task: common.plug_port_to_tenant_network(task, self.port, client=mock.MagicMock()) self.assertFalse(mock_gc.called) + self.assertTrue(mock_update.called) + @mock.patch.object(neutron_common, 'update_neutron_port', autospec=True) @mock.patch.object(neutron_common, 'get_client', autospec=True) - def test_plug_port_to_tenant_network_no_client(self, mock_gc): + def test_plug_port_to_tenant_network_no_client(self, mock_gc, mock_update): self.port.internal_info = {common.TENANT_VIF_KEY: self.vif_id} self.port.save() with task_manager.acquire(self.context, self.node.id) as task: common.plug_port_to_tenant_network(task, self.port) self.assertTrue(mock_gc.called) + self.assertTrue(mock_update.called) @mock.patch.object(neutron_common, 'get_client', autospec=True) def test_plug_port_to_tenant_network_no_tenant_vif(self, mock_gc): @@ -432,9 +436,10 @@ class TestCommonFunctions(db_base.DbTestCase): @mock.patch.object(neutron_common, 'wait_for_host_agent', autospec=True) @mock.patch.object(neutron_common, 'wait_for_port_status', autospec=True) + @mock.patch.object(neutron_common, 'update_neutron_port', autospec=True) @mock.patch.object(neutron_common, 'get_client', autospec=True) def test_plug_port_to_tenant_network_smartnic_port( - self, mock_gc, wait_port_mock, wait_agent_mock): + self, mock_gc, mock_update, wait_port_mock, wait_agent_mock): nclient = mock.MagicMock() mock_gc.return_value = nclient local_link_connection = self.port.local_link_connection @@ -449,6 +454,7 @@ class TestCommonFunctions(db_base.DbTestCase): nclient, 'hostname') wait_port_mock.assert_called_once_with( nclient, self.vif_id, 'ACTIVE') + self.assertTrue(mock_update.called) class TestVifPortIDMixin(db_base.DbTestCase): |