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(:configure_internet_service) }
|
2010-06-17 19:58:09 -04:00
|
|
|
|
|
|
|
describe "#configure_internet_service" do
|
|
|
|
before do
|
2010-10-17 19:06:44 -04:00
|
|
|
@original_service = @vcloud.get_internet_services(@mock_public_ip.internet_service_collection.href).body[:InternetService].first
|
|
|
|
@ip_data = { :id => @mock_public_ip.object_id, :name => @mock_public_ip.name, :href => @mock_public_ip.href.to_s }
|
2010-06-17 19:58:09 -04:00
|
|
|
@service_data = { :name => @original_service[:Name], :protocol => @original_service[:Protocol],
|
|
|
|
:port => @original_service[:Port], :description => @original_service[:Description],
|
|
|
|
:enabled => @original_service[:Enabled], :redirect_url => @original_service[:RedirectURL],
|
|
|
|
:id => @original_service[:Id], :href => @original_service[:Href], :timeout => @original_service[:Timeout] }
|
|
|
|
end
|
2010-06-07 12:18:06 -04:00
|
|
|
|
2010-06-17 19:58:09 -04:00
|
|
|
context "with a valid Internet Service uri and valid data" do
|
|
|
|
subject { @vcloud.configure_internet_service(@original_service[:Href], @service_data, @ip_data) }
|
2010-06-07 12:18:06 -04:00
|
|
|
|
2010-06-17 19:58:09 -04:00
|
|
|
it_should_behave_like "all responses"
|
2010-06-07 12:18:06 -04:00
|
|
|
|
2010-06-17 19:58:09 -04:00
|
|
|
context "with some changed data" do
|
|
|
|
before do
|
|
|
|
@service_data[:description] = "TEST BOOM"
|
2010-06-29 13:53:09 -04:00
|
|
|
@service_data[:redirect_url] = "http://google.com"
|
|
|
|
@service_data[:port] = "80"
|
2010-11-22 10:24:21 -05:00
|
|
|
@service_data[:backup_service_uri] = @mock_backup_service.href
|
2010-06-17 19:58:09 -04:00
|
|
|
end
|
2010-10-17 19:06:44 -04:00
|
|
|
|
2010-06-17 19:58:09 -04:00
|
|
|
it "should change data" do
|
2010-06-29 13:53:09 -04:00
|
|
|
@original_service[:Description].should == @mock_service[:description]
|
|
|
|
@original_service[:RedirectURL].should == @mock_service[:redirect_url]
|
2010-10-17 19:06:44 -04:00
|
|
|
@original_service[:Port].should == @mock_service[:port].to_s
|
2010-06-17 19:58:09 -04:00
|
|
|
result = subject
|
2010-06-29 13:53:09 -04:00
|
|
|
result.body[:Description].should == @service_data[:description]
|
|
|
|
result.body[:RedirectURL].should == @service_data[:redirect_url]
|
|
|
|
result.body[:Port].should == @service_data[:port]
|
2010-11-22 10:24:21 -05:00
|
|
|
result.body[:BackupService][:Href].should == @service_data[:backup_service_uri]
|
2010-06-29 13:53:09 -04:00
|
|
|
|
2010-10-17 19:06:44 -04:00
|
|
|
new_result = @vcloud.get_internet_services(@mock_public_ip.internet_service_collection.href).body[:InternetService].first
|
2010-06-29 13:53:09 -04:00
|
|
|
|
|
|
|
new_result[:Description].should == @service_data[:description]
|
|
|
|
new_result[:RedirectURL].should == @service_data[:redirect_url]
|
|
|
|
new_result[:Port].should == @service_data[:port]
|
2010-11-22 10:24:21 -05:00
|
|
|
new_result[:BackupService][:Href].should == @service_data[:backup_service_uri]
|
2010-06-17 19:58:09 -04:00
|
|
|
end
|
2010-06-07 12:18:06 -04:00
|
|
|
end
|
2010-06-17 19:58:09 -04:00
|
|
|
end
|
2010-06-07 12:18:06 -04:00
|
|
|
|
2010-06-17 19:58:09 -04:00
|
|
|
context "with an internet_services_uri that doesn't exist" do
|
|
|
|
subject { lambda { @vcloud.configure_internet_service(URI.parse('https://www.fakey.c/piv8vc99'), @service_data, @ip_data ) } }
|
2010-06-07 12:18:06 -04:00
|
|
|
|
2010-06-17 19:58:09 -04:00
|
|
|
it_should_behave_like "a request for a resource that doesn't exist"
|
|
|
|
end
|
2010-06-07 12:18:06 -04:00
|
|
|
end
|
|
|
|
end
|
2010-06-17 19:58:09 -04:00
|
|
|
else
|
2010-06-07 12:18:06 -04:00
|
|
|
end
|
|
|
|
|