summaryrefslogtreecommitdiff
path: root/heat/tests/test_common_context.py
diff options
context:
space:
mode:
authorhuangtianhua <huangtianhua@huawei.com>2016-01-14 10:18:38 +0800
committerhuangtianhua <huangtianhua@huawei.com>2016-01-18 11:42:03 +0800
commit82687a60f45e6a4c0d3c5252529ba5fa8193bcd0 (patch)
tree2b54d386dd1e7a2f867df95c32436f2bcb3cd097 /heat/tests/test_common_context.py
parent7e3e4087f476a0431d1d278730b1736e02e5fd06 (diff)
downloadheat-82687a60f45e6a4c0d3c5252529ba5fa8193bcd0.tar.gz
Use correct user_domain_id when create trust auth plugin
This patch will attempt to get cfg.CONF.keystone_authtoken.user_domain_id as 'user_domain_id' when create trust auth plugin, and only if the conf is not set switch to 'default' domain. Change-Id: Icce69dcbdf917fab6644f48f71c4eeb6926d9d6e Closes-Bug: #1533928
Diffstat (limited to 'heat/tests/test_common_context.py')
-rw-r--r--heat/tests/test_common_context.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/heat/tests/test_common_context.py b/heat/tests/test_common_context.py
index a7c915e56..1a03f7ccf 100644
--- a/heat/tests/test_common_context.py
+++ b/heat/tests/test_common_context.py
@@ -183,6 +183,28 @@ class TestRequestContext(common.HeatTestCase):
self.assertRaises(exception.AuthorizationFailure, getattr, ctx,
'keystone_v3_endpoint')
+ def test_create_trusts_auth_plugin_with_correct_user_domain_id(self):
+ importutils.import_module('keystonemiddleware.auth_token')
+ cfg.CONF.set_override('auth_uri', 'http://abc/v2.0',
+ group='keystone_authtoken')
+ cfg.CONF.set_override('admin_user', 'heat',
+ group='keystone_authtoken')
+ cfg.CONF.set_override('admin_password', 'password',
+ group='keystone_authtoken')
+ policy_check = 'heat.common.policy.Enforcer.check_is_admin'
+ with mock.patch(policy_check) as pc:
+ pc.return_value = False
+ ctx = context.RequestContext(auth_url=None,
+ user_domain_id='non-default',
+ username='test')
+ with mock.patch('keystoneclient.auth.identity.v3.Password') as ps:
+ ctx.trusts_auth_plugin
+ ps.assert_called_once_with(username='heat',
+ password='password',
+ user_domain_id='default',
+ auth_url='http://abc/v3',
+ trust_id=None)
+
class RequestContextMiddlewareTest(common.HeatTestCase):