mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Add tests for keypairs.
This commit is contained in:
parent
05f3c840af
commit
26e2fa51ec
1 changed files with 67 additions and 0 deletions
67
tests/hp/requests/compute/key_pair_tests.rb
Normal file
67
tests/hp/requests/compute/key_pair_tests.rb
Normal file
|
@ -0,0 +1,67 @@
|
|||
Shindo.tests('Fog::Compute[:hp] | key pair requests', ['hp']) do
|
||||
|
||||
tests('success') do
|
||||
|
||||
@keypair_format = {
|
||||
'public_key' => String,
|
||||
'fingerprint' => String,
|
||||
'name' => String
|
||||
}
|
||||
|
||||
@keypairs_format = {
|
||||
'keypairs' => [{
|
||||
'name' => String,
|
||||
'fingerprint' => String,
|
||||
'public_key' => String
|
||||
}]
|
||||
}
|
||||
|
||||
@key_pair_name = 'fog_create_key_pair'
|
||||
@public_key_material = 'ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA1SL+kgze8tvSFW6Tyj3RyZc9iFVQDiCKzjgwn2tS7hyWxaiDhjfY2mBYSZwFdKN+ZdsXDJL4CPutUg4DKoQneVgIC1zuXrlpPbaT0Btu2aFd4qNfJ85PBrOtw2GrWZ1kcIgzZ1mMbQt6i1vhsySD2FEj+5kGHouNxQpI5dFR5K+nGgcTLFGnzb/MPRBk136GVnuuYfJ2I4va/chstThoP8UwnoapRHcBpwTIfbmmL91BsRVqjXZEUT73nxpxFeXXidYwhHio+5dXwE0aM/783B/3cPG6FVoxrBvjoNpQpAcEyjtRh9lpwHZtSEW47WNzpIW3PhbQ8j4MryznqF1Rhw=='
|
||||
|
||||
tests("#create_key_pair('#{@key_pair_name}')").formats({'keypair' => @keypair_format.merge({'private_key' => String, 'user_id' => String})}) do
|
||||
body = Fog::Compute[:hp].create_key_pair(@key_pair_name).body
|
||||
tests("private_key").returns(OpenSSL::PKey::RSA, "is a valid private RSA key") do
|
||||
OpenSSL::PKey::RSA.new(body['keypair']['private_key']).class
|
||||
end
|
||||
body
|
||||
end
|
||||
|
||||
tests('#list_key_pairs').formats(@keypairs_format) do
|
||||
Fog::Compute[:hp].list_key_pairs.body
|
||||
end
|
||||
|
||||
tests("#delete_key_pair('#{@key_pair_name}')").succeeds do
|
||||
Fog::Compute[:hp].delete_key_pair(@key_pair_name)
|
||||
end
|
||||
|
||||
tests("#create_key_pair('fog_import_key_pair', '#{@public_key_material}')").formats({'keypair' => @keypair_format.merge({'private_key' => String, 'user_id' => String})}) do
|
||||
body = Fog::Compute[:hp].create_key_pair('fog_import_key_pair', @public_key_material).body
|
||||
tests("private_key").returns(OpenSSL::PKey::RSA, "is a valid private RSA key") do
|
||||
OpenSSL::PKey::RSA.new(body['keypair']['private_key']).class
|
||||
end
|
||||
body
|
||||
end
|
||||
|
||||
tests("#delete_key_pair('fog_import_key_pair)").succeeds do
|
||||
Fog::Compute[:hp].delete_key_pair('fog_import_key_pair')
|
||||
end
|
||||
|
||||
tests("#delete_key_pair('not_a_key_name')").succeeds do
|
||||
Fog::Compute[:hp].delete_key_pair('not_a_key_name')
|
||||
end
|
||||
|
||||
end
|
||||
tests('failure') do
|
||||
|
||||
@key_pair = Fog::Compute[:hp].key_pairs.create(:name => 'fog_key_pair')
|
||||
|
||||
tests("duplicate #create_key_pair('#{@key_pair.name}')").raises(Fog::Compute::HP::NotFound) do
|
||||
Fog::Compute[:hp].create_key_pair(@key_pair.name)
|
||||
end
|
||||
|
||||
@key_pair.destroy
|
||||
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in a new issue