2013-07-31 15:12:43 -04:00
|
|
|
Shindo.tests('Fog::Compute::RackspaceV2 | key_pairs', ['rackspace']) do
|
2013-07-24 17:17:36 -04:00
|
|
|
service = Fog::Compute::RackspaceV2.new
|
|
|
|
|
2013-07-26 02:57:02 -04:00
|
|
|
name = Fog::Mock.random_letters(32)
|
|
|
|
key = nil
|
2013-07-24 17:17:36 -04:00
|
|
|
|
2013-07-26 02:57:02 -04:00
|
|
|
tests("API access") do
|
|
|
|
begin
|
|
|
|
tests("create").succeeds do
|
2013-07-31 15:12:43 -04:00
|
|
|
key = service.key_pairs.create({:name => name})
|
2013-07-26 02:57:02 -04:00
|
|
|
end
|
2013-07-24 17:17:36 -04:00
|
|
|
|
2013-07-26 02:57:02 -04:00
|
|
|
tests("list all").succeeds do
|
2013-07-31 15:12:43 -04:00
|
|
|
service.key_pairs.all
|
2013-07-26 02:57:02 -04:00
|
|
|
end
|
2013-07-24 17:17:36 -04:00
|
|
|
|
2013-07-26 02:57:02 -04:00
|
|
|
tests("get").succeeds do
|
2013-07-31 15:12:43 -04:00
|
|
|
service.key_pairs.get(name)
|
2013-07-26 02:57:02 -04:00
|
|
|
end
|
2013-07-24 17:17:36 -04:00
|
|
|
|
2013-07-26 02:57:02 -04:00
|
|
|
tests("delete").succeeds do
|
2013-07-31 15:12:43 -04:00
|
|
|
key = nil if service.key_pairs.destroy(name)
|
2013-07-26 02:57:02 -04:00
|
|
|
key == nil
|
|
|
|
end
|
2013-07-24 17:17:36 -04:00
|
|
|
|
2013-07-26 09:00:45 -04:00
|
|
|
tests("get unknown").returns(nil) do
|
2013-07-31 15:12:43 -04:00
|
|
|
service.key_pairs.get(Fog::Mock.random_letters(32))
|
2013-07-26 02:57:02 -04:00
|
|
|
end
|
|
|
|
|
2013-07-26 09:00:45 -04:00
|
|
|
tests("delete unknown").raises(Fog::Compute::RackspaceV2::NotFound) do
|
2013-07-31 15:12:43 -04:00
|
|
|
service.key_pairs.destroy(Fog::Mock.random_letters(32))
|
2013-07-26 02:57:02 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
tests("create again after delete").succeeds do
|
2013-07-31 15:12:43 -04:00
|
|
|
key = service.key_pairs.create({:name => name})
|
2013-07-26 02:57:02 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
tests("create already existing").raises(Fog::Compute::RackspaceV2::ServiceError) do
|
2013-07-31 15:12:43 -04:00
|
|
|
service.key_pairs.create({:name => name})
|
2013-07-26 02:57:02 -04:00
|
|
|
end
|
2013-07-24 17:17:36 -04:00
|
|
|
|
2013-07-26 02:57:02 -04:00
|
|
|
ensure
|
|
|
|
key.destroy if key
|
2013-07-24 17:17:36 -04:00
|
|
|
end
|
2013-07-26 02:57:02 -04:00
|
|
|
|
2013-07-24 17:17:36 -04:00
|
|
|
end
|
|
|
|
end
|