1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[dns] fixes to get all shared tests passing

This commit is contained in:
geemus 2011-01-03 15:39:38 -08:00
parent 969300ed01
commit e4e33af626
16 changed files with 51 additions and 39 deletions

View file

@ -25,8 +25,8 @@ module Fog
end end
def destroy def destroy
requires :identity requires :identity, :zone
connection.domain_resource_delete(identity) connection.domain_resource_delete(zone.id, identity)
true true
end end
@ -46,13 +46,13 @@ module Fog
options[:priority] = priority if priority options[:priority] = priority if priority
options[:target] = ip if ip options[:target] = ip if ip
options[:ttl_sec] = ttl if ttl options[:ttl_sec] = ttl if ttl
data = unless identity response = unless identity
connection.domain_resource_create(zone.id, type) connection.domain_resource_create(zone.identity, type, options)
else else
options[:type] = type if type options[:type] = type if type
connection.domain_resource_update(zone.id, identity, optionts) connection.domain_resource_update(zone.identity, identity, options)
end end
merge_attributes(data.body) merge_attributes(response.body['DATA'])
true true
end end

View file

@ -18,10 +18,11 @@ module Fog
end end
def get(record_id) def get(record_id)
data = connection.domain_resource_list(zone.id, record_id).body['DATA'] if data = connection.domain_resource_list(zone.id, record_id).body['DATA'].first
new(data) new(data)
rescue Excon::Errors::NotFound else
nil nil
end
end end
def new(attributes = {}) def new(attributes = {})

View file

@ -7,7 +7,7 @@ module Fog
class Zone < Fog::Model class Zone < Fog::Model
identity :id, :aliases => ['DOMAINID', 'ResourceID'] identity :id, :aliases => ['DomainID', 'DOMAINID', 'ResourceID']
attribute :description, :aliases => 'DESCRIPTION' attribute :description, :aliases => 'DESCRIPTION'
attribute :domain, :aliases => 'DOMAIN' attribute :domain, :aliases => 'DOMAIN'
@ -66,14 +66,14 @@ module Fog
options[:description] = description if description options[:description] = description if description
options[:soa_email] = email if email options[:soa_email] = email if email
options[:ttl_sec] = ttl if ttl options[:ttl_sec] = ttl if ttl
data = unless identity response = unless identity
connection.domain_create(domain, type, options).body['DATA'] connection.domain_create(domain, type, options)
else else
options[:domain] = domain if domain options[:domain] = domain if domain
options[:type] = type if type options[:type] = type if type
connection.domain_update(identity, options) connection.domain_update(identity, options)
end end
merge_attributes(data) merge_attributes(response.body['DATA'])
true true
end end

View file

@ -15,10 +15,11 @@ module Fog
end end
def get(zone_id) def get(zone_id)
data = connection.domain_list(zone_id).body['DATA'] if data = connection.domain_list(zone_id).body['DATA'].first
new(data) new(data)
rescue Excon::Errors::Forbidden else
nil nil
end
end end
end end

View file

@ -26,7 +26,6 @@ module Fog
# * DATA<~Hash>: # * DATA<~Hash>:
# * 'ResourceID'<~Integer>: ID of the resource record created # * 'ResourceID'<~Integer>: ID of the resource record created
def domain_resource_create(domain_id, type, options = {}) def domain_resource_create(domain_id, type, options = {})
query= {} query= {}
request( request(
:expects => 200, :expects => 200,

View file

@ -46,7 +46,7 @@ module Fog
requires :ip, :name, :type, :zone requires :ip, :name, :type, :zone
options = {} options = {}
options[:active] = active ? 'Y' : 'N' options[:active] = active ? 'Y' : 'N'
options[:aux] = notes if notes options[:aux] = description if description
options[:ttl] = ttl if ttl options[:ttl] = ttl if ttl
data = connection.create_record(type, zone.id, name, ip, options) data = connection.create_record(type, zone.id, name, ip, options)
merge_attributes(data.body) merge_attributes(data.body)

View file

@ -20,7 +20,7 @@ module Fog
def get(record_id) def get(record_id)
data = connection.get_record(record_id).body data = connection.get_record(record_id).body
new(data) new(data)
rescue Excon::Errors::NotFound rescue Excon::Errors::Forbidden
nil nil
end end

View file

@ -36,7 +36,7 @@ module Fog
def records def records
@records ||= begin @records ||= begin
Fog::Zerigo::DNS::Records.new( Fog::Slicehost::DNS::Records.new(
:zone => self, :zone => self,
:connection => connection :connection => connection
) )

View file

@ -38,7 +38,7 @@ module Fog
requires :zone, :type, :ip requires :zone, :type, :ip
options = {} options = {}
options[:hostname] = name if name options[:hostname] = name if name
options[:notes] = notes if notes options[:notes] = description if description
options[:priority] = priority if priority options[:priority] = priority if priority
options[:ttl] = ttl if ttl options[:ttl] = ttl if ttl
data = unless identity data = unless identity

View file

@ -25,7 +25,7 @@ module Fog
def get(record_id) def get(record_id)
data = connection.get_host(record_id).body data = connection.get_host(record_id).body
new(data) new(data)
rescue Excon::Errors::NotFound rescue Fog::Service::NotFound
nil nil
end end

View file

@ -19,7 +19,7 @@ module Fog
zone = new(data) zone = new(data)
zone.records.load(data['hosts']) zone.records.load(data['hosts'])
zone zone
rescue Excon::Errors::Forbidden rescue Fog::Service::NotFound
nil nil
end end

View file

@ -4,7 +4,10 @@ def dns_providers
:mocked => false :mocked => false
}, },
Linode => { Linode => {
:mocked => false :mocked => false,
:zone_attributes => {
:email => 'fog@example.com'
}
}, },
Slicehost => { Slicehost => {
:mocked => false :mocked => false

View file

@ -2,16 +2,20 @@ for provider, config in dns_providers
Shindo.tests("#{provider}::DNS | record", [provider.to_s.downcase]) do Shindo.tests("#{provider}::DNS | record", [provider.to_s.downcase]) do
attributes = { record_attributes = {
:ip => '1.2.3.4', :ip => '1.2.3.4',
:name => 'www.fogrecordtests.com', :name => 'www.fogrecordtests.com',
:type => 'A' :type => 'A'
}.merge!(config[:record_attributes] || {}) }.merge!(config[:record_attributes] || {})
if !Fog.mocking? || config[:mocked] if !Fog.mocking? || config[:mocked]
@zone = provider[:dns].zones.create(:domain => 'fogrecordtests.com') zone_attributes = {
:domain => 'fogrecordtests.com'
}.merge(config[:zone_attributes] || {})
model_tests(@zone.records, attributes, config[:mocked]) @zone = provider[:dns].zones.create(zone_attributes)
model_tests(@zone.records, record_attributes, config[:mocked])
@zone.destroy @zone.destroy
end end

View file

@ -2,16 +2,20 @@ for provider, config in dns_providers
Shindo.tests("#{provider}::DNS | records", [provider.to_s.downcase]) do Shindo.tests("#{provider}::DNS | records", [provider.to_s.downcase]) do
attributes = { record_attributes = {
:ip => '1.2.3.4', :ip => '1.2.3.4',
:name => 'www.fogrecordstests.com', :name => 'www.fogrecordstests.com',
:type => 'A' :type => 'A'
}.merge!(config[:records_attributes] || {}) }.merge!(config[:record_attributes] || {})
if !Fog.mocking? || configa[:mocked] if !Fog.mocking? || config[:mocked]
@zone = provider[:dns].zones.create(:domain => 'fogrecordstests.com') zone_attributes = {
:domain => 'fogrecordstests.com'
}.merge(config[:zone_attributes] || {})
collection_tests(@zone.records, attributes, config[:mocked]) @zone = provider[:dns].zones.create(zone_attributes)
collection_tests(@zone.records, record_attributes, config[:mocked])
@zone.destroy @zone.destroy
end end

View file

@ -2,11 +2,11 @@ for provider, config in dns_providers
Shindo.tests("#{provider}::DNS | zone", [provider.to_s.downcase]) do Shindo.tests("#{provider}::DNS | zone", [provider.to_s.downcase]) do
attributes = { zone_attributes = {
:domain => 'fogzonetests.com' :domain => 'fogzonetests.com'
}.merge!(config[:zone_attributes] || {}) }.merge!(config[:zone_attributes] || {})
model_tests(provider[:dns].zones, attributes, config[:mocked]) model_tests(provider[:dns].zones, zone_attributes, config[:mocked])
end end

View file

@ -2,11 +2,11 @@ for provider, config in dns_providers
Shindo.tests("#{provider}::DNS | zones", [provider.to_s.downcase]) do Shindo.tests("#{provider}::DNS | zones", [provider.to_s.downcase]) do
attributes = { zone_attributes = {
:domain => 'fogzonestests.com' :domain => 'fogzonestests.com'
}.merge!(config[:zones_attributes] || {}) }.merge!(config[:zone_attributes] || {})
collection_tests(provider[:dns].zones, attributes, config[:mocked]) collection_tests(provider[:dns].zones, zone_attributes, config[:mocked])
end end