From ff37756243a534ba83a0d08803fd3b118df1cb1a Mon Sep 17 00:00:00 2001 From: Jamie Lennox Date: Tue, 28 Apr 2015 15:40:22 +1000 Subject: [PATCH] Modify tests to load trustee user from plugin Use the new auth plugin format to load authentication for the trustee user rather than reading it from auth_token middleware options. By doing the test modification as a separate patch we are assured that the older style auth loading and the new one both work. Change-Id: I72d81bd96b183d32697cbf259187ac0df13028c4 --- heat/tests/clients/test_heat_client.py | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/heat/tests/clients/test_heat_client.py b/heat/tests/clients/test_heat_client.py index 2defbfb594..d4e5289a87 100644 --- a/heat/tests/clients/test_heat_client.py +++ b/heat/tests/clients/test_heat_client.py @@ -15,6 +15,7 @@ import json import uuid from keystoneclient import access as ks_access +from keystoneclient import auth as ks_auth from keystoneclient.auth.identity import access as ks_auth_access from keystoneclient.auth.identity import v3 as ks_auth_v3 from keystoneclient.auth import token_endpoint as ks_token_endpoint @@ -51,19 +52,14 @@ class KeystoneClientTest(common.HeatTestCase): self.m.StubOutWithMock(ks_auth_v3, 'Password') self.m.StubOutWithMock(ks_token_endpoint, 'Token') self.m.StubOutWithMock(ks_auth_access, 'AccessInfoPlugin') + self.m.StubOutWithMock(ks_auth, 'load_from_conf_options') - dummy_url = 'http://server.test:5000/v2.0' - cfg.CONF.set_override('auth_uri', dummy_url, - group='keystone_authtoken') - cfg.CONF.set_override('admin_user', 'heat', - group='keystone_authtoken') - cfg.CONF.set_override('admin_password', 'verybadpass', - group='keystone_authtoken') - cfg.CONF.set_override('admin_tenant_name', 'service', + cfg.CONF.set_override('auth_uri', 'http://server.test:5000/v2.0', group='keystone_authtoken') cfg.CONF.set_override('stack_user_domain_id', 'adomain123') cfg.CONF.set_override('stack_domain_admin', 'adminuser123') cfg.CONF.set_override('stack_domain_admin_password', 'adminsecret') + self.addCleanup(self.m.VerifyAll) def _clear_domain_override(self): @@ -78,11 +74,7 @@ class KeystoneClientTest(common.HeatTestCase): else: a.AndRaise(kc_exception.Unauthorized) - m = ks_auth_v3.Password(auth_url='http://server.test:5000/v3', - password='verybadpass', - user_domain_id='default', - username='heat', - trust_id=None) + m = ks_auth.load_from_conf_options(cfg.CONF, 'trustee', trust_id=None) m.AndReturn(mock_ks_auth) def _stub_domain_admin_client(self, domain_id=None): @@ -126,11 +118,9 @@ class KeystoneClientTest(common.HeatTestCase): user_domain_id='default') elif method == 'trust': - p = ks_auth_v3.Password(auth_url='http://server.test:5000/v3', - username='heat', - password='verybadpass', - user_domain_id='default', - trust_id='atrust123') + p = ks_auth.load_from_conf_options(cfg.CONF, + 'trustee', + trust_id='atrust123') mock_auth_ref.user_id = user_id or 'trustor_user_id' mock_auth_ref.project_id = project_id or 'test_tenant_id'