Browse Source

Use domain_context not effective domain to display domains list

Use domain_context to decide whether to call domain_list or domain_get
in the list of domains. Previous code used the user's effective domain
instead, which is no longer the same thing with Keystone V3.

Closes-Bug: #1660602

Change-Id: Ie410d282c5b19a061fe83b496785f35bbcfad9ad
(cherry picked from commit 1be065aed8)
Radomir Dopieralski 2 years ago
parent
commit
30d0a31d41

+ 0
- 8
openstack_dashboard/dashboards/identity/domains/tests.py View File

@@ -39,8 +39,6 @@ class DomainsViewTests(test.BaseAdminViewTests):
39 39
     @test.create_stubs({api.keystone: ('domain_get',
40 40
                                        'domain_list',)})
41 41
     def test_index(self):
42
-        domain = self.domains.get(id="1")
43
-        api.keystone.domain_get(IsA(http.HttpRequest), '1').AndReturn(domain)
44 42
         api.keystone.domain_list(IgnoreArg()).AndReturn(self.domains.list())
45 43
 
46 44
         self.mox.ReplayAll()
@@ -59,8 +57,6 @@ class DomainsViewTests(test.BaseAdminViewTests):
59 57
                                        'domain_list',
60 58
                                        'keystone_can_edit_domain')})
61 59
     def test_index_with_keystone_can_edit_domain_false(self):
62
-        domain = self.domains.get(id="1")
63
-        api.keystone.domain_get(IsA(http.HttpRequest), '1').AndReturn(domain)
64 60
         api.keystone.domain_list(IgnoreArg()).AndReturn(self.domains.list())
65 61
         api.keystone.keystone_can_edit_domain() \
66 62
             .MultipleTimes().AndReturn(False)
@@ -83,7 +79,6 @@ class DomainsViewTests(test.BaseAdminViewTests):
83 79
     def test_delete_domain(self):
84 80
         domain = self.domains.get(id="2")
85 81
 
86
-        api.keystone.domain_get(IsA(http.HttpRequest), '2').AndReturn(domain)
87 82
         api.keystone.domain_list(IgnoreArg()).AndReturn(self.domains.list())
88 83
         api.keystone.domain_delete(IgnoreArg(), domain.id)
89 84
 
@@ -99,7 +94,6 @@ class DomainsViewTests(test.BaseAdminViewTests):
99 94
     def test_delete_with_enabled_domain(self):
100 95
         domain = self.domains.get(id="1")
101 96
 
102
-        api.keystone.domain_get(IsA(http.HttpRequest), '1').AndReturn(domain)
103 97
         api.keystone.domain_list(IgnoreArg()).AndReturn(self.domains.list())
104 98
 
105 99
         self.mox.ReplayAll()
@@ -116,7 +110,6 @@ class DomainsViewTests(test.BaseAdminViewTests):
116 110
     def test_disable(self):
117 111
         domain = self.domains.get(id="1")
118 112
 
119
-        api.keystone.domain_get(IsA(http.HttpRequest), '1').AndReturn(domain)
120 113
         api.keystone.domain_list(IgnoreArg()).AndReturn(self.domains.list())
121 114
         api.keystone.domain_update(IsA(http.HttpRequest),
122 115
                                    description=domain.description,
@@ -138,7 +131,6 @@ class DomainsViewTests(test.BaseAdminViewTests):
138 131
     def test_enable(self):
139 132
         domain = self.domains.get(id="2")
140 133
 
141
-        api.keystone.domain_get(IsA(http.HttpRequest), '1').AndReturn(domain)
142 134
         api.keystone.domain_list(IgnoreArg()).AndReturn(self.domains.list())
143 135
         api.keystone.domain_update(IsA(http.HttpRequest),
144 136
                                    description=domain.description,

+ 9
- 10
openstack_dashboard/dashboards/identity/domains/views.py View File

@@ -38,22 +38,21 @@ class IndexView(tables.DataTableView):
38 38
 
39 39
     def get_data(self):
40 40
         domains = []
41
-        domain_id = identity.get_domain_id_for_operation(self.request)
41
+        domain_context = self.request.session.get('domain_context')
42 42
 
43
-        if policy.check((("identity", "identity:list_domains"),),
44
-                        self.request):
43
+        if policy.check((
44
+            ("identity", "identity:list_domains"),
45
+        ), self.request) and not domain_context:
45 46
             try:
46
-                if domain_id:
47
-                    domain = api.keystone.domain_get(self.request, domain_id)
48
-                    domains.append(domain)
49
-                else:
50
-                    domains = api.keystone.domain_list(self.request)
47
+                domains = api.keystone.domain_list(self.request)
51 48
             except Exception:
52 49
                 exceptions.handle(self.request,
53 50
                                   _('Unable to retrieve domain list.'))
54
-        elif policy.check((("identity", "identity:get_domain"),),
55
-                          self.request):
51
+        elif policy.check((
52
+            ("identity", "identity:get_domain"),
53
+        ), self.request):
56 54
             try:
55
+                domain_id = identity.get_domain_id_for_operation(self.request)
57 56
                 domain = api.keystone.domain_get(self.request, domain_id)
58 57
                 domains.append(domain)
59 58
             except Exception:

Loading…
Cancel
Save