Skip to content

Commit

Permalink
[ibm] Generated key needs different name, supplied key only returns s…
Browse files Browse the repository at this point in the history
…uccess
  • Loading branch information
decklin committed Mar 21, 2012
1 parent 92f39c8 commit 220cb9a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions lib/fog/ibm/requests/compute/create_key.rb
Expand Up @@ -46,12 +46,12 @@ def create_key(name, public_key=nil)
if public_key.nil?
private_key = Fog::IBM::Mock.key_material
public_key = private_key.public_key
response.body = attributes.merge("keyMaterial" => private_key.to_s)
else
response.body = { 'success' => true }
end
public_key = { "keyMaterial" => public_key.to_s }.merge(attributes.dup)
private_key = { "keyMaterial" => private_key.to_s }.merge(attributes.dup)
response.body = private_key
self.data[:keys][name] = public_key
self.data[:private_keys][name] = private_key
self.data[:keys][name] = attributes.merge("keyMaterial" => public_key.to_s)
self.data[:private_keys][name] = attributes.merge("keyMaterial" => private_key.to_s)
response
end

Expand Down
6 changes: 3 additions & 3 deletions tests/ibm/requests/compute/key_tests.rb
Expand Up @@ -18,11 +18,11 @@
@public_key = 'AAAAB3NzaC1yc2EAAAADAQABAAABAQCvVCQA6JWWCAwjUjXDFUH8wOm15slX+WJOYCPNNrW+xipvHq5zDOCnus0xfl/zjWLVDkIz+1ku0Qapd4Q2a+NyyyH09iRxmclQaZdNoj+l4RRL0TRzeJT+l9FU0e4eUYKylrEgQCkZPFVsgn8Vly9Nh/NRcBMA1BgLMiCMebPu3N3bZIVjUrVp8MB66hqAivA36zVQ4ogykTXO8XKG9Mth7yblLjcVyDq7tecSrvM/RAUkZp0Z6SHihQwdnJwqLTcBMXeV3N2VRF3TZWayOWFgTlr1M3ZL7HD3adjRFzY8lmzbOdL/L6BamwDL9nP6bnHeH5oDnUuOIsJng04BC9Ht'

tests("#create_key('#{@key_name}')").formats(@key_format) do
Fog::Compute[:ibm].create_key(@key_name).body
Fog::Compute[:ibm].create_key(@key_name + '-gen').body
end

tests("#create_key('#{@key_name}', '#{@public_key}')").formats(@key_format) do
Fog::Compute[:ibm].create_key(@key_name, @public_key).body
tests("#create_key('#{@key_name}', '#{@public_key}')") do
returns(true) { Fog::Compute[:ibm].create_key(@key_name, @public_key).body['success'] }
end

tests("#list_keys").formats(@keys_format) do
Expand Down

0 comments on commit 220cb9a

Please sign in to comment.