mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
57 lines
1.7 KiB
Ruby
57 lines
1.7 KiB
Ruby
Shindo.tests('Fog::Compute[:ibm] | key requests', ['ibm']) do
|
|
|
|
@key_format = {
|
|
'default' => Fog::Boolean,
|
|
'instanceIds' => Array,
|
|
'keyMaterial' => String,
|
|
'keyName' => String,
|
|
'lastModifiedTime' => Integer
|
|
}
|
|
|
|
@keys_format = {
|
|
'keys' => [ @key_format ]
|
|
}
|
|
|
|
tests('success') do
|
|
|
|
@key_name = "fog test key"
|
|
@public_key = <<-EOF
|
|
-----BEGIN RSA PUBLIC KEY-----
|
|
MIGJAoGBAL2nePLzDy1Z2Y64/Dz5QMmJN4S9xc6D8TbiKVe5YHeuNt3fCSYDJl9x
|
|
d/V5r2mUo4nGrEhum1ooX0rdk5CPugVxd3Tgovj87y3NRw9zAdeCB8omfrRwG4yu
|
|
x1z+ejqX1BSKYy+KvOT2RKiuLdIiodLsps5epovQFZmlymTIg/ODAgMBAAE=
|
|
-----END RSA PUBLIC KEY-----
|
|
EOF
|
|
@public_key.gsub!(/^\s{4}/, '')
|
|
|
|
tests("#create_key('#{@key_name}')").formats(@key_format) do
|
|
Fog::Compute[:ibm].create_key(@key_name).body
|
|
end
|
|
|
|
tests("#create_key('#{@key_name}', '#{@public_key}')").formats(@key_format) do
|
|
Fog::Compute[:ibm].create_key(@key_name, @public_key).body
|
|
end
|
|
|
|
tests("#list_keys").formats(@keys_format) do
|
|
Fog::Compute[:ibm].list_keys.body
|
|
end
|
|
|
|
tests("#get_key('#{@key_name}')").formats(@key_format) do
|
|
Fog::Compute[:ibm].get_key(@key_name).body
|
|
end
|
|
|
|
tests("#set_default_key('#{@key_name}')") do
|
|
returns(@key_name) { Fog::Compute[:ibm].modify_key(@key_name, 'default' => true).body }
|
|
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
|
|
|
|
tests("#delete_key('#{@key_name}')") do
|
|
returns(true) { Fog::Compute[:ibm].delete_key(@key_name).body['success'] }
|
|
end
|
|
|
|
end
|
|
|
|
end
|