summaryrefslogtreecommitdiff
path: root/keystoneclient/access.py
diff options
context:
space:
mode:
authorJamie Lennox <jamielennox@redhat.com>2014-06-18 10:53:05 +1000
committerJamie Lennox <jamielennox@redhat.com>2014-06-29 23:17:46 +0000
commit8c8fd6560766c5f732c58b88b1b5eb6fcdb16e41 (patch)
treec040b9241aeda8e7579032c05b603625bd59ffe6 /keystoneclient/access.py
parent3d29db1bd1274e54097ee9387987f9b64ed8b3d0 (diff)
downloadpython-keystoneclient-8c8fd6560766c5f732c58b88b1b5eb6fcdb16e41.tar.gz
Add trust users to AccessInfo and fixture
A trust should always contain a trustee_user_id and a trustor_user_id. Expose these values via AccessInfo if available. Change-Id: Ic46a44300e6bf8aa694f1543d470c16fcac643fc
Diffstat (limited to 'keystoneclient/access.py')
-rw-r--r--keystoneclient/access.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/keystoneclient/access.py b/keystoneclient/access.py
index 354ccec..dfd7e9a 100644
--- a/keystoneclient/access.py
+++ b/keystoneclient/access.py
@@ -264,6 +264,22 @@ class AccessInfo(dict):
raise NotImplementedError()
@property
+ def trustee_user_id(self):
+ """Returns the trustee user id associated with a trust.
+
+ :returns: str or None (if no trust associated with the token)
+ """
+ raise NotImplementedError()
+
+ @property
+ def trustor_user_id(self):
+ """Returns the trustor user id associated with a trust.
+
+ :returns: str or None (if no trust associated with the token)
+ """
+ raise NotImplementedError()
+
+ @property
def project_id(self):
"""Returns the project ID associated with the authentication
request, or None if the authentication request wasn't scoped to a
@@ -469,6 +485,15 @@ class AccessInfoV2(AccessInfo):
return 'trust' in self
@property
+ def trustee_user_id(self):
+ return self.get('trust', {}).get('trustee_user_id')
+
+ @property
+ def trustor_user_id(self):
+ # this information is not available in the v2 token bug: #1331882
+ return None
+
+ @property
def project_id(self):
try:
tenant_dict = self['token']['tenant']
@@ -650,6 +675,14 @@ class AccessInfoV3(AccessInfo):
return 'OS-TRUST:trust' in self
@property
+ def trustee_user_id(self):
+ return self.get('OS-TRUST:trust', {}).get('trustee_user', {}).get('id')
+
+ @property
+ def trustor_user_id(self):
+ return self.get('OS-TRUST:trust', {}).get('trustor_user', {}).get('id')
+
+ @property
def auth_url(self):
# FIXME(jamielennox): this is deprecated in favour of retrieving it
# from the service catalog. Provide a warning.