summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-06-16 10:33:24 +0000
committerGerrit Code Review <review@openstack.org>2017-06-16 10:33:24 +0000
commit45265c0ddffa399fcb10bed6eac98069decdf910 (patch)
tree48e65c6eac1d14dfbebe76e7a58a6e437f7be9cd
parenta83257f75638f99c2be98262dad687fca2b17f75 (diff)
parent600c7247bc38c017c673b330a1d227331ca55f91 (diff)
Merge "Fix response body of getting role inference rule"
-rw-r--r--keystone/assignment/controllers.py4
-rw-r--r--keystone/tests/unit/test_v3_assignment.py22
2 files changed, 26 insertions, 0 deletions
diff --git a/keystone/assignment/controllers.py b/keystone/assignment/controllers.py
index c6ac224..3137e2a 100644
--- a/keystone/assignment/controllers.py
+++ b/keystone/assignment/controllers.py
@@ -500,6 +500,10 @@ class ImpliedRolesV3(controller.V3Controller):
500 implied_role = self.role_api.get_role(implied_id) 500 implied_role = self.role_api.get_role(implied_id)
501 stanza = self._implied_role_stanza(endpoint, implied_role) 501 stanza = self._implied_role_stanza(endpoint, implied_role)
502 response["role_inference"]['implies'] = stanza 502 response["role_inference"]['implies'] = stanza
503 response["links"] = {
504 "self": (endpoint + "/v3/roles/" + prior_id
505 + "/implies/" + implied_id)
506 }
503 return response 507 return response
504 508
505 @controller.protected(callback=_check_implies_role) 509 @controller.protected(callback=_check_implies_role)
diff --git a/keystone/tests/unit/test_v3_assignment.py b/keystone/tests/unit/test_v3_assignment.py
index f94fe63..d77b1ed 100644
--- a/keystone/tests/unit/test_v3_assignment.py
+++ b/keystone/tests/unit/test_v3_assignment.py
@@ -2512,9 +2512,31 @@ class ImpliedRolesTests(test_v3.RestfulTestCase, test_v3.AssignmentTestMixin,
2512 for implied in role_inference['implies']: 2512 for implied in role_inference['implies']:
2513 self.assertIsNotNone(implied['links']['self']) 2513 self.assertIsNotNone(implied['links']['self'])
2514 2514
2515 def _assert_expected_role_inference_rule_response(
2516 self, expected_prior_id, expected_implied_id):
2517 url = '/roles/%s/implies/%s' % (expected_prior_id, expected_implied_id)
2518 response = self.get(url).json
2519 self.assertThat(response['links']['self'],
2520 matchers.EndsWith('/v3%s' % url))
2521 role_inference = response['role_inference']
2522 prior_role = role_inference['prior_role']
2523 self.assertEqual(expected_prior_id, prior_role['id'])
2524 self.assertIsNotNone(prior_role['name'])
2525 self.assertThat(prior_role['links']['self'],
2526 matchers.EndsWith('/v3/roles/%s' % expected_prior_id))
2527 implied_role = role_inference['implies']
2528 self.assertEqual(expected_implied_id, implied_role['id'])
2529 self.assertIsNotNone(implied_role['name'])
2530 self.assertThat(implied_role['links']['self'], matchers.EndsWith(
2531 '/v3/roles/%s' % expected_implied_id))
2532
2515 def _assert_two_roles_implied(self): 2533 def _assert_two_roles_implied(self):
2516 self._assert_expected_implied_role_response( 2534 self._assert_expected_implied_role_response(
2517 self.prior['id'], [self.implied1['id'], self.implied2['id']]) 2535 self.prior['id'], [self.implied1['id'], self.implied2['id']])
2536 self._assert_expected_role_inference_rule_response(
2537 self.prior['id'], self.implied1['id'])
2538 self._assert_expected_role_inference_rule_response(
2539 self.prior['id'], self.implied2['id'])
2518 2540
2519 def _assert_one_role_implied(self): 2541 def _assert_one_role_implied(self):
2520 self._assert_expected_implied_role_response( 2542 self._assert_expected_implied_role_response(