2010-06-17 19:58:09 -04:00
|
|
|
require File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper')
|
|
|
|
|
|
|
|
if Fog.mocking?
|
2010-10-17 19:06:44 -04:00
|
|
|
shared_examples_for "the expected internet service item" do
|
|
|
|
specify { service.should be_an_instance_of Hash }
|
2010-11-19 12:41:49 -05:00
|
|
|
specify { service.should have(14).attributes }
|
2010-10-17 19:06:44 -04:00
|
|
|
specify { service[:Name].should == mock_service.name }
|
|
|
|
specify { service[:Id].should == mock_service.object_id.to_s }
|
|
|
|
specify { service[:Href].should == mock_service.href }
|
|
|
|
|
|
|
|
specify { service[:PublicIpAddress].should be_an_instance_of Hash }
|
|
|
|
specify { service[:PublicIpAddress].should have(3).attributes }
|
|
|
|
specify { service[:PublicIpAddress][:Name].should == mock_ip.name }
|
|
|
|
specify { service[:PublicIpAddress][:Href].should == mock_ip.href }
|
|
|
|
specify { service[:PublicIpAddress][:Id].should == mock_ip.object_id.to_s }
|
|
|
|
|
|
|
|
specify { service[:Port].should == mock_service.port.to_s }
|
|
|
|
specify { service[:Protocol].should == mock_service.protocol }
|
|
|
|
specify { service[:Enabled].should == mock_service.enabled.to_s }
|
|
|
|
specify { service[:Timeout].should == mock_service.timeout.to_s }
|
|
|
|
specify { service[:Description].should == mock_service.description }
|
|
|
|
specify { service[:RedirectURL].should == (mock_service.redirect_url || "") }
|
|
|
|
specify { service[:Monitor].should == "" }
|
2010-11-19 12:41:49 -05:00
|
|
|
specify { service[:IsBackupService].should == "false" }
|
|
|
|
specify { service[:BackupService].should be_nil }
|
|
|
|
specify { service[:BackupOf].should == "" }
|
|
|
|
end
|
|
|
|
|
|
|
|
shared_examples_for "the expected backup internet service item" do
|
|
|
|
specify { service.should be_an_instance_of Hash }
|
|
|
|
specify { service.should have(14).attributes }
|
|
|
|
specify { service[:Name].should == mock_service.name }
|
|
|
|
specify { service[:Id].should == mock_service.object_id.to_s }
|
|
|
|
specify { service[:Href].should == mock_service.href }
|
|
|
|
|
|
|
|
specify { service[:PublicIpAddress].should be_nil }
|
|
|
|
|
|
|
|
specify { service[:Port].should == mock_service.port.to_s }
|
|
|
|
specify { service[:Protocol].should == mock_service.protocol }
|
|
|
|
specify { service[:Enabled].should == mock_service.enabled.to_s }
|
|
|
|
specify { service[:Timeout].should == mock_service.timeout.to_s }
|
|
|
|
specify { service[:Description].should == mock_service.description }
|
|
|
|
specify { service[:RedirectURL].should == (mock_service.redirect_url || "") }
|
|
|
|
specify { service[:Monitor].should == "" }
|
|
|
|
specify { service[:IsBackupService].should == "true" }
|
|
|
|
specify { service[:BackupService].should be_nil }
|
|
|
|
specify { service[:BackupOf].should == "" }
|
2010-10-17 19:06:44 -04:00
|
|
|
end
|
|
|
|
|
2010-06-17 19:58:09 -04:00
|
|
|
describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do
|
|
|
|
subject { @vcloud }
|
|
|
|
|
|
|
|
it { should respond_to :get_internet_services }
|
|
|
|
|
|
|
|
describe "#get_internet_services" do
|
|
|
|
context "with a valid VDC internet_services_uri" do
|
2010-10-17 19:06:44 -04:00
|
|
|
before { @services = @vcloud.get_internet_services(@mock_vdc_service_collection.href) }
|
2010-06-17 19:58:09 -04:00
|
|
|
subject { @services }
|
|
|
|
|
|
|
|
it_should_behave_like "all responses"
|
|
|
|
it { should have_headers_denoting_a_content_type_of "application/vnd.tmrk.ecloud.internetServicesList+xml" }
|
|
|
|
|
|
|
|
describe "#body" do
|
|
|
|
subject { @services.body }
|
|
|
|
|
|
|
|
it { should have(3).items }
|
|
|
|
|
|
|
|
context "[:InternetService]" do
|
|
|
|
subject { @services.body[:InternetService] }
|
|
|
|
|
2010-11-19 12:41:49 -05:00
|
|
|
it { should have(5).items }
|
2010-06-17 19:58:09 -04:00
|
|
|
|
|
|
|
[0,1,2,3].each do |idx|
|
|
|
|
let(:service) { subject[idx] }
|
2010-11-19 12:41:49 -05:00
|
|
|
let(:mock_service) { @mock_vdc.internet_service_collection.items[idx] }
|
2010-10-17 19:06:44 -04:00
|
|
|
let(:mock_ip) { mock_service._parent._parent }
|
|
|
|
|
|
|
|
it_should_behave_like "the expected internet service item"
|
2010-06-29 13:53:09 -04:00
|
|
|
end
|
2010-11-19 12:41:49 -05:00
|
|
|
|
|
|
|
context "for a backup internet service" do
|
|
|
|
let(:service) { subject[4] }
|
|
|
|
let(:mock_service) { @mock_vdc.internet_service_collection.backup_internet_services.first }
|
|
|
|
|
|
|
|
it_should_behave_like "the expected backup internet service item"
|
|
|
|
end
|
2010-06-29 13:53:09 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "with a valid Public IP uri" do
|
|
|
|
before do
|
2010-10-17 19:06:44 -04:00
|
|
|
@services = @vcloud.get_internet_services(@mock_service_collection.href)
|
2010-06-29 13:53:09 -04:00
|
|
|
end
|
|
|
|
subject { @services }
|
|
|
|
|
|
|
|
it_should_behave_like "all responses"
|
|
|
|
it { should have_headers_denoting_a_content_type_of "application/vnd.tmrk.ecloud.internetServicesList+xml" }
|
|
|
|
|
|
|
|
describe "#body" do
|
|
|
|
subject { @services.body }
|
|
|
|
|
|
|
|
it { should have(3).items }
|
|
|
|
|
|
|
|
context "[:InternetService]" do
|
|
|
|
subject { @services.body[:InternetService] }
|
|
|
|
|
|
|
|
it { should have(2).items }
|
|
|
|
|
|
|
|
[0,1].each do |idx|
|
|
|
|
let(:service) { subject[idx] }
|
2010-10-17 19:06:44 -04:00
|
|
|
let(:mock_service) { @mock_service_collection.items[idx] }
|
2010-06-29 13:53:09 -04:00
|
|
|
let(:mock_ip) { @mock_public_ip }
|
2010-10-17 19:06:44 -04:00
|
|
|
|
|
|
|
it_should_behave_like "the expected internet service item"
|
2010-06-17 19:58:09 -04:00
|
|
|
end
|
2010-05-27 21:27:12 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-06-17 19:58:09 -04:00
|
|
|
context "with a public_ips_uri that doesn't exist" do
|
|
|
|
subject { lambda { @vcloud.get_internet_services(URI.parse('https://www.fakey.c/piv8vc99')) } }
|
2010-05-27 21:27:12 -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-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
|