mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[ec2] add specs/mocks for named ingresses
This commit is contained in:
parent
5e06297cd4
commit
efa6a5b5ef
2 changed files with 32 additions and 15 deletions
|
@ -35,15 +35,23 @@ module Fog
|
||||||
|
|
||||||
class Mock
|
class Mock
|
||||||
|
|
||||||
# TODO: handle the GroupName/Source/Source case
|
|
||||||
def authorize_security_group_ingress(options = {})
|
def authorize_security_group_ingress(options = {})
|
||||||
if options['GroupName'] && options['SourceSecurityGroupName'] && options['SourceSecurityGroupOwnerId']
|
response = Excon::Response.new
|
||||||
raise MockNotImplemented.new("Contributions welcome!")
|
group = @data[:security_groups][options['GroupName']]
|
||||||
else
|
group['ipPermissions'] ||= []
|
||||||
response = Excon::Response.new
|
|
||||||
group = @data[:security_groups][options['GroupName']]
|
|
||||||
|
|
||||||
group['ipPermissions'] ||= []
|
if options['GroupName'] && options['SourceSecurityGroupName'] && options['SourceSecurityGroupOwnerId']
|
||||||
|
owner = Fog::AWS::Mock.owner_id
|
||||||
|
['icmp', 'tcp', 'udp'].each do |protocol|
|
||||||
|
group['ipPermissions'] << {
|
||||||
|
'groups' => [{'groupName' => options['GroupName'], 'userId' => owner}],
|
||||||
|
'fromPort' => 1,
|
||||||
|
'ipRanges' => [],
|
||||||
|
'ipProtocol' => protocol,
|
||||||
|
'toPort' => 65535
|
||||||
|
}
|
||||||
|
end
|
||||||
|
else
|
||||||
group['ipPermissions'] << {
|
group['ipPermissions'] << {
|
||||||
'groups' => [],
|
'groups' => [],
|
||||||
'fromPort' => options['FromPort'],
|
'fromPort' => options['FromPort'],
|
||||||
|
@ -51,14 +59,13 @@ module Fog
|
||||||
'ipProtocol' => options['IpProtocol'],
|
'ipProtocol' => options['IpProtocol'],
|
||||||
'toPort' => options['ToPort']
|
'toPort' => options['ToPort']
|
||||||
}
|
}
|
||||||
|
|
||||||
response.status = 200
|
|
||||||
response.body = {
|
|
||||||
'requestId' => Fog::AWS::Mock.request_id,
|
|
||||||
'return' => true
|
|
||||||
}
|
|
||||||
response
|
|
||||||
end
|
end
|
||||||
|
response.status = 200
|
||||||
|
response.body = {
|
||||||
|
'requestId' => Fog::AWS::Mock.request_id,
|
||||||
|
'return' => true
|
||||||
|
}
|
||||||
|
response
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,7 +11,7 @@ describe 'EC2.authorize_security_group_ingress' do
|
||||||
AWS[:ec2].delete_security_group('fog_security_group')
|
AWS[:ec2].delete_security_group('fog_security_group')
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should return proper attributes" do
|
it "should return proper attributes for port based ingress" do
|
||||||
actual = AWS[:ec2].authorize_security_group_ingress({
|
actual = AWS[:ec2].authorize_security_group_ingress({
|
||||||
'FromPort' => 80,
|
'FromPort' => 80,
|
||||||
'GroupName' => 'fog_security_group',
|
'GroupName' => 'fog_security_group',
|
||||||
|
@ -22,5 +22,15 @@ describe 'EC2.authorize_security_group_ingress' do
|
||||||
[false, true].should include(actual.body['return'])
|
[false, true].should include(actual.body['return'])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should return proper attributes for named ingress" do
|
||||||
|
actual = AWS[:ec2].authorize_security_group_ingress({
|
||||||
|
'GroupName' => 'fog_security_group',
|
||||||
|
'SourceSecurityGroupName' => 'fog_security_group',
|
||||||
|
'SourceSecurityGroupOwnerId' => '254056571511'
|
||||||
|
})
|
||||||
|
actual.body['requestId'].should be_a(String)
|
||||||
|
[false, true].should include(actual.body['return'])
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue