1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[digitalocean|compute] added get_ssh_key request and tests

This commit is contained in:
Sergio Rubio 2013-03-25 21:56:29 +01:00
parent 9397b368d3
commit 45ce6d0419
2 changed files with 61 additions and 0 deletions

View file

@ -0,0 +1,39 @@
module Fog
module Compute
class DigitalOcean
class Real
#
# This method shows a specific public SSH key in your account
# that can be added to a droplet.
#
# @see https://www.digitalocean.com/api#ssh_keys
#
def get_ssh_key(id)
request(
:expects => [200],
:method => 'GET',
:path => "ssh_keys/#{id}"
)
end
end
class Mock
def get_ssh_key(id)
response = Excon::Response.new
response.status = 200
response.body = {
"status" => "OK",
# key listing does not return ssh_pub_key
# https://www.digitalocean.com/api#ssh_keys
"ssh_key" => self.data[:ssh_keys].find { |k| k['id'] == id }
}
response
end
end
end
end
end

View file

@ -0,0 +1,22 @@
Shindo.tests('Fog::Compute[:digitalocean] | get_ssh_keys request', ['digitalocean', 'compute']) do
@ssh_key_format = {
'id' => Integer,
'name' => String,
'ssh_pub_key' => String,
}
service = Fog::Compute[:digitalocean]
tests('success') do
tests('#get_ssh_key') do
key = service.create_ssh_key 'fookey', 'ssh-dss FOO'
tests('format').data_matches_schema(@ssh_key_format) do
service.get_ssh_key(key.body['ssh_key']['id']).body['ssh_key']
end
end
end
end