summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-09-12 05:29:29 +0000
committerGerrit Code Review <review@openstack.org>2018-09-12 05:29:29 +0000
commit58ac4c059ae8e0feb7272884833e5633c45bef48 (patch)
treee7d6b876e3b2124ef54ea4b99466dca3c932d46f
parent400925364306408da9d0a7514f3e628c5727b626 (diff)
parent2585047ffceadeb79864008c81f3ff0f07a24d5f (diff)
Merge "Protect against endpoint_data not existing"3.11.0
-rw-r--r--keystoneauth1/plugin.py4
-rw-r--r--keystoneauth1/tests/unit/test_discovery.py23
2 files changed, 26 insertions, 1 deletions
diff --git a/keystoneauth1/plugin.py b/keystoneauth1/plugin.py
index 74970af..f27a9e1 100644
--- a/keystoneauth1/plugin.py
+++ b/keystoneauth1/plugin.py
@@ -149,7 +149,9 @@ class BaseAuthPlugin(object):
149 endpoint_data = self.get_endpoint_data( 149 endpoint_data = self.get_endpoint_data(
150 session, endpoint_override=endpoint_override, 150 session, endpoint_override=endpoint_override,
151 discover_versions=False, **kwargs) 151 discover_versions=False, **kwargs)
152 return endpoint_data.api_version 152 if endpoint_data:
153 return endpoint_data.api_version
154 return None
153 155
154 def get_endpoint(self, session, **kwargs): 156 def get_endpoint(self, session, **kwargs):
155 """Return an endpoint for the client. 157 """Return an endpoint for the client.
diff --git a/keystoneauth1/tests/unit/test_discovery.py b/keystoneauth1/tests/unit/test_discovery.py
index b0cdd9c..241afe5 100644
--- a/keystoneauth1/tests/unit/test_discovery.py
+++ b/keystoneauth1/tests/unit/test_discovery.py
@@ -560,6 +560,29 @@ class VersionDataTests(utils.TestCase):
560 560
561 self.assertTrue(mock.called_once) 561 self.assertTrue(mock.called_once)
562 562
563 def test_version_data_legacy_ironic_no_override(self):
564 """Validate detection of legacy Ironic microversion ranges."""
565 ironic_url = 'https://bare-metal.example.com/v1/'
566 self.requests_mock.get(
567 ironic_url, status_code=200,
568 json={
569 'id': 'v1',
570 'links': [{
571 "href": ironic_url,
572 "rel": "self"}]},
573 headers={
574 'X-OpenStack-Ironic-API-Minimum-Version': '1.3',
575 'X-OpenStack-Ironic-API-Maximum-Version': '1.21',
576 })
577
578 plugin = noauth.NoAuth()
579 a = adapter.Adapter(
580 self.session,
581 auth=plugin,
582 service_type='baremetal')
583
584 self.assertIsNone(a.get_api_major_version())
585
563 def test_version_data_ironic_microversions(self): 586 def test_version_data_ironic_microversions(self):
564 """Validate detection of Ironic microversion ranges.""" 587 """Validate detection of Ironic microversion ranges."""
565 ironic_url = 'https://bare-metal.example.com/v1/' 588 ironic_url = 'https://bare-metal.example.com/v1/'