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:
Steve Martinelli
2014-06-06 17:41:26 -04:00
parent 53a175e7c6
commit 6663e1360d

View File

@@ -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,7 +103,14 @@ class TokenTests(BaseTest):
self.assertThat(auth_header, matchers.StartsWith('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)
self.assertEqual('HMAC-SHA1', parameters['oauth_signature_method'])