Merge "Add Keystone Groups to REST API"
This commit is contained in:
commit
47edc6b6de
|
@ -587,3 +587,21 @@ class Services(generic.View):
|
||||||
)
|
)
|
||||||
|
|
||||||
return {'items': services}
|
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,
|
deleteProject: deleteProject,
|
||||||
grantRole: grantRole,
|
grantRole: grantRole,
|
||||||
serviceCatalog: serviceCatalog,
|
serviceCatalog: serviceCatalog,
|
||||||
getServices: getServices
|
getServices: getServices,
|
||||||
|
getGroups: getGroups
|
||||||
};
|
};
|
||||||
|
|
||||||
return service;
|
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
|
* @name getCurrentUserSession
|
||||||
* @param {Object} config - The configuration for which we want a session
|
* @param {Object} config - The configuration for which we want a session
|
||||||
|
|
|
@ -384,6 +384,12 @@
|
||||||
"method": "get",
|
"method": "get",
|
||||||
"path": "/api/keystone/services/",
|
"path": "/api/keystone/services/",
|
||||||
"error": "Unable to fetch the 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.assertEqual(content['token'], 'token here')
|
||||||
self.assertNotIn('super_secret_thing', content)
|
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
|
# Services
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in New Issue