Allow unprivileged users to get their quota usage

When user try to get quota usage detail for their own project, it will
return null. As process logic of details method is incorrect, it only
allow admin to get other's project quota usage detail.

Change-Id: I2e21dac497a6c5bffba6b55cb4456820900449df
Closes-Bug: #1708133
This commit is contained in:
Zhengwei Gao 2017-08-02 20:05:20 +08:00 committed by Kevin Benton
parent 6280787f84
commit 9e185bca08
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,