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 (cherry picked from commit 9e185bca08510ec831afdd75013bb3655d9a6e76)
This commit is contained in:
parent
2f98022fa5
commit
d823ae2974
@ -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):
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user