summaryrefslogtreecommitdiff
path: root/openstack_dashboard/dashboards/project/security_groups
diff options
context:
space:
mode:
authorSamuel12321 <samuelgilliessmith@outlook.com>2018-01-18 16:14:02 +1300
committerAkihiro Motoki <amotoki@gmail.com>2018-04-10 00:48:30 +0900
commit6f37943af9634ef6a86475402e69c33bc162893e (patch)
treeee2d7d851221e47554aa29e3d1c7089da5398cc4 /openstack_dashboard/dashboards/project/security_groups
parent9ca9b5cd81db29bddf6dbcc5fc535009a9ec63b0 (diff)
downloadhorizon-6f37943af9634ef6a86475402e69c33bc162893e.tar.gz
A description can now be added to a security rule
This patch fixes Bug #1742332 (Security Rule Description neither editable nor shown). I have added the option for a description to be added to a security rule which will show the description on the related table. Co-Authored-By: Akihiro Motoki <amotoki@gmail.com> Change-Id: Ie723deb412977ae460c1e897f5d71fc8dbb7a853 Closes-Bug: #1742332
Diffstat (limited to 'openstack_dashboard/dashboards/project/security_groups')
-rw-r--r--openstack_dashboard/dashboards/project/security_groups/forms.py23
-rw-r--r--openstack_dashboard/dashboards/project/security_groups/tables.py23
-rw-r--r--openstack_dashboard/dashboards/project/security_groups/tests.py182
3 files changed, 204 insertions, 24 deletions
diff --git a/openstack_dashboard/dashboards/project/security_groups/forms.py b/openstack_dashboard/dashboards/project/security_groups/forms.py
index 852413843..58dd2dc4d 100644
--- a/openstack_dashboard/dashboards/project/security_groups/forms.py
+++ b/openstack_dashboard/dashboards/project/security_groups/forms.py
@@ -102,6 +102,12 @@ class AddRule(forms.SelfHandlingForm):
widget=forms.ThemableSelectWidget(attrs={
'class': 'switchable',
'data-slug': 'rule_menu'}))
+ description = forms.CharField(
+ label=_('Description'),
+ required=False, max_length=255,
+ widget=forms.Textarea(attrs={'rows': 2}),
+ help_text=_('A brief description of the security group rule '
+ 'you are adding'))
# "direction" field is enabled only when custom mode.
# It is because most common rules in local_settings.py is meaningful
@@ -296,6 +302,17 @@ class AddRule(forms.SelfHandlingForm):
attrs={'readonly': 'readonly'})
self.fields['ethertype'].initial = 'IPv4'
+ try:
+ is_desc_supported = api.neutron.is_extension_supported(
+ self.request, 'standard-attr-description')
+ except Exception:
+ exceptions.handle(
+ self.request,
+ _('Failed to check if description field is supported.'))
+ is_desc_supported = False
+ if not is_desc_supported:
+ del self.fields['description']
+
def _update_and_pop_error(self, cleaned_data, key, value):
cleaned_data[key] = value
self.errors.pop(key, None)
@@ -419,6 +436,9 @@ class AddRule(forms.SelfHandlingForm):
def handle(self, request, data):
redirect = reverse("horizon:project:security_groups:detail",
args=[data['id']])
+ params = {}
+ if 'description' in data:
+ params['description'] = data['description']
try:
rule = api.neutron.security_group_rule_create(
request,
@@ -429,7 +449,8 @@ class AddRule(forms.SelfHandlingForm):
data['from_port'],
data['to_port'],
data['cidr'],
- data['security_group'])
+ data['security_group'],
+ **params)
messages.success(request,
_('Successfully added rule: %s')
% six.text_type(rule))
diff --git a/openstack_dashboard/dashboards/project/security_groups/tables.py b/openstack_dashboard/dashboards/project/security_groups/tables.py
index 3872116ef..c4386c0b0 100644
--- a/openstack_dashboard/dashboards/project/security_groups/tables.py
+++ b/openstack_dashboard/dashboards/project/security_groups/tables.py
@@ -12,12 +12,16 @@
# License for the specific language governing permissions and limitations
# under the License.
+import functools
+
from django.conf import settings
+from django.template import defaultfilters
from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ungettext_lazy
import six
+from horizon import exceptions
from horizon import tables
from openstack_dashboard import api
@@ -228,6 +232,25 @@ class RulesTable(tables.DataTable):
remote_security_group = tables.Column(get_remote_security_group,
verbose_name=_("Remote Security"
" Group"))
+ description = tables.Column(
+ "description",
+ verbose_name=("Description"),
+ # 'default' filter is to hide the difference between empty string
+ # and None (null) in description. Both will be displayed as '-'.
+ filters=(functools.partial(defaultfilters.default, arg=_("-")),))
+
+ def __init__(self, request, *args, **kwargs):
+ super(RulesTable, self).__init__(request, *args, **kwargs)
+ try:
+ is_desc_supported = api.neutron.is_extension_supported(
+ self.request, 'standard-attr-description')
+ except Exception:
+ exceptions.handle(
+ self.request,
+ _('Failed to check if description field is supported.'))
+ is_desc_supported = False
+ if not is_desc_supported:
+ del self.columns['description']
def sanitize_id(self, obj_id):
return filters.get_int_or_uuid(obj_id)
diff --git a/openstack_dashboard/dashboards/project/security_groups/tests.py b/openstack_dashboard/dashboards/project/security_groups/tests.py
index 74b751df8..e12cdaa3f 100644
--- a/openstack_dashboard/dashboards/project/security_groups/tests.py
+++ b/openstack_dashboard/dashboards/project/security_groups/tests.py
@@ -160,11 +160,12 @@ class SecurityGroupsViewTests(test.TestCase):
def test_create_button_disabled_when_quota_exceeded_neutron_enabled(self):
self._test_create_button_disabled_when_quota_exceeded(True)
- def _add_security_group_rule_fixture(self, **kwargs):
+ def _add_security_group_rule_fixture(self, is_desc_support=True, **kwargs):
sec_group = self.security_groups.first()
sec_group_list = self.security_groups.list()
rule = self.security_group_rules.first()
+ self.mock_is_extension_supported.return_value = is_desc_support
self.mock_security_group_rule_create.return_value = rule
self.mock_security_group_list.return_value = sec_group_list
@@ -174,6 +175,13 @@ class SecurityGroupsViewTests(test.TestCase):
sec_group = self.security_groups.first()
rule = self.security_group_rules.first()
+ extra_params = {}
+ if 'description' in kwargs:
+ if kwargs['description'] is not None:
+ extra_params['description'] = kwargs['description']
+ else:
+ extra_params['description'] = rule.description
+
self.mock_security_group_rule_create.assert_called_once_with(
test.IsHttpRequest(),
kwargs.get('sec_group', sec_group.id),
@@ -183,9 +191,12 @@ class SecurityGroupsViewTests(test.TestCase):
kwargs.get('from_port', int(rule.from_port)),
kwargs.get('to_port', int(rule.to_port)),
kwargs.get('cidr', rule.ip_range['cidr']),
- kwargs.get('security_group', u'%s' % sec_group.id))
+ kwargs.get('security_group', u'%s' % sec_group.id),
+ **extra_params)
self.mock_security_group_list.assert_called_once_with(
test.IsHttpRequest())
+ self.mock_is_extension_supported.assert_called_once_with(
+ test.IsHttpRequest(), 'standard-attr-description')
@test.create_mocks({api.neutron: ('security_group_get',)})
def test_update_security_groups_get(self):
@@ -274,25 +285,34 @@ class SecurityGroupsViewTests(test.TestCase):
sec_group.name,
sec_group.description)
- @test.create_mocks({api.neutron: ('security_group_get',)})
+ @test.create_mocks({api.neutron: ('security_group_get',
+ 'is_extension_supported')})
def test_detail_get(self):
sec_group = self.security_groups.first()
self.mock_security_group_get.return_value = sec_group
+ self.mock_is_extension_supported.return_value = True
res = self.client.get(self.detail_url)
self.assertTemplateUsed(res, SG_DETAIL_TEMPLATE)
self.mock_security_group_get.assert_called_once_with(
test.IsHttpRequest(), sec_group.id)
+ self.mock_is_extension_supported.assert_called_once_with(
+ test.IsHttpRequest(), 'standard-attr-description')
- @test.create_mocks({api.neutron: ('security_group_get',)})
+ @test.create_mocks({api.neutron: ('security_group_get',
+ 'is_extension_supported')})
def test_detail_get_exception(self):
sec_group = self.security_groups.first()
self.mock_security_group_get.side_effect = self.exceptions.nova
+ self.mock_is_extension_supported.return_value = True
res = self.client.get(self.detail_url)
self.assertRedirectsNoFollow(res, INDEX_URL)
self.mock_security_group_get.assert_called_once_with(
test.IsHttpRequest(), sec_group.id)
+ self.mock_is_extension_supported.assert_called_once_with(
+ test.IsHttpRequest(), 'standard-attr-description')
@test.create_mocks({api.neutron: ('security_group_rule_create',
+ 'is_extension_supported',
'security_group_list')})
def test_detail_add_rule_cidr(self):
sec_group, rule = self._add_security_group_rule_fixture(
@@ -300,6 +320,7 @@ class SecurityGroupsViewTests(test.TestCase):
formData = {'method': 'AddRule',
'id': sec_group.id,
+ 'description': rule.description,
'port_or_range': 'port',
'port': rule.from_port,
'rule_menu': rule.ip_protocol,
@@ -311,6 +332,7 @@ class SecurityGroupsViewTests(test.TestCase):
security_group=None)
@test.create_mocks({api.neutron: ('security_group_rule_create',
+ 'is_extension_supported',
'security_group_list')})
def test_detail_add_rule_cidr_with_invalid_unused_fields(self):
sec_group, rule = self._add_security_group_rule_fixture(
@@ -318,6 +340,7 @@ class SecurityGroupsViewTests(test.TestCase):
formData = {'method': 'AddRule',
'id': sec_group.id,
+ 'description': rule.description,
'port_or_range': 'port',
'port': rule.from_port,
'to_port': 'INVALID',
@@ -336,6 +359,7 @@ class SecurityGroupsViewTests(test.TestCase):
security_group=None)
@test.create_mocks({api.neutron: ('security_group_rule_create',
+ 'is_extension_supported',
'security_group_list')})
def test_detail_add_rule_securitygroup_with_invalid_unused_fields(self):
sec_group, rule = self._add_security_group_rule_fixture(
@@ -343,6 +367,7 @@ class SecurityGroupsViewTests(test.TestCase):
formData = {'method': 'AddRule',
'id': sec_group.id,
+ 'description': rule.description,
'port_or_range': 'port',
'port': rule.from_port,
'to_port': 'INVALID',
@@ -361,6 +386,7 @@ class SecurityGroupsViewTests(test.TestCase):
cidr=None, ethertype='')
@test.create_mocks({api.neutron: ('security_group_rule_create',
+ 'is_extension_supported',
'security_group_list')})
def test_detail_add_rule_icmp_with_invalid_unused_fields(self):
sec_group, rule = self._add_security_group_rule_fixture(
@@ -368,6 +394,7 @@ class SecurityGroupsViewTests(test.TestCase):
formData = {'method': 'AddRule',
'id': sec_group.id,
+ 'description': rule.description,
'port_or_range': 'port',
'port': 'INVALID',
'to_port': 'INVALID',
@@ -386,12 +413,33 @@ class SecurityGroupsViewTests(test.TestCase):
ip_protocol='icmp', security_group=None)
@test.create_mocks({api.neutron: ('security_group_rule_create',
+ 'is_extension_supported',
+ 'security_group_list')})
+ def test_detail_add_rule_without_description_support(self):
+ sec_group, rule = self._add_security_group_rule_fixture(
+ security_group=None, is_desc_support=False)
+
+ formData = {'method': 'AddRule',
+ 'id': sec_group.id,
+ 'port_or_range': 'port',
+ 'port': rule.from_port,
+ 'rule_menu': rule.ip_protocol,
+ 'cidr': rule.ip_range['cidr'],
+ 'remote': 'cidr'}
+ res = self.client.post(self.edit_url, formData)
+ self.assertRedirectsNoFollow(res, self.detail_url)
+ self._check_add_security_group_rule(
+ security_group=None, description=None)
+
+ @test.create_mocks({api.neutron: ('security_group_rule_create',
+ 'is_extension_supported',
'security_group_list')})
def test_detail_add_rule_cidr_with_template(self):
sec_group = self.security_groups.first()
sec_group_list = self.security_groups.list()
rule = self.security_group_rules.first()
+ self.mock_is_extension_supported.return_value = True
self.mock_security_group_rule_create.return_value = rule
self.mock_security_group_list.return_value = sec_group_list
@@ -412,9 +460,12 @@ class SecurityGroupsViewTests(test.TestCase):
int(rule.from_port),
int(rule.to_port),
rule.ip_range['cidr'],
- None)
+ None,
+ description='')
self.mock_security_group_list.assert_called_once_with(
test.IsHttpRequest())
+ self.mock_is_extension_supported.assert_called_once_with(
+ test.IsHttpRequest(), 'standard-attr-description')
def _get_source_group_rule(self):
for rule in self.security_group_rules.list():
@@ -423,12 +474,14 @@ class SecurityGroupsViewTests(test.TestCase):
raise Exception("No matches found.")
@test.create_mocks({api.neutron: ('security_group_rule_create',
+ 'is_extension_supported',
'security_group_list')})
def test_detail_add_rule_self_as_source_group(self):
sec_group = self.security_groups.first()
sec_group_list = self.security_groups.list()
rule = self._get_source_group_rule()
+ self.mock_is_extension_supported.return_value = True
self.mock_security_group_rule_create.return_value = rule
self.mock_security_group_list.return_value = sec_group_list
@@ -453,17 +506,22 @@ class SecurityGroupsViewTests(test.TestCase):
int(rule.from_port),
int(rule.to_port),
None,
- u'%s' % sec_group.id)
+ u'%s' % sec_group.id,
+ description='')
self.mock_security_group_list.assert_called_once_with(
test.IsHttpRequest())
+ self.mock_is_extension_supported.assert_called_once_with(
+ test.IsHttpRequest(), 'standard-attr-description')
@test.create_mocks({api.neutron: ('security_group_rule_create',
+ 'is_extension_supported',
'security_group_list')})
def test_detail_add_rule_self_as_source_group_with_template(self):
sec_group = self.security_groups.first()
sec_group_list = self.security_groups.list()
rule = self._get_source_group_rule()
+ self.mock_is_extension_supported.return_value = True
self.mock_security_group_rule_create.return_value = rule
self.mock_security_group_list.return_value = sec_group_list
@@ -487,17 +545,22 @@ class SecurityGroupsViewTests(test.TestCase):
int(rule.from_port),
int(rule.to_port),
None,
- u'%s' % sec_group.id)
+ u'%s' % sec_group.id,
+ description='')
self.mock_security_group_list.assert_called_once_with(
test.IsHttpRequest())
+ self.mock_is_extension_supported.assert_called_once_with(
+ test.IsHttpRequest(), 'standard-attr-description')
- @test.create_mocks({api.neutron: ('security_group_list',)})
+ @test.create_mocks({api.neutron: ('security_group_list',
+ 'is_extension_supported')})
def test_detail_invalid_port(self):
sec_group = self.security_groups.first()
sec_group_list = self.security_groups.list()
rule = self.security_group_rules.first()
self.mock_security_group_list.return_value = sec_group_list
+ self.mock_is_extension_supported.return_value = True
formData = {'method': 'AddRule',
'id': sec_group.id,
@@ -513,13 +576,18 @@ class SecurityGroupsViewTests(test.TestCase):
self.assert_mock_multiple_calls_with_same_arguments(
self.mock_security_group_list, 2,
mock.call(test.IsHttpRequest()))
+ self.assert_mock_multiple_calls_with_same_arguments(
+ self.mock_is_extension_supported, 2,
+ mock.call(test.IsHttpRequest(), 'standard-attr-description'))
- @test.create_mocks({api.neutron: ('security_group_list',)})
+ @test.create_mocks({api.neutron: ('security_group_list',
+ 'is_extension_supported')})
def test_detail_invalid_port_range(self):
sec_group = self.security_groups.first()
sec_group_list = self.security_groups.list()
rule = self.security_group_rules.first()
+ self.mock_is_extension_supported.return_value = True
self.mock_security_group_list.return_value = sec_group_list
formData = {'method': 'AddRule',
@@ -563,14 +631,19 @@ class SecurityGroupsViewTests(test.TestCase):
self.assert_mock_multiple_calls_with_same_arguments(
self.mock_security_group_list, 6,
mock.call(test.IsHttpRequest()))
+ self.assert_mock_multiple_calls_with_same_arguments(
+ self.mock_is_extension_supported, 6,
+ mock.call(test.IsHttpRequest(), 'standard-attr-description'))
- @test.create_mocks({api.neutron: ('security_group_list',)})
+ @test.create_mocks({api.neutron: ('security_group_list',
+ 'is_extension_supported')})
def test_detail_invalid_icmp_rule(self):
sec_group = self.security_groups.first()
sec_group_list = self.security_groups.list()
icmp_rule = self.security_group_rules.list()[1]
self.mock_security_group_list.return_value = sec_group_list
+ self.mock_is_extension_supported.return_value = True
formData = {'method': 'AddRule',
'id': sec_group.id,
@@ -636,14 +709,19 @@ class SecurityGroupsViewTests(test.TestCase):
self.assert_mock_multiple_calls_with_same_arguments(
self.mock_security_group_list, 10,
mock.call(test.IsHttpRequest()))
+ self.assert_mock_multiple_calls_with_same_arguments(
+ self.mock_is_extension_supported, 10,
+ mock.call(test.IsHttpRequest(), 'standard-attr-description'))
@test.create_mocks({api.neutron: ('security_group_rule_create',
+ 'is_extension_supported',
'security_group_list')})
def test_detail_add_rule_exception(self):
sec_group = self.security_groups.first()
sec_group_list = self.security_groups.list()
rule = self.security_group_rules.first()
+ self.mock_is_extension_supported.return_value = True
self.mock_security_group_rule_create.side_effect = self.exceptions.nova
self.mock_security_group_list.return_value = sec_group_list
@@ -664,17 +742,22 @@ class SecurityGroupsViewTests(test.TestCase):
int(rule.from_port),
int(rule.to_port),
rule.ip_range['cidr'],
- None)
+ None,
+ description='')
self.mock_security_group_list.assert_called_once_with(
test.IsHttpRequest())
+ self.mock_is_extension_supported.assert_called_once_with(
+ test.IsHttpRequest(), 'standard-attr-description')
@test.create_mocks({api.neutron: ('security_group_rule_create',
+ 'is_extension_supported',
'security_group_list')})
def test_detail_add_rule_duplicated(self):
sec_group = self.security_groups.first()
sec_group_list = self.security_groups.list()
rule = self.security_group_rules.first()
+ self.mock_is_extension_supported.return_value = True
self.mock_security_group_rule_create.side_effect = exceptions.Conflict
self.mock_security_group_list.return_value = sec_group_list
@@ -696,15 +779,20 @@ class SecurityGroupsViewTests(test.TestCase):
int(rule.from_port),
int(rule.to_port),
rule.ip_range['cidr'],
- None)
+ None,
+ description='')
self.mock_security_group_list.assert_called_once_with(
test.IsHttpRequest())
+ self.mock_is_extension_supported.assert_called_once_with(
+ test.IsHttpRequest(), 'standard-attr-description')
- @test.create_mocks({api.neutron: ('security_group_rule_delete',)})
+ @test.create_mocks({api.neutron: ('security_group_rule_delete',
+ 'is_extension_supported')})
def test_detail_delete_rule(self):
sec_group = self.security_groups.first()
rule = self.security_group_rules.first()
self.mock_security_group_rule_delete.return_value = None
+ self.mock_is_extension_supported.return_value = True
form_data = {"action": "rules__delete__%s" % rule.id}
req = self.factory.post(self.edit_url, form_data)
@@ -715,12 +803,16 @@ class SecurityGroupsViewTests(test.TestCase):
self.detail_url)
self.mock_security_group_rule_delete.assert_called_once_with(
test.IsHttpRequest(), rule.id)
+ self.mock_is_extension_supported.assert_called_once_with(
+ test.IsHttpRequest(), 'standard-attr-description')
- @test.create_mocks({api.neutron: ('security_group_rule_delete',)})
+ @test.create_mocks({api.neutron: ('security_group_rule_delete',
+ 'is_extension_supported')})
def test_detail_delete_rule_exception(self):
sec_group = self.security_groups.first()
rule = self.security_group_rules.first()
self.mock_security_group_rule_delete.side_effect = self.exceptions.nova
+ self.mock_is_extension_supported.return_value = True
form_data = {"action": "rules__delete__%s" % rule.id}
req = self.factory.post(self.edit_url, form_data)
@@ -732,6 +824,8 @@ class SecurityGroupsViewTests(test.TestCase):
self.detail_url)
self.mock_security_group_rule_delete.assert_called_once_with(
test.IsHttpRequest(), rule.id)
+ self.mock_is_extension_supported.assert_called_once_with(
+ test.IsHttpRequest(), 'standard-attr-description')
@test.create_mocks({api.neutron: ('security_group_delete',)})
def test_delete_group(self):
@@ -763,12 +857,14 @@ class SecurityGroupsViewTests(test.TestCase):
test.IsHttpRequest(), sec_group.id)
@test.create_mocks({api.neutron: ('security_group_rule_create',
+ 'is_extension_supported',
'security_group_list')})
def test_detail_add_rule_custom_protocol(self):
sec_group = self.security_groups.first()
sec_group_list = self.security_groups.list()
rule = self.security_group_rules.first()
+ self.mock_is_extension_supported.return_value = True
self.mock_security_group_rule_create.return_value = rule
self.mock_security_group_list.return_value = sec_group_list
@@ -787,17 +883,21 @@ class SecurityGroupsViewTests(test.TestCase):
test.IsHttpRequest(),
sec_group.id, 'ingress', 'IPv6',
37, None, None, 'fe80::/48',
- None)
+ None, description='')
self.mock_security_group_list.assert_called_once_with(
test.IsHttpRequest())
+ self.mock_is_extension_supported.assert_called_once_with(
+ test.IsHttpRequest(), 'standard-attr-description')
@test.create_mocks({api.neutron: ('security_group_rule_create',
+ 'is_extension_supported',
'security_group_list')})
def test_detail_add_rule_egress(self):
sec_group = self.security_groups.first()
sec_group_list = self.security_groups.list()
rule = self.security_group_rules.first()
+ self.mock_is_extension_supported.return_value = True
self.mock_security_group_rule_create.return_value = rule
self.mock_security_group_list.return_value = sec_group_list
@@ -816,17 +916,21 @@ class SecurityGroupsViewTests(test.TestCase):
test.IsHttpRequest(),
sec_group.id, 'egress', 'IPv4',
'udp', 80, 80, '10.1.1.0/24',
- None)
+ None, description='')
self.mock_security_group_list.assert_called_once_with(
test.IsHttpRequest())
+ self.mock_is_extension_supported.assert_called_once_with(
+ test.IsHttpRequest(), 'standard-attr-description')
@test.create_mocks({api.neutron: ('security_group_rule_create',
+ 'is_extension_supported',
'security_group_list')})
def test_detail_add_rule_egress_with_all_tcp(self):
sec_group = self.security_groups.first()
sec_group_list = self.security_groups.list()
rule = self.security_group_rules.list()[3]
+ self.mock_is_extension_supported.return_value = True
self.mock_security_group_rule_create.return_value = rule
self.mock_security_group_list.return_value = sec_group_list
@@ -847,17 +951,22 @@ class SecurityGroupsViewTests(test.TestCase):
int(rule.from_port),
int(rule.to_port),
rule.ip_range['cidr'],
- None)
+ None,
+ description='')
self.mock_security_group_list.assert_called_once_with(
test.IsHttpRequest())
+ self.mock_is_extension_supported.assert_called_once_with(
+ test.IsHttpRequest(), 'standard-attr-description')
@test.create_mocks({api.neutron: ('security_group_rule_create',
+ 'is_extension_supported',
'security_group_list')})
def test_detail_add_rule_source_group_with_direction_ethertype(self):
sec_group = self.security_groups.first()
sec_group_list = self.security_groups.list()
rule = self._get_source_group_rule()
+ self.mock_is_extension_supported.return_value = True
self.mock_security_group_rule_create.return_value = rule
self.mock_security_group_list.return_value = sec_group_list
@@ -884,16 +993,21 @@ class SecurityGroupsViewTests(test.TestCase):
int(rule.from_port),
int(rule.to_port),
None,
- u'%s' % sec_group.id)
+ u'%s' % sec_group.id,
+ description='')
self.mock_security_group_list.assert_called_once_with(
test.IsHttpRequest())
+ self.mock_is_extension_supported.assert_called_once_with(
+ test.IsHttpRequest(), 'standard-attr-description')
@test.update_settings(
OPENSTACK_NEUTRON_NETWORK={'enable_ipv6': False})
- @test.create_mocks({api.neutron: ('security_group_list',)})
+ @test.create_mocks({api.neutron: ('security_group_list',
+ 'is_extension_supported')})
def test_add_rule_ethertype_with_ipv6_disabled(self):
self.mock_security_group_list.return_value = \
self.security_groups.list()
+ self.mock_is_extension_supported.return_value = True
res = self.client.get(self.edit_url)
@@ -911,14 +1025,18 @@ class SecurityGroupsViewTests(test.TestCase):
)
self.mock_security_group_list.assert_called_once_with(
test.IsHttpRequest())
+ self.mock_is_extension_supported.assert_called_once_with(
+ test.IsHttpRequest(), 'standard-attr-description')
@test.update_settings(
OPENSTACK_NEUTRON_NETWORK={'enable_ipv6': False})
- @test.create_mocks({api.neutron: ('security_group_list',)})
+ @test.create_mocks({api.neutron: ('security_group_list',
+ 'is_extension_supported')})
def test_add_rule_cidr_with_ipv6_disabled(self):
sec_group = self.security_groups.first()
self.mock_security_group_list.return_value = \
self.security_groups.list()
+ self.mock_is_extension_supported.return_value = True
formData = {'method': 'AddRule',
'id': sec_group.id,
@@ -935,13 +1053,18 @@ class SecurityGroupsViewTests(test.TestCase):
self.assert_mock_multiple_calls_with_same_arguments(
self.mock_security_group_list, 2,
mock.call(test.IsHttpRequest()))
+ self.assert_mock_multiple_calls_with_same_arguments(
+ self.mock_is_extension_supported, 2,
+ mock.call(test.IsHttpRequest(), 'standard-attr-description'))
- @test.create_mocks({api.neutron: ('security_group_list',)})
+ @test.create_mocks({api.neutron: ('security_group_list',
+ 'is_extension_supported')})
def test_detail_add_rule_invalid_port(self):
sec_group = self.security_groups.first()
sec_group_list = self.security_groups.list()
rule = self.security_group_rules.first()
+ self.mock_is_extension_supported.return_value = True
self.mock_security_group_list.return_value = sec_group_list
formData = {'method': 'AddRule',
@@ -958,14 +1081,19 @@ class SecurityGroupsViewTests(test.TestCase):
self.assert_mock_multiple_calls_with_same_arguments(
self.mock_security_group_list, 2,
mock.call(test.IsHttpRequest()))
+ self.assert_mock_multiple_calls_with_same_arguments(
+ self.mock_is_extension_supported, 2,
+ mock.call(test.IsHttpRequest(), 'standard-attr-description'))
@test.create_mocks({api.neutron: ('security_group_rule_create',
+ 'is_extension_supported',
'security_group_list')})
def test_detail_add_rule_ingress_tcp_without_port(self):
sec_group = self.security_groups.first()
sec_group_list = self.security_groups.list()
rule = self.security_group_rules.list()[3]
+ self.mock_is_extension_supported.return_value = True
self.mock_security_group_rule_create.return_value = rule
self.mock_security_group_list.return_value = sec_group_list
@@ -985,17 +1113,22 @@ class SecurityGroupsViewTests(test.TestCase):
None,
None,
rule.ip_range['cidr'],
- None)
+ None,
+ description='')
self.mock_security_group_list.assert_called_once_with(
test.IsHttpRequest())
+ self.mock_is_extension_supported.assert_called_once_with(
+ test.IsHttpRequest(), 'standard-attr-description')
@test.create_mocks({api.neutron: ('security_group_rule_create',
+ 'is_extension_supported',
'security_group_list')})
def test_detail_add_rule_custom_without_protocol(self):
sec_group = self.security_groups.first()
sec_group_list = self.security_groups.list()
rule = self.security_group_rules.list()[3]
+ self.mock_is_extension_supported.return_value = True
self.mock_security_group_rule_create.return_value = rule
self.mock_security_group_list.return_value = sec_group_list
@@ -1016,6 +1149,9 @@ class SecurityGroupsViewTests(test.TestCase):
None,
None,
rule.ip_range['cidr'],
- None)
+ None,
+ description='')
self.mock_security_group_list.assert_called_once_with(
test.IsHttpRequest())
+ self.mock_is_extension_supported.assert_called_once_with(
+ test.IsHttpRequest(), 'standard-attr-description')