Require a GroupDescription for security group creation. Closes #112.

This commit is contained in:
Steve Pulec 2014-05-11 17:37:00 -04:00
parent 8182b3baa8
commit 06481ebe7e
2 changed files with 11 additions and 2 deletions

View File

@ -22,7 +22,6 @@ def process_rules_from_querystring(querystring):
if 'IpPermissions.1.IpRanges' in key:
ip_ranges.append(value[0])
source_groups = []
source_group_ids = []
@ -45,7 +44,11 @@ class SecurityGroups(BaseResponse):
def create_security_group(self):
name = self.querystring.get('GroupName')[0]
description = self.querystring.get('GroupDescription')[0]
try:
description = self.querystring.get('GroupDescription')[0]
except TypeError:
# No description found, return error
return "The request must contain the parameter GroupDescription", dict(status=400)
vpc_id = self.querystring.get("VpcId", [None])[0]
group = ec2_backend.create_security_group(name, description, vpc_id=vpc_id)
if not group:

View File

@ -21,6 +21,12 @@ def test_create_and_describe_security_group():
all_groups[0].name.should.equal('test security group')
@mock_ec2
def test_create_security_group_without_description_raises_error():
conn = boto.connect_ec2('the_key', 'the_secret')
conn.create_security_group.when.called_with('test security group', '').should.throw(EC2ResponseError)
@mock_ec2
def test_create_and_describe_vpc_security_group():
conn = boto.connect_ec2('the_key', 'the_secret')