Add Keystone Groups to REST API
Adding REST API calls to retrieve group list Co-Authored-By: zhurong <aaronzhu1121@gmail.com> Partially-Implements: blueprint angularize-identity-tables Change-Id: I12ca270036b4963fb20d3f6f1a630ded60a449f8
This commit is contained in:
parent
185c89b4c6
commit
8130a79589
@ -587,3 +587,21 @@ class Services(generic.View):
|
||||
)
|
||||
|
||||
return {'items': services}
|
||||
|
||||
|
||||
@urls.register
|
||||
class Groups(generic.View):
|
||||
"""API over all groups.
|
||||
"""
|
||||
url_regex = r'keystone/groups/$'
|
||||
|
||||
@rest_utils.ajax()
|
||||
def get(self, request):
|
||||
"""Get a list of groups.
|
||||
The listing result is an object with property "items".
|
||||
"""
|
||||
domain_context = request.session.get('domain_context')
|
||||
items = [d.to_dict() for d in api.keystone.group_list(
|
||||
request, domain=request.GET.get('domain_id', domain_context))]
|
||||
|
||||
return {'items': items}
|
||||
|
@ -57,7 +57,8 @@
|
||||
deleteProject: deleteProject,
|
||||
grantRole: grantRole,
|
||||
serviceCatalog: serviceCatalog,
|
||||
getServices: getServices
|
||||
getServices: getServices,
|
||||
getGroups: getGroups
|
||||
};
|
||||
|
||||
return service;
|
||||
@ -102,6 +103,13 @@
|
||||
});
|
||||
}
|
||||
|
||||
function getGroups() {
|
||||
return apiService.get('/api/keystone/groups/')
|
||||
.error(function () {
|
||||
toastService.add('error', gettext('Unable to fetch the groups.'));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @name getCurrentUserSession
|
||||
* @param {Object} config - The configuration for which we want a session
|
||||
|
@ -384,6 +384,12 @@
|
||||
"method": "get",
|
||||
"path": "/api/keystone/services/",
|
||||
"error": "Unable to fetch the services."
|
||||
},
|
||||
{
|
||||
"func": "getGroups",
|
||||
"method": "get",
|
||||
"path": "/api/keystone/groups/",
|
||||
"error": "Unable to fetch the groups."
|
||||
}
|
||||
];
|
||||
|
||||
|
@ -673,6 +673,25 @@ class KeystoneRestTestCase(test.TestCase):
|
||||
self.assertEqual(content['token'], 'token here')
|
||||
self.assertNotIn('super_secret_thing', content)
|
||||
|
||||
#
|
||||
# Groups
|
||||
#
|
||||
@mock.patch.object(keystone.api, 'keystone')
|
||||
def test_group_get_list(self, kc):
|
||||
request = self.mock_rest_request(**{
|
||||
'session.get': mock.Mock(return_value='the_domain'),
|
||||
'GET': {},
|
||||
})
|
||||
kc.group_list.return_value = [
|
||||
mock.Mock(**{'to_dict.return_value': {'name': 'uno!'}}),
|
||||
mock.Mock(**{'to_dict.return_value': {'name': 'dos!'}})
|
||||
]
|
||||
response = keystone.Groups().get(request)
|
||||
self.assertStatusCode(response, 200)
|
||||
self.assertEqual(response.json,
|
||||
{"items": [{"name": "uno!"}, {"name": "dos!"}]})
|
||||
kc.group_list.assert_called_once_with(request, domain='the_domain')
|
||||
|
||||
#
|
||||
# Services
|
||||
#
|
||||
|
Loading…
x
Reference in New Issue
Block a user