Merge "Use get_auth_ref() rather than auth_ref property"
This commit is contained in:
commit
c0b621b35b
@ -142,8 +142,10 @@ class ClientPlugin(object):
|
|||||||
version = self.default_version
|
version = self.default_version
|
||||||
|
|
||||||
if version in self._client_instances:
|
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'
|
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)):
|
cfg.CONF.stale_token_duration)):
|
||||||
# If the token is near expiry, force creating a new client,
|
# If the token is near expiry, force creating a new client,
|
||||||
# which will get a new token via another call to auth_token
|
# which will get a new token via another call to auth_token
|
||||||
|
@ -363,15 +363,18 @@ class ClientPluginTest(common.HeatTestCase):
|
|||||||
def test_create_client_on_token_expiration(self):
|
def test_create_client_on_token_expiration(self):
|
||||||
cfg.CONF.set_override('reauthentication_auth_method', 'trusts',
|
cfg.CONF.set_override('reauthentication_auth_method', 'trusts',
|
||||||
enforce_type=True)
|
enforce_type=True)
|
||||||
con = mock.Mock()
|
con = utils.dummy_context()
|
||||||
con.auth_plugin.auth_ref.will_expire_soon.return_value = False
|
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 = FooClientsPlugin(con)
|
||||||
plugin._create = mock.Mock()
|
plugin._create = mock.Mock()
|
||||||
plugin.client()
|
plugin.client()
|
||||||
self.assertEqual(1, plugin._create.call_count)
|
self.assertEqual(1, plugin._create.call_count)
|
||||||
plugin.client()
|
plugin.client()
|
||||||
self.assertEqual(1, plugin._create.call_count)
|
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()
|
plugin.client()
|
||||||
self.assertEqual(2, plugin._create.call_count)
|
self.assertEqual(2, plugin._create.call_count)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user