Ensure to show security groups only from current project

Previously when logging in as a user with admin role,
if we visit "Edit Security Group" action of the instance table,
security groups from all projects are listed.

Change-Id: I71ff940434ef8dc146e934dc833c4d26829930c0
Closes-Bug: #1750140
This commit is contained in:
Akihiro Motoki 2018-02-17 23:31:58 +09:00
parent 7c09346e08
commit 3051dee604
3 changed files with 7 additions and 6 deletions

View File

@ -1856,7 +1856,7 @@ class InstanceTests(InstanceTestBase):
self.mock_server_get.assert_called_once_with(
helpers.IsHttpRequest(), server.id)
self.mock_security_group_list.assert_called_once_with(
helpers.IsHttpRequest(), tenant_id=None)
helpers.IsHttpRequest(), tenant_id=self.tenant.id)
self.mock_server_security_groups.assert_called_once_with(
helpers.IsHttpRequest(), server.id)
self.mock_server_update.assert_called_once_with(
@ -1892,7 +1892,7 @@ class InstanceTests(InstanceTestBase):
self.mock_server_get.assert_called_once_with(
helpers.IsHttpRequest(), server.id)
self.mock_security_group_list.assert_called_once_with(
helpers.IsHttpRequest(), tenant_id=None)
helpers.IsHttpRequest(), tenant_id=self.tenant.id)
self.mock_server_security_groups.assert_called_once_with(
helpers.IsHttpRequest(), server.id)
self.mock_server_update.assert_called_once_with(
@ -1919,7 +1919,7 @@ class InstanceTests(InstanceTestBase):
self.mock_server_get.assert_called_once_with(
helpers.IsHttpRequest(), server.id)
self.mock_security_group_list.assert_called_once_with(
helpers.IsHttpRequest(), tenant_id=None)
helpers.IsHttpRequest(), tenant_id=self.tenant.id)
self.mock_server_security_groups.assert_called_once_with(
helpers.IsHttpRequest(), server.id)
self.mock_server_update.assert_called_once_with(
@ -1948,7 +1948,7 @@ class InstanceTests(InstanceTestBase):
self.mock_server_get.assert_called_once_with(
helpers.IsHttpRequest(), server.id)
self.mock_security_group_list.assert_called_once_with(
helpers.IsHttpRequest(), tenant_id=None)
helpers.IsHttpRequest(), tenant_id=self.tenant.id)
self.mock_server_security_groups.assert_called_once_with(
helpers.IsHttpRequest(), server.id)
self.mock_server_update.assert_called_once_with(

View File

@ -337,7 +337,8 @@ class UpdateView(workflows.WorkflowView):
instance = self.get_object()
initial.update({'instance_id': self.kwargs['instance_id'],
'name': getattr(instance, 'name', ''),
'description': getattr(instance, 'description', '')})
'description': getattr(instance, 'description', ''),
'target_tenant_id': self.request.user.tenant_id})
return initial

View File

@ -119,7 +119,7 @@ class UpdateInstanceSecurityGroups(BaseSecurityGroups):
members_list_title = _("Instance Security Groups")
help_text = _("Add and remove security groups to this instance "
"from the list of available security groups.")
depends_on = ("instance_id",)
depends_on = ("instance_id", "target_tenant_id")
def allowed(self, request):
return api.base.is_service_enabled(request, 'network')