2011-01-10 01:12:48 -05:00
|
|
|
require 'spec_helper'
|
2009-09-28 00:31:15 -04:00
|
|
|
|
2010-09-09 20:50:38 -04:00
|
|
|
describe 'Fog::AWS::Compute::KeyPair' do
|
2009-09-28 00:31:15 -04:00
|
|
|
|
|
|
|
describe "#initialize" do
|
|
|
|
|
2009-10-06 23:35:46 -04:00
|
|
|
it "should remap attributes from parser" do
|
2010-09-09 20:50:38 -04:00
|
|
|
key_pair = AWS[:compute].key_pairs.new(
|
2009-10-06 23:35:46 -04:00
|
|
|
'keyFingerprint' => 'fingerprint',
|
|
|
|
'keyMaterial' => 'material',
|
|
|
|
'keyName' => 'name'
|
|
|
|
)
|
|
|
|
key_pair.fingerprint.should == 'fingerprint'
|
2010-09-23 13:48:52 -04:00
|
|
|
key_pair.private_key.should == 'material'
|
2009-10-06 23:35:46 -04:00
|
|
|
key_pair.name.should == 'name'
|
|
|
|
end
|
2009-09-28 00:31:15 -04:00
|
|
|
|
|
|
|
end
|
|
|
|
|
2009-10-24 01:23:55 -04:00
|
|
|
describe "#collection" do
|
2009-09-28 00:31:15 -04:00
|
|
|
|
2010-09-09 20:50:38 -04:00
|
|
|
it "should return a Fog::AWS::Compute::KeyPairs" do
|
|
|
|
AWS[:compute].key_pairs.new.collection.should be_a(Fog::AWS::Compute::KeyPairs)
|
2009-09-28 00:31:15 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should be the key_pairs the keypair is related to" do
|
2010-09-09 20:50:38 -04:00
|
|
|
key_pairs = AWS[:compute].key_pairs
|
2009-10-24 01:23:55 -04:00
|
|
|
key_pairs.new.collection.should == key_pairs
|
2009-09-28 00:31:15 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "#destroy" do
|
|
|
|
|
|
|
|
it "should return true if the key_pair is deleted" do
|
2010-09-09 20:50:38 -04:00
|
|
|
address = AWS[:compute].key_pairs.create(:name => 'keyname')
|
2009-09-28 00:31:15 -04:00
|
|
|
address.destroy.should be_true
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "#reload" do
|
|
|
|
|
|
|
|
before(:each) do
|
2010-09-09 20:50:38 -04:00
|
|
|
@key_pair = AWS[:compute].key_pairs.create(:name => 'keyname')
|
2009-09-28 00:31:15 -04:00
|
|
|
@reloaded = @key_pair.reload
|
|
|
|
end
|
|
|
|
|
|
|
|
after(:each) do
|
|
|
|
@key_pair.destroy
|
|
|
|
end
|
|
|
|
|
2010-09-09 20:50:38 -04:00
|
|
|
it "should return a Fog::AWS::Compute::KeyPair" do
|
|
|
|
@reloaded.should be_a(Fog::AWS::Compute::KeyPair)
|
2009-09-28 00:31:15 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should reset attributes to remote state" do
|
|
|
|
@key_pair.attributes.should == @reloaded.attributes
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "#save" do
|
|
|
|
|
|
|
|
before(:each) do
|
2010-09-09 20:50:38 -04:00
|
|
|
@key_pair = AWS[:compute].key_pairs.new(:name => 'keyname')
|
2009-09-28 00:31:15 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should return true when it succeeds" do
|
|
|
|
@key_pair.save.should be_true
|
|
|
|
@key_pair.destroy
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should not exist in key_pairs before save" do
|
2010-09-09 20:50:38 -04:00
|
|
|
AWS[:compute].key_pairs.get(@key_pair.name).should be_nil
|
2009-09-28 00:31:15 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should exist in buckets after save" do
|
|
|
|
@key_pair.save
|
2010-09-09 20:50:38 -04:00
|
|
|
AWS[:compute].key_pairs.get(@key_pair.name).should_not be_nil
|
2009-09-28 00:31:15 -04:00
|
|
|
@key_pair.destroy
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|