summaryrefslogtreecommitdiff
path: root/keystoneclient/tests/auth/test_identity_common.py
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-02-09 05:54:33 +0000
committerGerrit Code Review <review@openstack.org>2015-02-09 05:54:33 +0000
commit4ee6e3302ae53c8858c0e48c27a46c292e771afb (patch)
treed945a6e37daf9542ebf6c5e398fbe932fe072d4a /keystoneclient/tests/auth/test_identity_common.py
parent14aa7fe27b0dcae5d5b4be6f9c6d5948c7704aae (diff)
parentcd552374ca8eaa315ec54fe8f586ec8c69a69c74 (diff)
downloadpython-keystoneclient-1.1.0.tar.gz
Merge "Add get_headers interface to authentication plugins"1.1.0
Diffstat (limited to 'keystoneclient/tests/auth/test_identity_common.py')
-rw-r--r--keystoneclient/tests/auth/test_identity_common.py55
1 files changed, 54 insertions, 1 deletions
diff --git a/keystoneclient/tests/auth/test_identity_common.py b/keystoneclient/tests/auth/test_identity_common.py
index a7d9be6..d6942bc 100644
--- a/keystoneclient/tests/auth/test_identity_common.py
+++ b/keystoneclient/tests/auth/test_identity_common.py
@@ -221,7 +221,7 @@ class CommonIdentityTests(object):
s = session.Session(auth=a)
# trigger token fetching
- s.get_token()
+ s.get_auth_headers()
self.assertTrue(a.auth_ref)
self.assertTrue(a.invalidate())
@@ -368,3 +368,56 @@ class CatalogHackTests(utils.TestCase):
version=(3, 0))
self.assertEqual(self.V2_URL, endpoint)
+
+
+class GenericPlugin(base.BaseAuthPlugin):
+
+ BAD_TOKEN = uuid.uuid4().hex
+
+ def __init__(self):
+ super(GenericPlugin, self).__init__()
+
+ self.endpoint = 'http://keystone.host:5000'
+
+ self.headers = {'headerA': 'valueA',
+ 'headerB': 'valueB'}
+
+ def url(self, prefix):
+ return '%s/%s' % (self.endpoint, prefix)
+
+ def get_token(self, session, **kwargs):
+ # NOTE(jamielennox): by specifying get_headers this should not be used
+ return self.BAD_TOKEN
+
+ def get_headers(self, session, **kwargs):
+ return self.headers
+
+ def get_endpoint(self, session, **kwargs):
+ return self.endpoint
+
+
+class GenericAuthPluginTests(utils.TestCase):
+
+ # filter doesn't matter to GenericPlugin, but we have to specify one
+ ENDPOINT_FILTER = {uuid.uuid4().hex: uuid.uuid4().hex}
+
+ def setUp(self):
+ super(GenericAuthPluginTests, self).setUp()
+ self.auth = GenericPlugin()
+ self.session = session.Session(auth=self.auth)
+
+ def test_setting_headers(self):
+ text = uuid.uuid4().hex
+ self.stub_url('GET', base_url=self.auth.url('prefix'), text=text)
+
+ resp = self.session.get('prefix', endpoint_filter=self.ENDPOINT_FILTER)
+
+ self.assertEqual(text, resp.text)
+
+ for k, v in six.iteritems(self.auth.headers):
+ self.assertRequestHeaderEqual(k, v)
+
+ self.assertIsNone(self.session.get_token())
+ self.assertEqual(self.auth.headers,
+ self.session.get_auth_headers())
+ self.assertNotIn('X-Auth-Token', self.requests.last_request.headers)