summaryrefslogtreecommitdiff
path: root/keystoneclient/tests
diff options
context:
space:
mode:
authorJamie Lennox <jamielennox@redhat.com>2014-10-30 15:12:05 +0100
committerJamie Lennox <jamielennox@redhat.com>2015-01-23 10:41:07 +1000
commit496a0efc43c40fb030b62f3ed632ee50659a9b41 (patch)
tree1d2fce86dc5fbb5fc3b36c9ce643be2f332a752b /keystoneclient/tests
parenteaab62aca5f570bd119b4c602db7845a017c958e (diff)
downloadpython-keystoneclient-496a0efc43c40fb030b62f3ed632ee50659a9b41.tar.gz
Surface the user_id and project_id beyond the plugin
Having the user_id and project_id exposed in the plugin is a good first step however we don't really expect the user to be interacting with the plugins directly often - particularly as you need to pass session to the methods. Exposing get_user_id and get_project_id on the session and the adapter in this way is very similar to the way we expose get_token and get_endpoint on the session and adapter for use higher up. Related-Bug: #1364724 Change-Id: If2f868c3ddc19133f18446e74f8e1b560a4798fa
Diffstat (limited to 'keystoneclient/tests')
-rw-r--r--keystoneclient/tests/test_session.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/keystoneclient/tests/test_session.py b/keystoneclient/tests/test_session.py
index 3cd7ae5..33dda08 100644
--- a/keystoneclient/tests/test_session.py
+++ b/keystoneclient/tests/test_session.py
@@ -321,6 +321,8 @@ class AuthPlugin(base.BaseAuthPlugin):
"""
TEST_TOKEN = 'aToken'
+ TEST_USER_ID = 'aUser'
+ TEST_PROJECT_ID = 'aProject'
SERVICE_URLS = {
'identity': {'public': 'http://identity-public:1111/v2.0',
@@ -348,6 +350,12 @@ class AuthPlugin(base.BaseAuthPlugin):
def invalidate(self):
return self._invalidate
+ def get_user_id(self, session):
+ return self.TEST_USER_ID
+
+ def get_project_id(self, session):
+ return self.TEST_PROJECT_ID
+
class CalledAuthPlugin(base.BaseAuthPlugin):
@@ -582,6 +590,13 @@ class SessionAuthTests(utils.TestCase):
self.assertTrue(auth.get_token_called)
self.assertFalse(auth.get_endpoint_called)
+ def test_user_and_project_id(self):
+ auth = AuthPlugin()
+ sess = client_session.Session(auth=auth)
+
+ self.assertEqual(auth.TEST_USER_ID, sess.get_user_id())
+ self.assertEqual(auth.TEST_PROJECT_ID, sess.get_project_id())
+
class AdapterTest(utils.TestCase):
@@ -737,6 +752,14 @@ class AdapterTest(utils.TestCase):
self.assertThat(self.requests.request_history,
matchers.HasLength(retries + 1))
+ def test_user_and_project_id(self):
+ auth = AuthPlugin()
+ sess = client_session.Session()
+ adpt = adapter.Adapter(sess, auth=auth)
+
+ self.assertEqual(auth.TEST_USER_ID, adpt.get_user_id())
+ self.assertEqual(auth.TEST_PROJECT_ID, adpt.get_project_id())
+
class ConfLoadingTests(utils.TestCase):