diff options
author | 2016-12-07 21:24:24 -0500 | |
---|---|---|
committer | 2016-12-14 04:06:25 -0500 | |
commit | 703d4477d2385d3c654cdac549b936c08b9c5b31 (patch) | |
tree | 4305d2b9c36c74253336e112b94e385fd2afc77b /functest/tests/unit/odl/test_odl.py | |
parent | 7bb9e652122482a31992901c9eae7429624aabdf (diff) |
Authenticate clients with keystoneauth1.session
JIRA: FUNCTEST-529
1. use keystoneauth1.session to initialize the client for each service
The keystoneauth1.session.Session class was introduced into keystoneauth1 as an attempt
to bring a unified interface to the various OpenStack clients that share common authentication
and request parameters between a variety of services.
2. update ODL case to leverage session to get the endpoint info
Change-Id: Ic8c01b9b7ed86d3bdd9f5125504bc47f46a37700
Signed-off-by: helenyao <yaohelan@huawei.com>
Diffstat (limited to 'functest/tests/unit/odl/test_odl.py')
-rwxr-xr-x[-rw-r--r--] | functest/tests/unit/odl/test_odl.py | 43 |
1 files changed, 15 insertions, 28 deletions
diff --git a/functest/tests/unit/odl/test_odl.py b/functest/tests/unit/odl/test_odl.py index ef18016b..c29bfd7f 100644..100755 --- a/functest/tests/unit/odl/test_odl.py +++ b/functest/tests/unit/odl/test_odl.py @@ -59,14 +59,6 @@ class ODLTesting(unittest.TestCase): else: return None - @classmethod - def _get_fake_keystone_client(cls): - kclient = mock.Mock() - kclient.service_catalog = mock.Mock() - kclient.service_catalog.url_for = mock.Mock( - side_effect=cls._fake_url_for) - return kclient - def _get_main_kwargs(self, key=None): kwargs = {'odlusername': self._odl_username, 'odlpassword': self._odl_password, @@ -247,8 +239,9 @@ class ODLTesting(unittest.TestCase): def _test_run(self, status=testcase_base.TestcaseBase.EX_OK, exception=None, odlip="127.0.0.3", odlwebport="8080"): - with mock.patch('functest.utils.openstack_utils.get_keystone_client', - return_value=self._get_fake_keystone_client()): + with mock.patch('functest.utils.openstack_utils.get_endpoint', + side_effect=[self._fake_url_for('identity'), + self._fake_url_for('network')]): if exception: self.test.main = mock.Mock(side_effect=exception) else: @@ -288,12 +281,10 @@ class ODLTesting(unittest.TestCase): odlwebport=self._odl_webport) def test_run_missing_sdn_controller_ip(self): - with mock.patch('functest.utils.openstack_utils.get_keystone_client', - return_value=self._get_fake_keystone_client()): - ft_constants.CI_INSTALLER_TYPE = None - ft_constants.SDN_CONTROLLER_IP = None - self.assertEqual(self.test.run(), - testcase_base.TestcaseBase.EX_RUN_ERROR) + ft_constants.CI_INSTALLER_TYPE = None + ft_constants.SDN_CONTROLLER_IP = None + self.assertEqual(self.test.run(), + testcase_base.TestcaseBase.EX_RUN_ERROR) def test_run_without_installer_type(self): ft_constants.SDN_CONTROLLER_IP = self._sdn_controller_ip @@ -308,12 +299,10 @@ class ODLTesting(unittest.TestCase): odlip=self._neutron_ip, odlwebport='8282') def test_run_apex_missing_sdn_controller_ip(self): - with mock.patch('functest.utils.openstack_utils.get_keystone_client', - return_value=self._get_fake_keystone_client()): - ft_constants.CI_INSTALLER_TYPE = "apex" - ft_constants.SDN_CONTROLLER_IP = None - self.assertEqual(self.test.run(), - testcase_base.TestcaseBase.EX_RUN_ERROR) + ft_constants.CI_INSTALLER_TYPE = "apex" + ft_constants.SDN_CONTROLLER_IP = None + self.assertEqual(self.test.run(), + testcase_base.TestcaseBase.EX_RUN_ERROR) def test_run_apex(self): ft_constants.SDN_CONTROLLER_IP = self._sdn_controller_ip @@ -322,12 +311,10 @@ class ODLTesting(unittest.TestCase): odlip=self._sdn_controller_ip, odlwebport='8181') def test_run_joid_missing_sdn_controller(self): - with mock.patch('functest.utils.openstack_utils.get_keystone_client', - return_value=self._get_fake_keystone_client()): - ft_constants.CI_INSTALLER_TYPE = "joid" - ft_constants.SDN_CONTROLLER = None - self.assertEqual(self.test.run(), - testcase_base.TestcaseBase.EX_RUN_ERROR) + ft_constants.CI_INSTALLER_TYPE = "joid" + ft_constants.SDN_CONTROLLER = None + self.assertEqual(self.test.run(), + testcase_base.TestcaseBase.EX_RUN_ERROR) def test_run_joid(self): ft_constants.SDN_CONTROLLER = self._sdn_controller_ip |