Merge "Use get_auth_ref() rather than auth_ref property"

This commit is contained in:
Jenkins 2016-06-14 10:56:48 +00:00 committed by Gerrit Code Review
commit c0b621b35b
2 changed files with 9 additions and 4 deletions

View File

@ -142,8 +142,10 @@ class ClientPlugin(object):
version = self.default_version
if version in self._client_instances:
auth_ref = self.context.auth_plugin.get_auth_ref(
self._keystone_session)
if (cfg.CONF.reauthentication_auth_method == 'trusts'
and self.context.auth_plugin.auth_ref.will_expire_soon(
and auth_ref.will_expire_soon(
cfg.CONF.stale_token_duration)):
# If the token is near expiry, force creating a new client,
# which will get a new token via another call to auth_token

View File

@ -363,15 +363,18 @@ class ClientPluginTest(common.HeatTestCase):
def test_create_client_on_token_expiration(self):
cfg.CONF.set_override('reauthentication_auth_method', 'trusts',
enforce_type=True)
con = mock.Mock()
con.auth_plugin.auth_ref.will_expire_soon.return_value = False
con = utils.dummy_context()
auth_ref = mock.Mock()
self.patchobject(con.auth_plugin, 'get_auth_ref',
return_value=auth_ref)
auth_ref.will_expire_soon.return_value = False
plugin = FooClientsPlugin(con)
plugin._create = mock.Mock()
plugin.client()
self.assertEqual(1, plugin._create.call_count)
plugin.client()
self.assertEqual(1, plugin._create.call_count)
con.auth_plugin.auth_ref.will_expire_soon.return_value = True
auth_ref.will_expire_soon.return_value = True
plugin.client()
self.assertEqual(2, plugin._create.call_count)