diff --git a/rally/osclients.py b/rally/osclients.py index 165e4a5578..2e22e35d8e 100644 --- a/rally/osclients.py +++ b/rally/osclients.py @@ -99,7 +99,8 @@ class Clients(object): kw = dict(self.endpoint.to_dict().items() + new_kw.items()) if kw["endpoint_type"] == consts.EndpointType.PUBLIC: mgmt_url = urlparse.urlparse(kw["auth_url"]) - if mgmt_url.port != kw["admin_port"]: + if (mgmt_url.port != kw["admin_port"] and + mgmt_url.scheme != "https"): kw["endpoint"] = "{0}://{1}:{2}{3}".format( mgmt_url.scheme, mgmt_url.hostname, diff --git a/tests/unit/test_osclients.py b/tests/unit/test_osclients.py index a5c5f01470..d31b54162d 100644 --- a/tests/unit/test_osclients.py +++ b/tests/unit/test_osclients.py @@ -33,7 +33,10 @@ class OSClientsTestCase(test.TestCase): super(OSClientsTestCase, self).setUp() self.endpoint = endpoint.Endpoint("http://auth_url", "use", "pass", "tenant") + self.endpoint_https = endpoint.Endpoint("https://auth_url/v2.0/admin", + "use", "pass", "tenant") self.clients = osclients.Clients(self.endpoint) + self.clients_https = osclients.Clients(self.endpoint_https) self.fake_keystone = fakes.FakeKeystoneClient() self.fake_keystone.auth_token = mock.MagicMock() @@ -64,6 +67,18 @@ class OSClientsTestCase(test.TestCase): self.mock_create_keystone_client.assert_called_once_with(kwargs) self.assertEqual(self.clients.cache["keystone"], self.fake_keystone) + def test_keystone_with_https_auth_url(self): + self.assertNotIn("keystone", self.clients_https.cache) + client = self.clients_https.keystone() + self.assertEqual(client, self.fake_keystone) + endpoint = {"timeout": cfg.CONF.openstack_client_http_timeout, + "insecure": False, "cacert": None, + "endpoint": self.endpoint_https.auth_url} + kwargs = dict(self.endpoint_https.to_dict().items() + endpoint.items()) + self.mock_create_keystone_client.assert_called_once_with(kwargs) + self.assertEqual(self.clients_https.cache["keystone"], + self.fake_keystone) + @mock.patch("rally.osclients.Clients.keystone") def test_verified_keystone_user_not_admin(self, mock_keystone): mock_keystone.return_value = fakes.FakeKeystoneClient()