2011-12-02 13:27:44 -05:00
|
|
|
Shindo.tests('Fog::Compute[:ibm] | key requests', ['ibm']) do
|
2012-02-13 10:51:03 -05:00
|
|
|
|
2011-12-02 13:27:44 -05:00
|
|
|
@key_format = {
|
|
|
|
'default' => Fog::Boolean,
|
|
|
|
'instanceIds' => Array,
|
|
|
|
'keyMaterial' => String,
|
|
|
|
'keyName' => String,
|
|
|
|
'lastModifiedTime' => Integer
|
|
|
|
}
|
2012-02-13 10:51:03 -05:00
|
|
|
|
2011-12-02 13:27:44 -05:00
|
|
|
@keys_format = {
|
|
|
|
'keys' => [ @key_format ]
|
|
|
|
}
|
|
|
|
|
|
|
|
tests('success') do
|
2012-02-13 10:51:03 -05:00
|
|
|
|
2012-02-20 13:14:02 -05:00
|
|
|
@key_name = 'fog-test-key' + Time.now.to_i.to_s(32)
|
2011-12-02 13:27:44 -05:00
|
|
|
@public_key = <<-EOF
|
|
|
|
-----BEGIN RSA PUBLIC KEY-----
|
|
|
|
MIGJAoGBAL2nePLzDy1Z2Y64/Dz5QMmJN4S9xc6D8TbiKVe5YHeuNt3fCSYDJl9x
|
|
|
|
d/V5r2mUo4nGrEhum1ooX0rdk5CPugVxd3Tgovj87y3NRw9zAdeCB8omfrRwG4yu
|
|
|
|
x1z+ejqX1BSKYy+KvOT2RKiuLdIiodLsps5epovQFZmlymTIg/ODAgMBAAE=
|
2012-02-13 10:51:03 -05:00
|
|
|
-----END RSA PUBLIC KEY-----
|
2011-12-02 13:27:44 -05:00
|
|
|
EOF
|
|
|
|
@public_key.gsub!(/^\s{4}/, '')
|
2012-02-13 10:51:03 -05:00
|
|
|
|
2011-12-02 13:27:44 -05:00
|
|
|
tests("#create_key('#{@key_name}')").formats(@key_format) do
|
|
|
|
Fog::Compute[:ibm].create_key(@key_name).body
|
|
|
|
end
|
2012-02-13 10:51:03 -05:00
|
|
|
|
2012-02-13 10:03:00 -05:00
|
|
|
tests("#create_key('#{@key_name}', '#{@public_key}')").formats(@key_format) do
|
|
|
|
Fog::Compute[:ibm].create_key(@key_name, @public_key).body
|
|
|
|
end
|
|
|
|
|
2011-12-02 13:27:44 -05:00
|
|
|
tests("#list_keys").formats(@keys_format) do
|
|
|
|
Fog::Compute[:ibm].list_keys.body
|
|
|
|
end
|
2012-02-13 10:51:03 -05:00
|
|
|
|
2011-12-02 13:27:44 -05:00
|
|
|
tests("#get_key('#{@key_name}')").formats(@key_format) do
|
|
|
|
Fog::Compute[:ibm].get_key(@key_name).body
|
|
|
|
end
|
2012-02-13 10:51:03 -05:00
|
|
|
|
|
|
|
tests("#set_default_key('#{@key_name}')") do
|
2012-02-13 10:34:48 -05:00
|
|
|
returns(true) { Fog::Compute[:ibm].modify_key(@key_name, 'default' => true).body['success'] }
|
2012-02-13 10:51:03 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
tests("#update_key('#{@key_name}', 'publicKey' => '#{@public_key}')") do
|
|
|
|
returns(true) { Fog::Compute[:ibm].modify_key(@key_name, 'publicKey' => @public_key).body['success'] }
|
|
|
|
end
|
|
|
|
|
2011-12-02 13:27:44 -05:00
|
|
|
tests("#delete_key('#{@key_name}')") do
|
|
|
|
returns(true) { Fog::Compute[:ibm].delete_key(@key_name).body['success'] }
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2012-02-13 10:51:03 -05:00
|
|
|
end
|