diff --git a/keystoneauth1/plugin.py b/keystoneauth1/plugin.py index 74970af5..f27a9e1a 100644 --- a/keystoneauth1/plugin.py +++ b/keystoneauth1/plugin.py @@ -149,7 +149,9 @@ class BaseAuthPlugin(object): endpoint_data = self.get_endpoint_data( session, endpoint_override=endpoint_override, discover_versions=False, **kwargs) - return endpoint_data.api_version + if endpoint_data: + return endpoint_data.api_version + return None def get_endpoint(self, session, **kwargs): """Return an endpoint for the client. diff --git a/keystoneauth1/tests/unit/test_discovery.py b/keystoneauth1/tests/unit/test_discovery.py index b0cdd9c0..241afe55 100644 --- a/keystoneauth1/tests/unit/test_discovery.py +++ b/keystoneauth1/tests/unit/test_discovery.py @@ -560,6 +560,29 @@ class VersionDataTests(utils.TestCase): self.assertTrue(mock.called_once) + def test_version_data_legacy_ironic_no_override(self): + """Validate detection of legacy Ironic microversion ranges.""" + ironic_url = 'https://bare-metal.example.com/v1/' + self.requests_mock.get( + ironic_url, status_code=200, + json={ + 'id': 'v1', + 'links': [{ + "href": ironic_url, + "rel": "self"}]}, + headers={ + 'X-OpenStack-Ironic-API-Minimum-Version': '1.3', + 'X-OpenStack-Ironic-API-Maximum-Version': '1.21', + }) + + plugin = noauth.NoAuth() + a = adapter.Adapter( + self.session, + auth=plugin, + service_type='baremetal') + + self.assertIsNone(a.get_api_major_version()) + def test_version_data_ironic_microversions(self): """Validate detection of Ironic microversion ranges.""" ironic_url = 'https://bare-metal.example.com/v1/'