From 8c8fd6560766c5f732c58b88b1b5eb6fcdb16e41 Mon Sep 17 00:00:00 2001 From: Jamie Lennox Date: Wed, 18 Jun 2014 10:53:05 +1000 Subject: 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 --- keystoneclient/access.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'keystoneclient/access.py') diff --git a/keystoneclient/access.py b/keystoneclient/access.py index 354ccec..dfd7e9a 100644 --- a/keystoneclient/access.py +++ b/keystoneclient/access.py @@ -263,6 +263,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 @@ -468,6 +484,15 @@ class AccessInfoV2(AccessInfo): def trust_scoped(self): 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: @@ -649,6 +674,14 @@ class AccessInfoV3(AccessInfo): def trust_scoped(self): 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 -- cgit v1.2.1