Make get_oauth_params conditional for specific oauthlib versions
With recent change to oauthlib 0.6.2, the get_oauth_params method now takes an extra argument. This patch will change the behaviour of test method _validate_oauth_headers, which will call get_oauth_params with or without the extra argument, depending on the version of oauthlib detected. Change-Id: Id82c28993fa735b8c5b1a4d64ed2f55cc2eddbba Closes-Bug: #1327430
This commit is contained in:
@@ -29,6 +29,7 @@ from keystoneclient.v3.contrib.oauth1 import consumers
|
||||
from keystoneclient.v3.contrib.oauth1 import request_tokens
|
||||
|
||||
try:
|
||||
import oauthlib
|
||||
from oauthlib import oauth1
|
||||
except ImportError:
|
||||
oauth1 = None
|
||||
@@ -102,6 +103,13 @@ class TokenTests(BaseTest):
|
||||
|
||||
self.assertThat(auth_header, matchers.StartsWith('OAuth '))
|
||||
auth_header = auth_header[len('OAuth '):]
|
||||
# NOTE(stevemar): In newer versions of oauthlib there is
|
||||
# an additional argument for getting oauth parameters.
|
||||
# Adding a conditional here to revert back to no arguments
|
||||
# if an earlier version is detected.
|
||||
if tuple(oauthlib.__version__.split('.')) > ('0', '6', '1'):
|
||||
header_params = oauth_client.get_oauth_params(None)
|
||||
else:
|
||||
header_params = oauth_client.get_oauth_params()
|
||||
parameters = dict(header_params)
|
||||
|
||||
|
Reference in New Issue
Block a user