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
This commit is contained in:
Zhongcheng Lao 2015-08-13 20:26:19 +08:00
parent 1fe46a8273
commit d7513d5bf0
2 changed files with 19 additions and 2 deletions

View File

@ -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})

View File

@ -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)