2011-01-10 01:12:48 -05:00
|
|
|
require 'spec_helper'
|
2009-09-28 23:00:49 -04:00
|
|
|
|
2010-09-09 20:50:38 -04:00
|
|
|
describe 'Fog::AWS::Compute::SecurityGroup' do
|
2009-09-28 23:00:49 -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
|
|
|
security_group = AWS[:compute].security_groups.new(
|
2009-10-06 23:35:46 -04:00
|
|
|
'groupDescription' => 'description',
|
|
|
|
'groupName' => 'name',
|
|
|
|
'ipPermissions' => 'permissions',
|
|
|
|
'ownerId' => 'owner'
|
|
|
|
)
|
2009-12-05 17:53:42 -05:00
|
|
|
security_group.description.should == 'description'
|
|
|
|
security_group.name.should == 'name'
|
2009-10-06 23:35:46 -04:00
|
|
|
security_group.ip_permissions.should == 'permissions'
|
|
|
|
security_group.owner_id.should == 'owner'
|
|
|
|
end
|
2009-09-28 23:00:49 -04:00
|
|
|
|
|
|
|
end
|
|
|
|
|
2009-10-24 01:23:55 -04:00
|
|
|
describe "#collection" do
|
2009-09-28 23:00:49 -04:00
|
|
|
|
2010-09-09 20:50:38 -04:00
|
|
|
it "should return a Fog::AWS::Compute::SecurityGroups" do
|
|
|
|
AWS[:compute].security_groups.new.collection.should be_a(Fog::AWS::Compute::SecurityGroups)
|
2009-09-28 23:00:49 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should be the security_groups the keypair is related to" do
|
2010-09-09 20:50:38 -04:00
|
|
|
security_groups = AWS[:compute].security_groups
|
2009-10-24 01:23:55 -04:00
|
|
|
security_groups.new.collection.should == security_groups
|
2009-09-28 23:00:49 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "#destroy" do
|
|
|
|
|
|
|
|
it "should return true if the security_group is deleted" do
|
2010-09-09 20:50:38 -04:00
|
|
|
address = AWS[:compute].security_groups.create(:description => 'groupdescription', :name => 'keyname')
|
2009-09-28 23:00:49 -04:00
|
|
|
address.destroy.should be_true
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "#reload" do
|
|
|
|
|
|
|
|
before(:each) do
|
2010-09-09 20:50:38 -04:00
|
|
|
@security_group = AWS[:compute].security_groups.create(:description => 'groupdescription', :name => 'keyname')
|
2009-09-28 23:00:49 -04:00
|
|
|
@reloaded = @security_group.reload
|
|
|
|
end
|
|
|
|
|
|
|
|
after(:each) do
|
|
|
|
@security_group.destroy
|
|
|
|
end
|
|
|
|
|
2010-09-09 20:50:38 -04:00
|
|
|
it "should return a Fog::AWS::Compute::SecurityGroup" do
|
|
|
|
@reloaded.should be_a(Fog::AWS::Compute::SecurityGroup)
|
2009-09-28 23:00:49 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should reset attributes to remote state" do
|
|
|
|
@security_group.attributes.should == @reloaded.attributes
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "#save" do
|
|
|
|
|
|
|
|
before(:each) do
|
2010-09-09 20:50:38 -04:00
|
|
|
@security_group = AWS[:compute].security_groups.new(:description => 'groupdescription', :name => 'keyname')
|
2009-09-28 23:00:49 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should return true when it succeeds" do
|
|
|
|
@security_group.save.should be_true
|
|
|
|
@security_group.destroy
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should not exist in security_groups before save" do
|
2010-09-09 20:50:38 -04:00
|
|
|
AWS[:compute].security_groups.get(@security_group.name).should be_nil
|
2009-09-28 23:00:49 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should exist in buckets after save" do
|
|
|
|
@security_group.save
|
2010-09-09 20:50:38 -04:00
|
|
|
AWS[:compute].security_groups.get(@security_group.name).should_not be_nil
|
2009-09-28 23:00:49 -04:00
|
|
|
@security_group.destroy
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|