1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/tests/openstack/models/compute/server_tests.rb
Eric Hodel e85428dcf0 OpenStack servers can now retrieve security groups
Added default security group to the OpenStack compute mocks.

OpenStack server creation mock now stores the security groups for the
created server.

OpenStack security group mock deletion now deletes created security
groups.

OpenStack security group mock list now accepts a server id like the real
implementation.
2012-12-08 14:03:13 -08:00

45 lines
1.2 KiB
Ruby

Shindo.tests("Fog::Compute[:openstack] | server", ['openstack']) do
tests('success') do
tests('#security_groups').succeeds do
fog = Fog::Compute[:openstack]
begin
my_group = fog.security_groups.create(:name => 'my_group',
:description => 'my group')
flavor = fog.flavors.first.id
image = fog.images.first.id
server = fog.servers.new(:name => 'test server',
:flavor_ref => flavor,
:image_ref => image)
server.security_groups = my_group
server.save
found_groups = server.security_groups
returns(1) { found_groups.length }
group = found_groups.first
returns('my_group') { group.name }
returns(server.connection) { group.connection }
ensure
unless Fog.mocking? then
server.destroy if server
begin
fog.servers.get(server.id).wait_for do false end
rescue Fog::Errors::Error
# ignore, server went away
end
end
my_group.destroy if my_group
end
end
end
end