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
|
from keystoneclient.v3.contrib.oauth1 import request_tokens
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
import oauthlib
|
||||||
from oauthlib import oauth1
|
from oauthlib import oauth1
|
||||||
except ImportError:
|
except ImportError:
|
||||||
oauth1 = None
|
oauth1 = None
|
||||||
@@ -102,7 +103,14 @@ class TokenTests(BaseTest):
|
|||||||
|
|
||||||
self.assertThat(auth_header, matchers.StartsWith('OAuth '))
|
self.assertThat(auth_header, matchers.StartsWith('OAuth '))
|
||||||
auth_header = auth_header[len('OAuth '):]
|
auth_header = auth_header[len('OAuth '):]
|
||||||
header_params = oauth_client.get_oauth_params()
|
# 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)
|
parameters = dict(header_params)
|
||||||
|
|
||||||
self.assertEqual('HMAC-SHA1', parameters['oauth_signature_method'])
|
self.assertEqual('HMAC-SHA1', parameters['oauth_signature_method'])
|
||||||
|
Reference in New Issue
Block a user