From d7513d5bf0c1b7b37ef78290849ab0217561428d Mon Sep 17 00:00:00 2001 From: Zhongcheng Lao Date: Thu, 13 Aug 2015 20:26:19 +0800 Subject: [PATCH] Fixed insecure and cacert not passed to user context insecure and cacert settings are not inherited by the context users, in which case the testing will be failed by the unsuccessful requests. Change-Id: Ie452488d7aaf9d742e86b9a4dd388af4b5dc16cc --- .../plugins/openstack/context/keystone/users.py | 4 +++- .../openstack/context/keystone/test_users.py | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/rally/plugins/openstack/context/keystone/users.py b/rally/plugins/openstack/context/keystone/users.py index 873b56c2..3fd0e887 100644 --- a/rally/plugins/openstack/context/keystone/users.py +++ b/rally/plugins/openstack/context/keystone/users.py @@ -223,7 +223,9 @@ class UserGenerator(UserContextMixin, context.Context): self.context["tenants"][tenant_id]["name"], consts.EndpointPermission.USER, client.region_name, project_domain_name=project_dom, user_domain_name=user_dom, - endpoint_type=self.endpoint.endpoint_type) + endpoint_type=self.endpoint.endpoint_type, + https_insecure=self.endpoint.insecure, + https_cacert=self.endpoint.cacert) users.append({"id": user.id, "endpoint": user_endpoint, "tenant_id": tenant_id}) diff --git a/tests/unit/plugins/openstack/context/keystone/test_users.py b/tests/unit/plugins/openstack/context/keystone/test_users.py index bbdc087e..602015d9 100644 --- a/tests/unit/plugins/openstack/context/keystone/test_users.py +++ b/tests/unit/plugins/openstack/context/keystone/test_users.py @@ -317,6 +317,9 @@ class UserGeneratorTestCase(test.TestCase): mock_keystone.wrap.return_value = wrapped_keystone task = {"uuid": "abcdef"} + endpoint = objects.Endpoint("foo_url", "foo", "foo_pass", + https_insecure=True, + https_cacert="cacert") config = { "config": { "users": { @@ -325,10 +328,11 @@ class UserGeneratorTestCase(test.TestCase): "resource_management_workers": 1 } }, - "admin": {"endpoint": mock.MagicMock()}, + "admin": {"endpoint": endpoint}, "task": task } + endpoint_dict = endpoint.to_dict(False) user_list = [mock.MagicMock(id="id_%d" % i) for i in range(self.users_num)] wrapped_keystone.create_user.side_effect = user_list @@ -347,6 +351,17 @@ class UserGeneratorTestCase(test.TestCase): self.assertEqual(set(["id", "endpoint", "tenant_id"]), set(user.keys())) + user_endpoint_dict = user["endpoint"].to_dict(False) + + excluded_keys = ["auth_url", "username", "password", + "tenant_name", "region_name", + "project_domain_name", + "admin_domain_name", + "user_domain_name"] + for key in (set(endpoint_dict.keys()) - set(excluded_keys)): + self.assertEqual(endpoint_dict[key], + user_endpoint_dict[key]) + tenants_ids = [] for t in ctx.context["tenants"].keys(): tenants_ids.append(t)