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
|
|
|
|
|
2010-05-26 18:22:23 -04:00
|
|
|
@keypair_format = {
|
|
|
|
'keyFingerprint' => String,
|
|
|
|
'keyName' => String,
|
|
|
|
'requestId' => String
|
|
|
|
}
|
|
|
|
|
|
|
|
@keypairs_format = {
|
|
|
|
'keySet' => [{
|
|
|
|
'keyFingerprint' => String,
|
|
|
|
'keyName' => String
|
|
|
|
}],
|
|
|
|
'requestId' => String
|
|
|
|
}
|
|
|
|
|
2010-09-28 17:48:37 -04:00
|
|
|
@key_pair_name = 'fog_create_key_pair'
|
|
|
|
@public_key_material = 'ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA1SL+kgze8tvSFW6Tyj3RyZc9iFVQDiCKzjgwn2tS7hyWxaiDhjfY2mBYSZwFdKN+ZdsXDJL4CPutUg4DKoQneVgIC1zuXrlpPbaT0Btu2aFd4qNfJ85PBrOtw2GrWZ1kcIgzZ1mMbQt6i1vhsySD2FEj+5kGHouNxQpI5dFR5K+nGgcTLFGnzb/MPRBk136GVnuuYfJ2I4va/chstThoP8UwnoapRHcBpwTIfbmmL91BsRVqjXZEUT73nxpxFeXXidYwhHio+5dXwE0aM/783B/3cPG6FVoxrBvjoNpQpAcEyjtRh9lpwHZtSEW47WNzpIW3PhbQ8j4MryznqF1Rhw=='
|
2010-05-22 18:09:35 -04:00
|
|
|
|
2010-09-28 17:48:37 -04:00
|
|
|
tests("#create_key_pair('#{@key_pair_name}')").formats(@keypair_format.merge({'keyMaterial' => String})) 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
|
|
|
|
|
2010-05-26 18:22:23 -04:00
|
|
|
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
|
|
|
|
|
2010-10-04 18:46:12 -04:00
|
|
|
tests("#describe_key_pairs('key-name' => '#{@key_pair_name}')").formats(@keypairs_format) do
|
|
|
|
AWS[:compute].describe_key_pairs('key-name' => @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
|
|
|
|
|
2010-09-28 17:48:37 -04:00
|
|
|
tests("#import_key_pair('fog_import_key_pair', '#{@public_key_material}')").formats(@keypair_format) do
|
|
|
|
AWS[:compute].import_key_pair('fog_import_key_pair', @public_key_material).body
|
|
|
|
end
|
|
|
|
|
|
|
|
tests("#delete_key_pair('fog_import_key_pair)").succeeds do
|
|
|
|
AWS[:compute].delete_key_pair('fog_import_key_pair')
|
|
|
|
end
|
|
|
|
|
2010-05-22 18:09:35 -04:00
|
|
|
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
|
|
|
|
|
|
|
|
@key_pair.destroy
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|