Merge "Use domain_context not effective domain to display domains list"
This commit is contained in:
commit
f716d559ad
@ -39,8 +39,6 @@ class DomainsViewTests(test.BaseAdminViewTests):
|
||||
@test.create_stubs({api.keystone: ('domain_get',
|
||||
'domain_list',)})
|
||||
def test_index(self):
|
||||
domain = self.domains.get(id="1")
|
||||
api.keystone.domain_get(IsA(http.HttpRequest), '1').AndReturn(domain)
|
||||
api.keystone.domain_list(IgnoreArg()).AndReturn(self.domains.list())
|
||||
|
||||
self.mox.ReplayAll()
|
||||
@ -59,8 +57,6 @@ class DomainsViewTests(test.BaseAdminViewTests):
|
||||
'domain_list',
|
||||
'keystone_can_edit_domain')})
|
||||
def test_index_with_keystone_can_edit_domain_false(self):
|
||||
domain = self.domains.get(id="1")
|
||||
api.keystone.domain_get(IsA(http.HttpRequest), '1').AndReturn(domain)
|
||||
api.keystone.domain_list(IgnoreArg()).AndReturn(self.domains.list())
|
||||
api.keystone.keystone_can_edit_domain() \
|
||||
.MultipleTimes().AndReturn(False)
|
||||
@ -83,7 +79,6 @@ class DomainsViewTests(test.BaseAdminViewTests):
|
||||
def test_delete_domain(self):
|
||||
domain = self.domains.get(id="2")
|
||||
|
||||
api.keystone.domain_get(IsA(http.HttpRequest), '2').AndReturn(domain)
|
||||
api.keystone.domain_list(IgnoreArg()).AndReturn(self.domains.list())
|
||||
api.keystone.domain_delete(IgnoreArg(), domain.id)
|
||||
|
||||
@ -99,7 +94,6 @@ class DomainsViewTests(test.BaseAdminViewTests):
|
||||
def test_delete_with_enabled_domain(self):
|
||||
domain = self.domains.get(id="1")
|
||||
|
||||
api.keystone.domain_get(IsA(http.HttpRequest), '1').AndReturn(domain)
|
||||
api.keystone.domain_list(IgnoreArg()).AndReturn(self.domains.list())
|
||||
|
||||
self.mox.ReplayAll()
|
||||
@ -116,7 +110,6 @@ class DomainsViewTests(test.BaseAdminViewTests):
|
||||
def test_disable(self):
|
||||
domain = self.domains.get(id="1")
|
||||
|
||||
api.keystone.domain_get(IsA(http.HttpRequest), '1').AndReturn(domain)
|
||||
api.keystone.domain_list(IgnoreArg()).AndReturn(self.domains.list())
|
||||
api.keystone.domain_update(IsA(http.HttpRequest),
|
||||
description=domain.description,
|
||||
@ -138,7 +131,6 @@ class DomainsViewTests(test.BaseAdminViewTests):
|
||||
def test_enable(self):
|
||||
domain = self.domains.get(id="2")
|
||||
|
||||
api.keystone.domain_get(IsA(http.HttpRequest), '1').AndReturn(domain)
|
||||
api.keystone.domain_list(IgnoreArg()).AndReturn(self.domains.list())
|
||||
api.keystone.domain_update(IsA(http.HttpRequest),
|
||||
description=domain.description,
|
||||
|
@ -38,22 +38,21 @@ class IndexView(tables.DataTableView):
|
||||
|
||||
def get_data(self):
|
||||
domains = []
|
||||
domain_id = identity.get_domain_id_for_operation(self.request)
|
||||
domain_context = self.request.session.get('domain_context')
|
||||
|
||||
if policy.check((("identity", "identity:list_domains"),),
|
||||
self.request):
|
||||
if policy.check((
|
||||
("identity", "identity:list_domains"),
|
||||
), self.request) and not domain_context:
|
||||
try:
|
||||
if domain_id:
|
||||
domain = api.keystone.domain_get(self.request, domain_id)
|
||||
domains.append(domain)
|
||||
else:
|
||||
domains = api.keystone.domain_list(self.request)
|
||||
except Exception:
|
||||
exceptions.handle(self.request,
|
||||
_('Unable to retrieve domain list.'))
|
||||
elif policy.check((("identity", "identity:get_domain"),),
|
||||
self.request):
|
||||
elif policy.check((
|
||||
("identity", "identity:get_domain"),
|
||||
), self.request):
|
||||
try:
|
||||
domain_id = identity.get_domain_id_for_operation(self.request)
|
||||
domain = api.keystone.domain_get(self.request, domain_id)
|
||||
domains.append(domain)
|
||||
except Exception:
|
||||
|
Loading…
Reference in New Issue
Block a user