mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[aws|compute] fix revoke_security_group method signature
This commit is contained in:
parent
1397c2d613
commit
17e137efa0
2 changed files with 93 additions and 60 deletions
|
@ -8,14 +8,13 @@ module Fog
|
||||||
# Remove permissions from a security group
|
# Remove permissions from a security group
|
||||||
#
|
#
|
||||||
# ==== Parameters
|
# ==== Parameters
|
||||||
|
# * 'GroupName'<~String> - Name of group
|
||||||
# * options<~Hash>:
|
# * options<~Hash>:
|
||||||
# * 'GroupName'<~String> - Name of group
|
|
||||||
# * 'SourceSecurityGroupName'<~String> - Name of security group to authorize
|
# * 'SourceSecurityGroupName'<~String> - Name of security group to authorize
|
||||||
# * 'SourceSecurityGroupOwnerId'<~String> - Name of owner to authorize
|
# * 'SourceSecurityGroupOwnerId'<~String> - Name of owner to authorize
|
||||||
# or
|
# or
|
||||||
# * 'CidrIp' - CIDR range
|
# * 'CidrIp' - CIDR range
|
||||||
# * 'FromPort' - Start of port range (or -1 for ICMP wildcard)
|
# * 'FromPort' - Start of port range (or -1 for ICMP wildcard)
|
||||||
# * 'GroupName' - Name of group to modify
|
|
||||||
# * 'IpProtocol' - Ip protocol, must be in ['tcp', 'udp', 'icmp']
|
# * 'IpProtocol' - Ip protocol, must be in ['tcp', 'udp', 'icmp']
|
||||||
# * 'ToPort' - End of port range (or -1 for ICMP wildcard)
|
# * 'ToPort' - End of port range (or -1 for ICMP wildcard)
|
||||||
#
|
#
|
||||||
|
@ -24,9 +23,18 @@ module Fog
|
||||||
# * body<~Hash>:
|
# * body<~Hash>:
|
||||||
# * 'requestId'<~String> - Id of request
|
# * 'requestId'<~String> - Id of request
|
||||||
# * 'return'<~Boolean> - success?
|
# * 'return'<~Boolean> - success?
|
||||||
def revoke_security_group_ingress(options = {})
|
def revoke_security_group_ingress(group_name, options = {})
|
||||||
|
if group_name.is_a?(Hash)
|
||||||
|
location = caller.first
|
||||||
|
warning = "[yellow][WARN] Fog::AWS::Compute#revoke_security_group_ingress now requires the 'group_name' parameter. Only specifying an options hash is now deprecated"
|
||||||
|
warning << " [light_black](" << location << ")[/] "
|
||||||
|
Formatador.display_line(warning)
|
||||||
|
options = group_name
|
||||||
|
group_name = options['GroupName']
|
||||||
|
end
|
||||||
request({
|
request({
|
||||||
'Action' => 'RevokeSecurityGroupIngress',
|
'Action' => 'RevokeSecurityGroupIngress',
|
||||||
|
'GroupName' => group_name,
|
||||||
:idempotent => true,
|
:idempotent => true,
|
||||||
:parser => Fog::Parsers::AWS::Compute::Basic.new
|
:parser => Fog::Parsers::AWS::Compute::Basic.new
|
||||||
}.merge!(options))
|
}.merge!(options))
|
||||||
|
@ -36,13 +44,21 @@ module Fog
|
||||||
|
|
||||||
class Mock
|
class Mock
|
||||||
|
|
||||||
def revoke_security_group_ingress(options = {})
|
def revoke_security_group_ingress(group_name, options = {})
|
||||||
|
if group_name.is_a?(Hash)
|
||||||
|
location = caller.first
|
||||||
|
warning = "[yellow][WARN] Fog::AWS::Compute#revoke_security_group_ingress now requires the 'group_name' parameter. Only specifying an options hash is now deprecated"
|
||||||
|
warning << " [light_black](" << location << ")[/] "
|
||||||
|
Formatador.display_line(warning)
|
||||||
|
options = group_name
|
||||||
|
group_name = options['GroupName']
|
||||||
|
end
|
||||||
response = Excon::Response.new
|
response = Excon::Response.new
|
||||||
group = @data[:security_groups][options['GroupName']]
|
group = @data[:security_groups][group_name]
|
||||||
if group
|
if group
|
||||||
if options['GroupName'] && options['SourceSecurityGroupName'] && options['SourceSecurityGroupOwnerId']
|
if options['SourceSecurityGroupName'] && options['SourceSecurityGroupOwnerId']
|
||||||
group['ipPermissions'].delete_if {|permission|
|
group['ipPermissions'].delete_if {|permission|
|
||||||
permission['groups'].first['groupName'] == options['GroupName']
|
permission['groups'].first['groupName'] == group_name
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ingress = group['ipPermissions'].select {|permission|
|
ingress = group['ipPermissions'].select {|permission|
|
||||||
|
@ -66,7 +82,7 @@ module Fog
|
||||||
}
|
}
|
||||||
response
|
response
|
||||||
else
|
else
|
||||||
raise Fog::AWS::Compute::NotFound.new("The security group '#{options['GroupName']}' does not exist")
|
raise Fog::AWS::Compute::NotFound.new("The security group '#{group_name}' does not exist")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -24,21 +24,25 @@ Shindo.tests('AWS::Compute | security group requests', ['aws']) do
|
||||||
AWS[:compute].create_security_group('fog_security_group', 'tests group').body
|
AWS[:compute].create_security_group('fog_security_group', 'tests group').body
|
||||||
end
|
end
|
||||||
|
|
||||||
tests("#authorize_security_group_ingress({'FromPort' => 80, 'GroupName' => 'fog_security_group', 'IpProtocol' => 'tcp', 'toPort' => 80})").formats(AWS::Compute::Formats::BASIC) do
|
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({
|
AWS[:compute].authorize_security_group_ingress(
|
||||||
'FromPort' => 80,
|
'fog_security_group',
|
||||||
'GroupName' => 'fog_security_group',
|
{
|
||||||
'IpProtocol' => 'tcp',
|
'FromPort' => 80,
|
||||||
'ToPort' => 80,
|
'IpProtocol' => 'tcp',
|
||||||
}).body
|
'ToPort' => 80,
|
||||||
|
}
|
||||||
|
).body
|
||||||
end
|
end
|
||||||
|
|
||||||
tests("#authorize_security_group_ingress({'GroupName' => 'fog_security_group', 'SourceSecurityGroupName' => 'fog_security_group', 'SourceSecurityGroupOwnerId' => '#{@owner_id}'})").formats(AWS::Compute::Formats::BASIC) do
|
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({
|
AWS[:compute].authorize_security_group_ingress(
|
||||||
'GroupName' => 'fog_security_group',
|
'fog_security_group',
|
||||||
'SourceSecurityGroupName' => 'fog_security_group',
|
{
|
||||||
'SourceSecurityGroupOwnerId' => @owner_id
|
'SourceSecurityGroupName' => 'fog_security_group',
|
||||||
}).body
|
'SourceSecurityGroupOwnerId' => @owner_id
|
||||||
|
}
|
||||||
|
).body
|
||||||
end
|
end
|
||||||
|
|
||||||
tests("#describe_security_groups").formats(@security_groups_format) do
|
tests("#describe_security_groups").formats(@security_groups_format) do
|
||||||
|
@ -49,21 +53,26 @@ Shindo.tests('AWS::Compute | security group requests', ['aws']) do
|
||||||
AWS[:compute].describe_security_groups('group-name' => 'fog_security_group').body
|
AWS[:compute].describe_security_groups('group-name' => 'fog_security_group').body
|
||||||
end
|
end
|
||||||
|
|
||||||
tests("#revoke_security_group_ingress({'FromPort' => 80, 'GroupName' => 'fog_security_group', 'IpProtocol' => 'tcp', 'toPort' => 80})").formats(AWS::Compute::Formats::BASIC) do
|
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({
|
AWS[:compute].revoke_security_group_ingress(
|
||||||
'FromPort' => 80,
|
'fog_security_group',
|
||||||
'GroupName' => 'fog_security_group',
|
{
|
||||||
'IpProtocol' => 'tcp',
|
'FromPort' => 80,
|
||||||
'ToPort' => 80,
|
'IpProtocol' => 'tcp',
|
||||||
}).body
|
'ToPort' => 80,
|
||||||
|
}
|
||||||
|
).body
|
||||||
end
|
end
|
||||||
|
|
||||||
tests("#revoke_security_group_ingress({'GroupName' => 'fog_security_group', 'SourceSecurityGroupName' => 'fog_security_group', 'SourceSecurityGroupOwnerId' => '#{@owner_id}'})").formats(AWS::Compute::Formats::BASIC) do
|
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({
|
AWS[:compute].revoke_security_group_ingress(
|
||||||
'GroupName' => 'fog_security_group',
|
'fog_security_group',
|
||||||
'SourceSecurityGroupName' => 'fog_security_group',
|
{
|
||||||
'SourceSecurityGroupOwnerId' => @owner_id
|
'GroupName' => 'fog_security_group',
|
||||||
}).body
|
'SourceSecurityGroupName' => 'fog_security_group',
|
||||||
|
'SourceSecurityGroupOwnerId' => @owner_id
|
||||||
|
}
|
||||||
|
).body
|
||||||
end
|
end
|
||||||
|
|
||||||
tests("#delete_security_group('fog_security_group')").formats(AWS::Compute::Formats::BASIC) do
|
tests("#delete_security_group('fog_security_group')").formats(AWS::Compute::Formats::BASIC) do
|
||||||
|
@ -79,38 +88,46 @@ Shindo.tests('AWS::Compute | security group requests', ['aws']) do
|
||||||
AWS[:compute].create_security_group(@security_group.name, @security_group.description)
|
AWS[:compute].create_security_group(@security_group.name, @security_group.description)
|
||||||
end
|
end
|
||||||
|
|
||||||
tests("#authorize_security_group_ingress({'FromPort' => 80, 'GroupName' => 'not_a_group_name', 'IpProtocol' => 'tcp', 'toPort' => 80})").raises(Fog::AWS::Compute::NotFound) do
|
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({
|
AWS[:compute].authorize_security_group_ingress(
|
||||||
'FromPort' => 80,
|
'not_a_group_name',
|
||||||
'GroupName' => 'not_a_group_name',
|
{
|
||||||
'IpProtocol' => 'tcp',
|
'FromPort' => 80,
|
||||||
'ToPort' => 80,
|
'IpProtocol' => 'tcp',
|
||||||
})
|
'ToPort' => 80,
|
||||||
|
}
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
tests("#authorize_security_group_ingress({'GroupName' => 'not_a_group_name', 'SourceSecurityGroupName' => 'not_a_group_name', 'SourceSecurityGroupOwnerId' => '#{@owner_id}'})").raises(Fog::AWS::Compute::NotFound) do
|
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({
|
AWS[:compute].authorize_security_group_ingress(
|
||||||
'GroupName' => 'not_a_group_name',
|
'not_a_group_name',
|
||||||
'SourceSecurityGroupName' => 'not_a_group_name',
|
{
|
||||||
'SourceSecurityGroupOwnerId' => @owner_id
|
'SourceSecurityGroupName' => 'not_a_group_name',
|
||||||
})
|
'SourceSecurityGroupOwnerId' => @owner_id
|
||||||
|
}
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
tests("#revoke_security_group_ingress({'FromPort' => 80, 'GroupName' => 'not_a_group_name', 'IpProtocol' => 'tcp', 'toPort' => 80})").raises(Fog::AWS::Compute::NotFound) do
|
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({
|
AWS[:compute].revoke_security_group_ingress(
|
||||||
'FromPort' => 80,
|
'not_a_group_name',
|
||||||
'GroupName' => 'not_a_group_name',
|
{
|
||||||
'IpProtocol' => 'tcp',
|
'FromPort' => 80,
|
||||||
'ToPort' => 80,
|
'IpProtocol' => 'tcp',
|
||||||
})
|
'ToPort' => 80,
|
||||||
|
}
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
tests("#revoke_security_group_ingress({'GroupName' => 'not_a_group_name', 'SourceSecurityGroupName' => 'not_a_group_name', 'SourceSecurityGroupOwnerId' => '#{@owner_id}'})").raises(Fog::AWS::Compute::NotFound) do
|
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({
|
AWS[:compute].revoke_security_group_ingress(
|
||||||
'GroupName' => 'not_a_group_name',
|
'not_a_group_name',
|
||||||
'SourceSecurityGroupName' => 'not_a_group_name',
|
{
|
||||||
'SourceSecurityGroupOwnerId' => @owner_id
|
'SourceSecurityGroupName' => 'not_a_group_name',
|
||||||
})
|
'SourceSecurityGroupOwnerId' => @owner_id
|
||||||
|
}
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
tests("#delete_security_group('not_a_group_name')").raises(Fog::AWS::Compute::NotFound) do
|
tests("#delete_security_group('not_a_group_name')").raises(Fog::AWS::Compute::NotFound) do
|
||||||
|
|
Loading…
Reference in a new issue