1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/tests/aws/requests/compute/key_pair_tests.rb

60 lines
1.6 KiB
Ruby
Raw Normal View History

2010-09-09 20:50:38 -04:00
Shindo.tests('AWS::Compute | key pair requests', ['aws']) do
2010-05-22 18:09:35 -04:00
tests('success') do
@keypair_format = {
'keyFingerprint' => String,
'keyMaterial' => String,
'keyName' => String,
'requestId' => String
}
@keypairs_format = {
'keySet' => [{
'keyFingerprint' => String,
'keyName' => String
}],
'requestId' => String
}
2010-05-22 18:09:35 -04:00
@key_pair_name = 'fog_key_pair'
tests("#create_key_pair('#{@key_pair_name}')").formats(@keypair_format) do
2010-09-09 20:50:38 -04:00
AWS[:compute].create_key_pair(@key_pair_name).body
2010-05-22 18:09:35 -04:00
end
tests('#describe_key_pairs').formats(@keypairs_format) do
2010-09-09 20:50:38 -04:00
AWS[:compute].describe_key_pairs.body
2010-05-22 18:09:35 -04:00
end
tests("#describe_key_pairs(#{@key_pair_name})").formats(@keypairs_format) do
2010-09-09 20:50:38 -04:00
AWS[:compute].describe_key_pairs(@key_pair_name).body
2010-05-22 18:09:35 -04:00
end
2010-09-09 20:50:38 -04:00
tests("#delete_key_pair('#{@key_pair_name}')").formats(AWS::Compute::Formats::BASIC) do
AWS[:compute].delete_key_pair(@key_pair_name).body
2010-05-22 18:09:35 -04:00
end
tests("#delete_key_pair('not_a_key_name')").succeeds do
2010-09-09 20:50:38 -04:00
AWS[:compute].delete_key_pair('not_a_key_name')
2010-05-22 18:09:35 -04:00
end
end
tests('failure') do
2010-09-09 20:50:38 -04:00
@key_pair = AWS[:compute].key_pairs.create(:name => 'fog_key_pair')
2010-05-22 18:09:35 -04:00
2010-09-09 20:50:38 -04:00
tests("duplicate #create_key_pair('#{@key_pair.name}')").raises(Fog::AWS::Compute::Error) do
AWS[:compute].create_key_pair(@key_pair.name)
2010-05-22 18:09:35 -04:00
end
2010-09-09 20:50:38 -04:00
tests("#describe_key_pair('not_a_key_name')").raises(Fog::AWS::Compute::NotFound) do
AWS[:compute].describe_key_pairs('not_a_key_name').body
2010-05-22 18:09:35 -04:00
end
@key_pair.destroy
end
end