2011-06-16 19:28:54 -04:00
|
|
|
Shindo.tests('Fog::Compute[:aws] | address requests', ['aws']) do
|
2010-09-09 20:50:38 -04:00
|
|
|
|
|
|
|
@addresses_format = {
|
|
|
|
'addressesSet' => [{
|
2012-02-20 16:16:52 -05:00
|
|
|
'allocationId' => Fog::Nullable::String,
|
|
|
|
'associationId' => Fog::Nullable::String,
|
|
|
|
'domain' => String,
|
|
|
|
'instanceId' => Fog::Nullable::String,
|
|
|
|
'publicIp' => String
|
2010-09-09 20:50:38 -04:00
|
|
|
}],
|
|
|
|
'requestId' => String
|
|
|
|
}
|
2011-06-16 19:28:54 -04:00
|
|
|
@server = Fog::Compute[:aws].servers.create
|
2010-09-09 20:50:38 -04:00
|
|
|
@server.wait_for { ready? }
|
2011-07-20 13:11:10 -04:00
|
|
|
@ip_address = @server.public_ip_address
|
2010-09-09 20:50:38 -04:00
|
|
|
|
|
|
|
tests('success') do
|
|
|
|
|
|
|
|
@public_ip = nil
|
|
|
|
|
2012-02-13 21:14:15 -05:00
|
|
|
tests('#allocate_address').formats({'domain' => String, 'publicIp' => String, 'requestId' => String}) do
|
2011-06-16 19:28:54 -04:00
|
|
|
data = Fog::Compute[:aws].allocate_address.body
|
2010-09-09 20:50:38 -04:00
|
|
|
@public_ip = data['publicIp']
|
|
|
|
data
|
|
|
|
end
|
|
|
|
|
|
|
|
tests('#describe_addresses').formats(@addresses_format) do
|
2011-06-16 19:28:54 -04:00
|
|
|
Fog::Compute[:aws].describe_addresses.body
|
2010-09-09 20:50:38 -04:00
|
|
|
end
|
|
|
|
|
2011-05-26 20:38:04 -04:00
|
|
|
tests("#describe_addresses('public-ip' => #{@public_ip}')").formats(@addresses_format) do
|
2011-06-16 19:28:54 -04:00
|
|
|
Fog::Compute[:aws].describe_addresses('public-ip' => @public_ip).body
|
2010-09-09 20:50:38 -04:00
|
|
|
end
|
|
|
|
|
2011-05-26 20:38:04 -04:00
|
|
|
tests("#associate_addresses('#{@server.identity}', '#{@public_ip}')").formats(AWS::Compute::Formats::BASIC) do
|
2011-06-16 19:28:54 -04:00
|
|
|
Fog::Compute[:aws].associate_address(@server.identity, @public_ip).body
|
2010-09-09 20:50:38 -04:00
|
|
|
end
|
2012-02-20 16:16:52 -05:00
|
|
|
|
2010-09-09 20:50:38 -04:00
|
|
|
tests("#dissassociate_address('#{@public_ip}')").formats(AWS::Compute::Formats::BASIC) do
|
2011-06-16 19:28:54 -04:00
|
|
|
Fog::Compute[:aws].disassociate_address(@public_ip).body
|
2010-09-09 20:50:38 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
tests("#release_address('#{@public_ip}')").formats(AWS::Compute::Formats::BASIC) do
|
2011-06-16 19:28:54 -04:00
|
|
|
Fog::Compute[:aws].release_address(@public_ip).body
|
2010-09-09 20:50:38 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2011-06-16 19:28:54 -04:00
|
|
|
tests('failure') do
|
2010-09-09 20:50:38 -04:00
|
|
|
|
2011-06-16 19:28:54 -04:00
|
|
|
@address = Fog::Compute[:aws].addresses.create
|
2010-09-09 20:50:38 -04:00
|
|
|
|
2011-06-16 19:28:54 -04:00
|
|
|
tests("#associate_addresses('i-00000000', '#{@address.identity}')").raises(Fog::Compute::AWS::NotFound) do
|
|
|
|
Fog::Compute[:aws].associate_address('i-00000000', @address.identity)
|
2010-09-09 20:50:38 -04:00
|
|
|
end
|
|
|
|
|
2011-06-16 19:28:54 -04:00
|
|
|
tests("#associate_addresses('#{@server.identity}', '127.0.0.1')").raises(Fog::Compute::AWS::Error) do
|
|
|
|
Fog::Compute[:aws].associate_address(@server.identity, '127.0.0.1')
|
2010-09-09 20:50:38 -04:00
|
|
|
end
|
|
|
|
|
2011-06-16 19:28:54 -04:00
|
|
|
tests("#associate_addresses('i-00000000', '127.0.0.1')").raises(Fog::Compute::AWS::NotFound) do
|
|
|
|
Fog::Compute[:aws].associate_address('i-00000000', '127.0.0.1')
|
2010-09-09 20:50:38 -04:00
|
|
|
end
|
|
|
|
|
2011-06-16 19:28:54 -04:00
|
|
|
tests("#disassociate_addresses('127.0.0.1') raises BadRequest error").raises(Fog::Compute::AWS::Error) do
|
|
|
|
Fog::Compute[:aws].disassociate_address('127.0.0.1')
|
2010-09-09 20:50:38 -04:00
|
|
|
end
|
|
|
|
|
2011-06-16 19:28:54 -04:00
|
|
|
tests("#release_address('127.0.0.1')").raises(Fog::Compute::AWS::Error) do
|
|
|
|
Fog::Compute[:aws].release_address('127.0.0.1')
|
2010-09-09 20:50:38 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
@address.destroy
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
@server.destroy
|
|
|
|
|
|
|
|
end
|