Require a GroupDescription for security group creation. Closes #112.
This commit is contained in:
parent
8182b3baa8
commit
06481ebe7e
@ -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:
|
||||
|
@ -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')
|
||||
|
Loading…
Reference in New Issue
Block a user