2011-02-17 13:44:46 -05:00
|
|
|
require 'ecloud/spec_helper'
|
2010-06-17 19:58:09 -04:00
|
|
|
|
|
|
|
if Fog.mocking?
|
2011-02-17 13:44:46 -05:00
|
|
|
describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do
|
2010-06-17 19:58:09 -04:00
|
|
|
subject { @vcloud }
|
|
|
|
|
2011-02-15 16:47:14 -05:00
|
|
|
it { should respond_to(:add_internet_service) }
|
2010-06-17 19:58:09 -04:00
|
|
|
|
|
|
|
describe "#add_internet_service" do
|
|
|
|
before do
|
2010-10-17 19:06:44 -04:00
|
|
|
@public_ip = @vcloud.vdcs.first.public_ips.detect {|p| p.name == @mock_public_ip.name }
|
|
|
|
|
2010-06-17 19:58:09 -04:00
|
|
|
@new_service_data = { :name => "Test Service",
|
|
|
|
:protocol => "HTTP",
|
|
|
|
:port => "80",
|
|
|
|
:enabled => "true",
|
|
|
|
:description => "this is a test",
|
|
|
|
:redirect_url => "" }
|
2010-05-27 21:27:12 -04:00
|
|
|
end
|
|
|
|
|
2010-06-17 19:58:09 -04:00
|
|
|
context "with a valid Public IP uri" do
|
2010-10-17 19:06:44 -04:00
|
|
|
subject { @vcloud.add_internet_service(@public_ip.internet_services.href, @new_service_data ) }
|
2010-05-27 21:27:12 -04:00
|
|
|
|
2010-06-17 19:58:09 -04:00
|
|
|
it "has the right number of Internet Services after" do
|
2010-10-17 19:06:44 -04:00
|
|
|
expect { subject }.to change { @vcloud.get_internet_services(@public_ip.internet_services.href).body[:InternetService].size }.by(1)
|
2010-06-17 19:58:09 -04:00
|
|
|
end
|
2010-05-27 21:27:12 -04:00
|
|
|
|
2010-06-17 19:58:09 -04:00
|
|
|
it_should_behave_like "all responses"
|
2010-05-27 21:27:12 -04:00
|
|
|
|
2010-06-17 19:58:09 -04:00
|
|
|
let(:body) { subject.body }
|
2010-05-27 21:27:12 -04:00
|
|
|
|
2011-02-15 16:47:14 -05:00
|
|
|
its(:body) { should be_an_instance_of(Hash) }
|
2010-06-30 00:15:36 -04:00
|
|
|
specify { body[:Href].should_not be_empty }
|
2010-06-29 17:11:35 -04:00
|
|
|
specify { body[:Name].should == @new_service_data[:name] }
|
|
|
|
specify { body[:Protocol].should == @new_service_data[:protocol] }
|
|
|
|
specify { body[:Enabled].should == @new_service_data[:enabled] }
|
|
|
|
specify { body[:Description].should == @new_service_data[:description] }
|
|
|
|
specify { body[:RedirectURL].should == @new_service_data[:redirect_url] }
|
|
|
|
specify { body[:Monitor].should == nil }
|
2010-05-27 21:27:12 -04:00
|
|
|
|
2010-10-17 19:06:44 -04:00
|
|
|
let(:referenced_public_ip) { subject.body[:PublicIpAddress] }
|
2011-02-15 16:47:14 -05:00
|
|
|
specify { referenced_public_ip.should be_an_instance_of(Hash) }
|
2010-10-17 19:06:44 -04:00
|
|
|
specify { referenced_public_ip[:Name].should == @public_ip.name }
|
|
|
|
specify { referenced_public_ip[:Id].should == @public_ip.id }
|
2010-05-27 21:27:12 -04:00
|
|
|
|
2010-06-30 13:48:53 -04:00
|
|
|
it "should update the mock object properly" do
|
|
|
|
subject
|
|
|
|
|
2010-10-17 19:06:44 -04:00
|
|
|
public_ip_internet_service = @vcloud.mock_data.public_ip_internet_service_from_href(body[:Href])
|
|
|
|
|
|
|
|
public_ip_internet_service.object_id.to_s.should == body[:Id]
|
|
|
|
public_ip_internet_service.node_collection.items.should be_empty
|
|
|
|
end
|
2010-06-17 19:58:09 -04:00
|
|
|
end
|
2010-05-27 21:27:12 -04:00
|
|
|
|
2010-06-17 19:58:09 -04:00
|
|
|
context "with a public_ips_uri that doesn't exist" do
|
|
|
|
subject { lambda { @vcloud.add_internet_service(URI.parse('https://www.fakey.c/piv8vc99'), @new_service_data ) } }
|
|
|
|
|
|
|
|
it_should_behave_like "a request for a resource that doesn't exist"
|
|
|
|
end
|
2010-05-27 21:27:12 -04:00
|
|
|
end
|
|
|
|
end
|
2010-06-17 19:58:09 -04:00
|
|
|
else
|
2010-05-27 21:27:12 -04:00
|
|
|
end
|
|
|
|
|