Merge "Correct output for Implied Roles"

This commit is contained in:
Jenkins 2016-09-26 11:37:39 +00:00 committed by Gerrit Code Review
commit ec930d1b32
2 changed files with 26 additions and 2 deletions

View File

@ -621,11 +621,34 @@ class RoleTests(utils.ClientTestCase, utils.CrudTests):
def test_implied_role_create(self): def test_implied_role_create(self):
prior_role_id = uuid.uuid4().hex prior_role_id = uuid.uuid4().hex
implied_role_id = uuid.uuid4().hex implied_role_id = uuid.uuid4().hex
test_json = {
"role_inference": {
"prior_role": {
"id": prior_role_id,
"links": {},
"name": "prior role name"
},
"implies": {
"id": implied_role_id,
"links": {},
"name": "implied role name"
}
},
"links": {}
}
self.stub_url('PUT', self.stub_url('PUT',
['roles', prior_role_id, 'implies', implied_role_id], ['roles', prior_role_id, 'implies', implied_role_id],
json=test_json,
status_code=200) status_code=200)
self.manager.create_implied(prior_role_id, implied_role_id) returned_rule = self.manager.create_implied(
prior_role_id, implied_role_id)
self.assertEqual(test_json['role_inference']['implies'],
returned_rule.implies)
self.assertEqual(test_json['role_inference']['prior_role'],
returned_rule.prior_role)
def test_implied_role_delete(self): def test_implied_role_delete(self):
prior_role_id = uuid.uuid4().hex prior_role_id = uuid.uuid4().hex

View File

@ -136,7 +136,8 @@ class RoleManager(base.CrudManager):
""" """
url_tail = self._implied_role_url_tail(prior_role, implied_role) url_tail = self._implied_role_url_tail(prior_role, implied_role)
self.client.put("/roles" + url_tail, **kwargs) resp, body = self.client.put("/roles" + url_tail, **kwargs)
return self.resource_class(self, body['role_inference'])
def delete_implied(self, prior_role, implied_role, **kwargs): def delete_implied(self, prior_role, implied_role, **kwargs):
"""Delete an inference rule. """Delete an inference rule.