Fix response body of getting role inference rule
The response body of getting role inference rule api lacks a 'links' object, comparing with the api-ref [1]. This patch is to add the 'links' object to make the response body consistent with the api-ref. [1] https://developer.openstack.org/api-ref/identity/v3/index.html#get-role-inference-rule Closes-Bug: 1691048 Change-Id: I31ddb4addce22cde68bfa2ff8ffd18386fd44136
This commit is contained in:
parent
bcd8d22afc
commit
600c7247bc
@ -500,6 +500,10 @@ class ImpliedRolesV3(controller.V3Controller):
|
||||
implied_role = self.role_api.get_role(implied_id)
|
||||
stanza = self._implied_role_stanza(endpoint, implied_role)
|
||||
response["role_inference"]['implies'] = stanza
|
||||
response["links"] = {
|
||||
"self": (endpoint + "/v3/roles/" + prior_id
|
||||
+ "/implies/" + implied_id)
|
||||
}
|
||||
return response
|
||||
|
||||
@controller.protected(callback=_check_implies_role)
|
||||
|
@ -2512,9 +2512,31 @@ class ImpliedRolesTests(test_v3.RestfulTestCase, test_v3.AssignmentTestMixin,
|
||||
for implied in role_inference['implies']:
|
||||
self.assertIsNotNone(implied['links']['self'])
|
||||
|
||||
def _assert_expected_role_inference_rule_response(
|
||||
self, expected_prior_id, expected_implied_id):
|
||||
url = '/roles/%s/implies/%s' % (expected_prior_id, expected_implied_id)
|
||||
response = self.get(url).json
|
||||
self.assertThat(response['links']['self'],
|
||||
matchers.EndsWith('/v3%s' % url))
|
||||
role_inference = response['role_inference']
|
||||
prior_role = role_inference['prior_role']
|
||||
self.assertEqual(expected_prior_id, prior_role['id'])
|
||||
self.assertIsNotNone(prior_role['name'])
|
||||
self.assertThat(prior_role['links']['self'],
|
||||
matchers.EndsWith('/v3/roles/%s' % expected_prior_id))
|
||||
implied_role = role_inference['implies']
|
||||
self.assertEqual(expected_implied_id, implied_role['id'])
|
||||
self.assertIsNotNone(implied_role['name'])
|
||||
self.assertThat(implied_role['links']['self'], matchers.EndsWith(
|
||||
'/v3/roles/%s' % expected_implied_id))
|
||||
|
||||
def _assert_two_roles_implied(self):
|
||||
self._assert_expected_implied_role_response(
|
||||
self.prior['id'], [self.implied1['id'], self.implied2['id']])
|
||||
self._assert_expected_role_inference_rule_response(
|
||||
self.prior['id'], self.implied1['id'])
|
||||
self._assert_expected_role_inference_rule_response(
|
||||
self.prior['id'], self.implied2['id'])
|
||||
|
||||
def _assert_one_role_implied(self):
|
||||
self._assert_expected_implied_role_response(
|
||||
|
Loading…
Reference in New Issue
Block a user