mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
internet service model returns backup service href
This commit is contained in:
parent
19d1177333
commit
98a2f257aa
5 changed files with 67 additions and 22 deletions
|
@ -714,6 +714,10 @@ module Fog
|
|||
def monitor
|
||||
nil
|
||||
end
|
||||
|
||||
def backup_service
|
||||
self[:backup_service]
|
||||
end
|
||||
end
|
||||
|
||||
class MockPublicIpInternetServiceNodes < Base
|
||||
|
|
|
@ -18,6 +18,7 @@ module Fog
|
|||
attribute :timeout, :aliases => :Timeout
|
||||
attribute :redirect_url, :aliases => :RedirectURL
|
||||
attribute :monitor, :aliases => :Monitor
|
||||
attribute :backup_service_data, :aliases => :BackupService
|
||||
|
||||
def delete
|
||||
requires :href
|
||||
|
@ -58,6 +59,12 @@ module Fog
|
|||
@nodes ||= Fog::Vcloud::Terremark::Ecloud::Nodes.new( :connection => connection, :href => href + "/nodeServices" )
|
||||
end
|
||||
|
||||
def backup_service_href
|
||||
if backup_service_data
|
||||
backup_service_data[:Href]
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def _compose_service_data
|
||||
|
|
|
@ -61,7 +61,13 @@ module Fog
|
|||
xml.RedirectURL service.redirect_url
|
||||
xml.Monitor
|
||||
xml.IsBackupService MockDataClasses::MockBackupInternetService === service
|
||||
xml.BackupService "i:nil" => true
|
||||
if MockDataClasses::MockPublicIpInternetService === service && service.backup_service
|
||||
xml.BackupService do
|
||||
xml.Href service.backup_service.href
|
||||
end
|
||||
else
|
||||
xml.BackupService "i:nil" => true
|
||||
end
|
||||
xml.BackupOf
|
||||
}
|
||||
end
|
||||
|
|
|
@ -8,7 +8,7 @@ if Fog.mocking?
|
|||
subject { Fog::Vcloud::Terremark::Ecloud::InternetService }
|
||||
|
||||
it { should have_identity :href }
|
||||
it { should have_only_these_attributes [:href, :name, :id, :protocol, :port, :enabled, :description, :public_ip, :timeout, :redirect_url, :monitor] }
|
||||
it { should have_only_these_attributes [:href, :name, :id, :protocol, :port, :enabled, :description, :public_ip, :timeout, :redirect_url, :monitor, :backup_service_data] }
|
||||
end
|
||||
|
||||
context "with no uri" do
|
||||
|
@ -31,18 +31,19 @@ if Fog.mocking?
|
|||
|
||||
it { should be_an_instance_of Fog::Vcloud::Terremark::Ecloud::InternetService }
|
||||
|
||||
its(:href) { should == @mock_service.href }
|
||||
its(:identity) { should == @mock_service.href }
|
||||
its(:name) { should == @mock_service.name }
|
||||
its(:id) { should == @mock_service.object_id.to_s }
|
||||
its(:protocol) { should == @mock_service.protocol }
|
||||
its(:port) { should == @mock_service.port.to_s }
|
||||
its(:enabled) { should == @mock_service.enabled.to_s }
|
||||
its(:description) { should == @mock_service.description }
|
||||
its(:public_ip) { should == public_ip }
|
||||
its(:timeout) { should == @mock_service.timeout.to_s }
|
||||
its(:redirect_url) { should == @mock_service.redirect_url }
|
||||
its(:monitor) { should == nil }
|
||||
its(:href) { should == @mock_service.href }
|
||||
its(:identity) { should == @mock_service.href }
|
||||
its(:name) { should == @mock_service.name }
|
||||
its(:id) { should == @mock_service.object_id.to_s }
|
||||
its(:protocol) { should == @mock_service.protocol }
|
||||
its(:port) { should == @mock_service.port.to_s }
|
||||
its(:enabled) { should == @mock_service.enabled.to_s }
|
||||
its(:description) { should == @mock_service.description }
|
||||
its(:public_ip) { should == public_ip }
|
||||
its(:timeout) { should == @mock_service.timeout.to_s }
|
||||
its(:redirect_url) { should == @mock_service.redirect_url }
|
||||
its(:monitor) { should == nil }
|
||||
its(:backup_service_href) { should be_nil }
|
||||
|
||||
specify { composed_public_ip_data[:href].should == public_ip[:Href].to_s }
|
||||
specify { composed_public_ip_data[:name].should == public_ip[:Name] }
|
||||
|
@ -56,6 +57,12 @@ if Fog.mocking?
|
|||
specify { composed_service_data[:enabled].should == subject.enabled.to_s }
|
||||
specify { composed_service_data[:description].should == subject.description }
|
||||
specify { composed_service_data[:timeout].should == subject.timeout.to_s }
|
||||
|
||||
context "with a backup internet service" do
|
||||
before { @mock_service[:backup_service] = @mock_backup_service }
|
||||
|
||||
its(:backup_service_href) { should == @mock_backup_service.href }
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper')
|
||||
|
||||
if Fog.mocking?
|
||||
shared_examples_for "the expected internet service item" do
|
||||
shared_examples_for "a basic internet service" do
|
||||
specify { service.should be_an_instance_of Hash }
|
||||
specify { service.should have(14).attributes }
|
||||
specify { service[:Name].should == mock_service.name }
|
||||
|
@ -22,11 +22,20 @@ if Fog.mocking?
|
|||
specify { service[:RedirectURL].should == (mock_service.redirect_url || "") }
|
||||
specify { service[:Monitor].should == "" }
|
||||
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
|
||||
shared_examples_for "an internet service without a backup internet service set" do
|
||||
specify { service[:BackupService].should be_nil }
|
||||
end
|
||||
|
||||
shared_examples_for "an internet service with a backup internet service set" do
|
||||
specify { service[:BackupService].should be_an_instance_of Hash }
|
||||
specify { service[:BackupService].should include :Href }
|
||||
specify { service[:BackupService][:Href].should == @mock_backup_service.href }
|
||||
end
|
||||
|
||||
shared_examples_for "a backup internet service" do
|
||||
specify { service.should be_an_instance_of Hash }
|
||||
specify { service.should have(14).attributes }
|
||||
specify { service[:Name].should == mock_service.name }
|
||||
|
@ -54,7 +63,11 @@ if Fog.mocking?
|
|||
|
||||
describe "#get_internet_services" do
|
||||
context "with a valid VDC internet_services_uri" do
|
||||
before { @services = @vcloud.get_internet_services(@mock_vdc_service_collection.href) }
|
||||
before do
|
||||
@mock_vdc.internet_service_collection.items[3][:backup_service] = @mock_backup_service
|
||||
@services = @vcloud.get_internet_services(@mock_vdc_service_collection.href)
|
||||
end
|
||||
|
||||
subject { @services }
|
||||
|
||||
it_should_behave_like "all responses"
|
||||
|
@ -70,19 +83,27 @@ if Fog.mocking?
|
|||
|
||||
it { should have(5).items }
|
||||
|
||||
[0,1,2,3].each do |idx|
|
||||
[0,1,2].each do |idx|
|
||||
let(:service) { subject[idx] }
|
||||
let(:mock_service) { @mock_vdc.internet_service_collection.items[idx] }
|
||||
let(:mock_ip) { mock_service._parent._parent }
|
||||
|
||||
it_should_behave_like "the expected internet service item"
|
||||
it_should_behave_like "an internet service without a backup internet service set"
|
||||
end
|
||||
|
||||
context "for a service with a backup internet service" do
|
||||
let(:service) { subject[3] }
|
||||
let(:mock_service) { @mock_vdc.internet_service_collection.items[3] }
|
||||
let(:mock_ip) { mock_service._parent._parent }
|
||||
|
||||
it_should_behave_like "an internet service with a backup internet service set"
|
||||
end
|
||||
|
||||
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"
|
||||
it_should_behave_like "a backup internet service"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -112,7 +133,7 @@ if Fog.mocking?
|
|||
let(:mock_service) { @mock_service_collection.items[idx] }
|
||||
let(:mock_ip) { @mock_public_ip }
|
||||
|
||||
it_should_behave_like "the expected internet service item"
|
||||
it_should_behave_like "an internet service without a backup internet service set"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue