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:
		@@ -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',
 | 
			
		||||
 
 | 
			
		||||
@@ -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)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user