From c5455ba8d9dbe2384284868fa2aea3503f9d8222 Mon Sep 17 00:00:00 2001 From: Jamie Lennox Date: Tue, 11 Nov 2014 15:20:36 +1000 Subject: [PATCH] Fix importing config module and classmethod params The Token/Endpoint options specify an instance method where the expectation is a classmethod. This prevents the class being loaded from config file or CLI. The cfg module was not imported so loading plugins would raise an AttributeError. Change-Id: I33b4a8c181210d74d4779438afc1f918e06df85b --- keystoneclient/auth/token_endpoint.py | 6 ++++-- keystoneclient/tests/auth/test_token_endpoint.py | 10 ++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/keystoneclient/auth/token_endpoint.py b/keystoneclient/auth/token_endpoint.py index 1f031d22..1a04b9d7 100644 --- a/keystoneclient/auth/token_endpoint.py +++ b/keystoneclient/auth/token_endpoint.py @@ -10,6 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. +from oslo.config import cfg from keystoneclient.auth import base @@ -38,8 +39,9 @@ class Token(base.BaseAuthPlugin): """ return self.endpoint - def get_options(self): - options = super(Token, self).get_options() + @classmethod + def get_options(cls): + options = super(Token, cls).get_options() options.extend([ cfg.StrOpt('endpoint', diff --git a/keystoneclient/tests/auth/test_token_endpoint.py b/keystoneclient/tests/auth/test_token_endpoint.py index 1f2c01d6..a9028e37 100644 --- a/keystoneclient/tests/auth/test_token_endpoint.py +++ b/keystoneclient/tests/auth/test_token_endpoint.py @@ -10,6 +10,8 @@ # License for the specific language governing permissions and limitations # under the License. +from testtools import matchers + from keystoneclient.auth import token_endpoint from keystoneclient import session from keystoneclient.tests import utils @@ -43,3 +45,11 @@ class TokenEndpointTest(utils.TestCase): self.assertEqual(self.TEST_URL, a.get_endpoint(s)) self.assertEqual('body', data.text) self.assertRequestHeaderEqual('X-Auth-Token', self.TEST_TOKEN) + + def test_token_endpoint_options(self): + opt_names = [opt.name for opt in token_endpoint.Token.get_options()] + + self.assertThat(opt_names, matchers.HasLength(2)) + + self.assertIn('token', opt_names) + self.assertIn('endpoint', opt_names)