Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Return a better error message(security_groups)

When creating a security group, whose name contains
other chars than numbers and letters, a non supportive error
message is thrown.

Fixes bug 1085888

Change-Id: I58ab57be29c0935dbfd10831fbaf97d09f654781
  • Loading branch information...
commit 146eef477b9ac0ea5b769cad26fb24cda33bf445 1 parent 155e3ae
@mrunge mrunge authored
View
4 openstack_dashboard/dashboards/project/access_and_security/security_groups/forms.py
@@ -34,6 +34,10 @@
class CreateGroup(forms.SelfHandlingForm):
name = forms.CharField(label=_("Name"),
+ error_messages={
+ 'required': _('This field is required.'),
+ 'invalid': _("The string may only contain"
+ " ASCII characters and numbers.")},
validators=[validators.validate_slug])
description = forms.CharField(label=_("Description"))
View
14 openstack_dashboard/dashboards/project/access_and_security/security_groups/tests.py
@@ -81,6 +81,20 @@ def test_create_security_groups_post_exception(self):
self.assertMessageCount(error=1)
self.assertRedirectsNoFollow(res, INDEX_URL)
+ def test_create_security_groups_post_wrong_name(self):
+ sec_group = self.security_groups.first()
+ self.mox.StubOutWithMock(api, 'security_group_create')
+ fail_name = sec_group.name + ' invalid'
+ self.mox.ReplayAll()
+
+ formData = {'method': 'CreateGroup',
+ 'name': fail_name,
+ 'description': sec_group.description}
+ res = self.client.post(SG_CREATE_URL, formData)
+ self.assertTemplateUsed(res,
+ 'project/access_and_security/security_groups/create.html')
+ self.assertContains(res, "ASCII")
+
def test_edit_rules_get(self):
sec_group = self.security_groups.first()
sec_group_list = self.security_groups.list()
Please sign in to comment.
Something went wrong with that request. Please try again.