Skip to content

Commit

Permalink
add OS-TRUST to links
Browse files Browse the repository at this point in the history
Bug 1183874

Change-Id: I3881e360485c4c1ff6d67aec12d47130c6b0eb70
  • Loading branch information
Adam Young committed Aug 1, 2013
1 parent a39a97d commit 7ac3d4e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
18 changes: 16 additions & 2 deletions keystone/trust/controllers.py
Expand Up @@ -35,6 +35,21 @@ class TrustV3(controller.V3Controller):
collection_name = "trusts"
member_name = "trust"

@classmethod
def base_url(cls, path=None):
endpoint = CONF.public_endpoint % CONF

# allow a missing trailing slash in the config
if endpoint[-1] != '/':
endpoint += '/'

url = endpoint + 'v3/OS-TRUST'

if path:
return url + path
else:
return url + '/' + cls.collection_name

def _get_user_id(self, context):
if 'token_id' in context:
token_id = context['token_id']
Expand Down Expand Up @@ -78,8 +93,7 @@ def _fill_in_roles(self, context, trust, global_roles):
trust_full_roles.append(full_role)
trust['roles'] = trust_full_roles
trust['roles_links'] = {
'self': (CONF.public_endpoint % CONF +
"trusts/%s/roles" % trust['id']),
'self': (self.base_url() + "/%s/roles" % trust['id']),
'next': None,
'previous': None}

Expand Down
4 changes: 4 additions & 0 deletions tests/test_auth.py
Expand Up @@ -618,6 +618,10 @@ def test_create_trust(self):
role_ids = [self.role_browser['id'], self.role_member['id']]
self.assertTrue(timeutils.parse_strtime(self.new_trust['expires_at'],
fmt=TIME_FORMAT))
self.assertIn('http://localhost:5000/v3/OS-TRUST/',
self.new_trust['links']['self'])
self.assertIn('http://localhost:5000/v3/OS-TRUST/',
self.new_trust['roles_links']['self'])

for role in self.new_trust['roles']:
self.assertIn(role['id'], role_ids)
Expand Down

0 comments on commit 7ac3d4e

Please sign in to comment.