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
This commit is contained in:
Jamie Lennox
2014-11-11 15:20:36 +10:00
parent d54bd32cd0
commit c5455ba8d9
2 changed files with 14 additions and 2 deletions

View File

@@ -10,6 +10,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo.config import cfg
from keystoneclient.auth import base from keystoneclient.auth import base
@@ -38,8 +39,9 @@ class Token(base.BaseAuthPlugin):
""" """
return self.endpoint return self.endpoint
def get_options(self): @classmethod
options = super(Token, self).get_options() def get_options(cls):
options = super(Token, cls).get_options()
options.extend([ options.extend([
cfg.StrOpt('endpoint', cfg.StrOpt('endpoint',

View File

@@ -10,6 +10,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from testtools import matchers
from keystoneclient.auth import token_endpoint from keystoneclient.auth import token_endpoint
from keystoneclient import session from keystoneclient import session
from keystoneclient.tests import utils from keystoneclient.tests import utils
@@ -43,3 +45,11 @@ class TokenEndpointTest(utils.TestCase):
self.assertEqual(self.TEST_URL, a.get_endpoint(s)) self.assertEqual(self.TEST_URL, a.get_endpoint(s))
self.assertEqual('body', data.text) self.assertEqual('body', data.text)
self.assertRequestHeaderEqual('X-Auth-Token', self.TEST_TOKEN) 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)