summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrant Knudson <bknudson@us.ibm.com>2015-04-11 10:28:49 -0500
committerBrant Knudson <bknudson@us.ibm.com>2015-04-11 11:26:30 -0500
commita4f80b5c64e1a2645384665cb60a924342230581 (patch)
treefa9eba96fab6e75e697baa769d05717617fdcbcd
parent4ee6e3302ae53c8858c0e48c27a46c292e771afb (diff)
downloadpython-keystoneclient-a4f80b5c64e1a2645384665cb60a924342230581.tar.gz
Fix tests to work with requests<2.3
The tests didn't pass with requests<2.3 because of the cookies monkey-patching. To test this, make sure the requests library in your tox venv is the right level: $ .tox/py27/bin/pip install -U "requests<2.3" Then run the tests. Closes-Bug: 1442919 Change-Id: Ie93906ba2370dada2386a50ae2137337ccf98f10 (cherry picked from commit a335b7f6f2577f06cead7b7acbfa07dd771a94b9)
-rw-r--r--keystoneclient/tests/v3/test_auth_saml2.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/keystoneclient/tests/v3/test_auth_saml2.py b/keystoneclient/tests/v3/test_auth_saml2.py
index f9a0776..375f7b7 100644
--- a/keystoneclient/tests/v3/test_auth_saml2.py
+++ b/keystoneclient/tests/v3/test_auth_saml2.py
@@ -582,9 +582,8 @@ class AuthenticateviaADFSTests(utils.TestCase):
self.session)
def test_access_sp_no_cookies_fail(self):
- # clean cookie jar
- self.session.session.cookies = []
-
+ # There are no cookies in the session initially, and
+ # _access_service_provider requires a cookie in the session.
self.assertRaises(exceptions.AuthorizationFailure,
self.adfsplugin._access_service_provider,
self.session)
@@ -594,7 +593,11 @@ class AuthenticateviaADFSTests(utils.TestCase):
json=saml2_fixtures.UNSCOPED_TOKEN,
headers=client_fixtures.AUTH_RESPONSE_HEADERS)
- self.session.session.cookies = [object()]
+ # _access_service_provider requires a cookie in the session.
+ cookie = requests.cookies.create_cookie(
+ name=self.getUniqueString(), value=self.getUniqueString())
+ self.session.session.cookies.set_cookie(cookie)
+
self.adfsplugin._access_service_provider(self.session)
response = self.adfsplugin.authenticated_response
@@ -617,7 +620,10 @@ class AuthenticateviaADFSTests(utils.TestCase):
# NOTE(marek-denis): We need to mimic this until self.requests can
# issue cookies properly.
- self.session.session.cookies = [object()]
+ cookie = requests.cookies.create_cookie(
+ name=self.getUniqueString(), value=self.getUniqueString())
+ self.session.session.cookies.set_cookie(cookie)
+
token, token_json = self.adfsplugin._get_unscoped_token(self.session)
self.assertEqual(token, client_fixtures.AUTH_SUBJECT_TOKEN)
self.assertEqual(saml2_fixtures.UNSCOPED_TOKEN['token'], token_json)