Merge "Allow unprivileged users to get their quota usage"

This commit is contained in:
Jenkins 2017-08-11 15:24:15 +00:00 committed by Gerrit Code Review
commit 76e1af8188
3 changed files with 7 additions and 8 deletions

View File

@ -52,8 +52,8 @@ class DetailQuotaSetsController(quotasv2.QuotaSetsController):
reason = _("Only admin is authorized to access quotas for"
" another tenant")
raise n_exc.AdminRequired(reason=reason)
return {self._resource_name:
self._get_detailed_quotas(request, id)}
return {self._resource_name:
self._get_detailed_quotas(request, id)}
class Quotasv2_detail(api_extensions.ExtensionDescriptor):

View File

@ -61,12 +61,12 @@ def _get_path(resource, id=None, action=None,
if action is not None:
path = path + '/%s' % action
if fmt is not None:
path = path + '.%s' % fmt
if endpoint is not None:
path = path + '/%s' % endpoint
if fmt is not None:
path = path + '.%s' % fmt
return path

View File

@ -69,8 +69,7 @@ class DetailQuotaExtensionDbTestCase(DetailQuotaExtensionTestCase):
def test_show_detail_quotas(self):
tenant_id = 'tenant_id1'
env = {'neutron.context': context.Context('', tenant_id,
is_admin=True)}
env = {'neutron.context': context.Context('', tenant_id)}
res = self.api.get(_get_path('quotas', id=tenant_id,
fmt=self.fmt,
endpoint=DEFAULT_QUOTAS_ACTION),
@ -144,7 +143,7 @@ class DetailQuotaExtensionDbTestCase(DetailQuotaExtensionTestCase):
def test_detail_quotas_without_admin_forbidden_returns_403(self):
tenant_id = 'tenant_id1'
env = {'neutron.context': context.Context('', tenant_id,
env = {'neutron.context': context.Context('', tenant_id + '2',
is_admin=False)}
res = self.api.get(_get_path('quotas', id=tenant_id,
fmt=self.fmt,