2010-09-09 20:50:38 -04:00
|
|
|
Shindo.tests('AWS::Compute | security group requests', ['aws']) do
|
2010-05-22 19:01:45 -04:00
|
|
|
|
2010-05-26 18:22:23 -04:00
|
|
|
@security_groups_format = {
|
|
|
|
'requestId' => String,
|
|
|
|
'securityGroupInfo' => [{
|
|
|
|
'groupDescription' => String,
|
|
|
|
'groupName' => String,
|
|
|
|
'ipPermissions' => [{
|
|
|
|
'fromPort' => Integer,
|
|
|
|
'groups' => [{ 'groupName' => String, 'userId' => String }],
|
|
|
|
'ipProtocol' => String,
|
|
|
|
'ipRanges' => [],
|
|
|
|
'toPort' => Integer,
|
|
|
|
}],
|
|
|
|
'ownerId' => String
|
|
|
|
}]
|
|
|
|
}
|
|
|
|
|
2010-10-04 18:46:12 -04:00
|
|
|
@owner_id = AWS[:compute].describe_security_groups('group-name' => 'default').body['securityGroupInfo'].first['ownerId']
|
2010-05-22 19:01:45 -04:00
|
|
|
|
|
|
|
tests('success') do
|
|
|
|
|
2010-09-09 20:50:38 -04:00
|
|
|
tests("#create_security_group('fog_security_group', 'tests group')").formats(AWS::Compute::Formats::BASIC) do
|
|
|
|
AWS[:compute].create_security_group('fog_security_group', 'tests group').body
|
2010-05-22 19:01:45 -04:00
|
|
|
end
|
|
|
|
|
2011-03-03 18:44:49 -05:00
|
|
|
tests("#authorize_security_group_ingress('fog_security_group', {'FromPort' => 80, 'IpProtocol' => 'tcp', 'toPort' => 80})").formats(AWS::Compute::Formats::BASIC) do
|
|
|
|
AWS[:compute].authorize_security_group_ingress(
|
|
|
|
'fog_security_group',
|
|
|
|
{
|
|
|
|
'FromPort' => 80,
|
|
|
|
'IpProtocol' => 'tcp',
|
|
|
|
'ToPort' => 80,
|
|
|
|
}
|
|
|
|
).body
|
2010-05-22 19:01:45 -04:00
|
|
|
end
|
|
|
|
|
2011-03-03 18:44:49 -05:00
|
|
|
tests("#authorize_security_group_ingress('fog_security_group', {'SourceSecurityGroupName' => 'fog_security_group', 'SourceSecurityGroupOwnerId' => '#{@owner_id}'})").formats(AWS::Compute::Formats::BASIC) do
|
|
|
|
AWS[:compute].authorize_security_group_ingress(
|
|
|
|
'fog_security_group',
|
|
|
|
{
|
|
|
|
'SourceSecurityGroupName' => 'fog_security_group',
|
|
|
|
'SourceSecurityGroupOwnerId' => @owner_id
|
|
|
|
}
|
|
|
|
).body
|
2010-05-22 19:01:45 -04:00
|
|
|
end
|
|
|
|
|
2010-05-26 18:22:23 -04:00
|
|
|
tests("#describe_security_groups").formats(@security_groups_format) do
|
2010-09-09 20:50:38 -04:00
|
|
|
AWS[:compute].describe_security_groups.body
|
2010-05-22 19:01:45 -04:00
|
|
|
end
|
|
|
|
|
2010-10-04 18:46:12 -04:00
|
|
|
tests("#describe_security_groups('group-name' => 'fog_security_group')").formats(@security_groups_format) do
|
|
|
|
AWS[:compute].describe_security_groups('group-name' => 'fog_security_group').body
|
2010-05-22 19:01:45 -04:00
|
|
|
end
|
|
|
|
|
2011-03-03 18:44:49 -05:00
|
|
|
tests("#revoke_security_group_ingress('fog_security_group', {'FromPort' => 80, 'IpProtocol' => 'tcp', 'toPort' => 80})").formats(AWS::Compute::Formats::BASIC) do
|
|
|
|
AWS[:compute].revoke_security_group_ingress(
|
|
|
|
'fog_security_group',
|
|
|
|
{
|
|
|
|
'FromPort' => 80,
|
|
|
|
'IpProtocol' => 'tcp',
|
|
|
|
'ToPort' => 80,
|
|
|
|
}
|
|
|
|
).body
|
2010-05-22 19:01:45 -04:00
|
|
|
end
|
|
|
|
|
2011-03-03 18:44:49 -05:00
|
|
|
tests("#revoke_security_group_ingress('fog_security_group', {'SourceSecurityGroupName' => 'fog_security_group', 'SourceSecurityGroupOwnerId' => '#{@owner_id}'})").formats(AWS::Compute::Formats::BASIC) do
|
|
|
|
AWS[:compute].revoke_security_group_ingress(
|
|
|
|
'fog_security_group',
|
|
|
|
{
|
|
|
|
'GroupName' => 'fog_security_group',
|
|
|
|
'SourceSecurityGroupName' => 'fog_security_group',
|
|
|
|
'SourceSecurityGroupOwnerId' => @owner_id
|
|
|
|
}
|
|
|
|
).body
|
2010-05-22 19:01:45 -04:00
|
|
|
end
|
|
|
|
|
2010-09-09 20:50:38 -04:00
|
|
|
tests("#delete_security_group('fog_security_group')").formats(AWS::Compute::Formats::BASIC) do
|
|
|
|
AWS[:compute].delete_security_group('fog_security_group').body
|
2010-05-22 19:01:45 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
tests('failure') do
|
|
|
|
|
2010-09-09 20:50:38 -04:00
|
|
|
@security_group = AWS[:compute].security_groups.create(:description => 'tests group', :name => 'fog_security_group')
|
2010-05-22 19:01:45 -04:00
|
|
|
|
2010-09-09 20:50:38 -04:00
|
|
|
tests("duplicate #create_security_group(#{@security_group.name}, #{@security_group.description})").raises(Fog::AWS::Compute::Error) do
|
|
|
|
AWS[:compute].create_security_group(@security_group.name, @security_group.description)
|
2010-05-22 19:01:45 -04:00
|
|
|
end
|
|
|
|
|
2011-03-03 18:44:49 -05:00
|
|
|
tests("#authorize_security_group_ingress('not_a_group_name', {'FromPort' => 80, 'IpProtocol' => 'tcp', 'toPort' => 80})").raises(Fog::AWS::Compute::NotFound) do
|
|
|
|
AWS[:compute].authorize_security_group_ingress(
|
|
|
|
'not_a_group_name',
|
|
|
|
{
|
|
|
|
'FromPort' => 80,
|
|
|
|
'IpProtocol' => 'tcp',
|
|
|
|
'ToPort' => 80,
|
|
|
|
}
|
|
|
|
)
|
2010-05-22 19:01:45 -04:00
|
|
|
end
|
|
|
|
|
2011-03-03 18:44:49 -05:00
|
|
|
tests("#authorize_security_group_ingress('not_a_group_name', {'SourceSecurityGroupName' => 'not_a_group_name', 'SourceSecurityGroupOwnerId' => '#{@owner_id}'})").raises(Fog::AWS::Compute::NotFound) do
|
|
|
|
AWS[:compute].authorize_security_group_ingress(
|
|
|
|
'not_a_group_name',
|
|
|
|
{
|
|
|
|
'SourceSecurityGroupName' => 'not_a_group_name',
|
|
|
|
'SourceSecurityGroupOwnerId' => @owner_id
|
|
|
|
}
|
|
|
|
)
|
2010-05-22 19:01:45 -04:00
|
|
|
end
|
|
|
|
|
2011-03-03 18:44:49 -05:00
|
|
|
tests("#revoke_security_group_ingress('not_a_group_name', {'FromPort' => 80, 'IpProtocol' => 'tcp', 'toPort' => 80})").raises(Fog::AWS::Compute::NotFound) do
|
|
|
|
AWS[:compute].revoke_security_group_ingress(
|
|
|
|
'not_a_group_name',
|
|
|
|
{
|
|
|
|
'FromPort' => 80,
|
|
|
|
'IpProtocol' => 'tcp',
|
|
|
|
'ToPort' => 80,
|
|
|
|
}
|
|
|
|
)
|
2010-05-22 19:01:45 -04:00
|
|
|
end
|
|
|
|
|
2011-03-03 18:44:49 -05:00
|
|
|
tests("#revoke_security_group_ingress('not_a_group_name', {'SourceSecurityGroupName' => 'not_a_group_name', 'SourceSecurityGroupOwnerId' => '#{@owner_id}'})").raises(Fog::AWS::Compute::NotFound) do
|
|
|
|
AWS[:compute].revoke_security_group_ingress(
|
|
|
|
'not_a_group_name',
|
|
|
|
{
|
|
|
|
'SourceSecurityGroupName' => 'not_a_group_name',
|
|
|
|
'SourceSecurityGroupOwnerId' => @owner_id
|
|
|
|
}
|
|
|
|
)
|
2010-05-22 19:01:45 -04:00
|
|
|
end
|
|
|
|
|
2010-09-09 20:50:38 -04:00
|
|
|
tests("#delete_security_group('not_a_group_name')").raises(Fog::AWS::Compute::NotFound) do
|
|
|
|
AWS[:compute].delete_security_group('not_a_group_name')
|
2010-05-22 19:01:45 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
@security_group.destroy
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|