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:
parent
969300ed01
commit
e4e33af626
16 changed files with 51 additions and 39 deletions
|
@ -25,8 +25,8 @@ module Fog
|
|||
end
|
||||
|
||||
def destroy
|
||||
requires :identity
|
||||
connection.domain_resource_delete(identity)
|
||||
requires :identity, :zone
|
||||
connection.domain_resource_delete(zone.id, identity)
|
||||
true
|
||||
end
|
||||
|
||||
|
@ -46,13 +46,13 @@ module Fog
|
|||
options[:priority] = priority if priority
|
||||
options[:target] = ip if ip
|
||||
options[:ttl_sec] = ttl if ttl
|
||||
data = unless identity
|
||||
connection.domain_resource_create(zone.id, type)
|
||||
response = unless identity
|
||||
connection.domain_resource_create(zone.identity, type, options)
|
||||
else
|
||||
options[:type] = type if type
|
||||
connection.domain_resource_update(zone.id, identity, optionts)
|
||||
connection.domain_resource_update(zone.identity, identity, options)
|
||||
end
|
||||
merge_attributes(data.body)
|
||||
merge_attributes(response.body['DATA'])
|
||||
true
|
||||
end
|
||||
|
||||
|
|
|
@ -18,10 +18,11 @@ module Fog
|
|||
end
|
||||
|
||||
def get(record_id)
|
||||
data = connection.domain_resource_list(zone.id, record_id).body['DATA']
|
||||
new(data)
|
||||
rescue Excon::Errors::NotFound
|
||||
nil
|
||||
if data = connection.domain_resource_list(zone.id, record_id).body['DATA'].first
|
||||
new(data)
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
def new(attributes = {})
|
||||
|
|
|
@ -7,7 +7,7 @@ module Fog
|
|||
|
||||
class Zone < Fog::Model
|
||||
|
||||
identity :id, :aliases => ['DOMAINID', 'ResourceID']
|
||||
identity :id, :aliases => ['DomainID', 'DOMAINID', 'ResourceID']
|
||||
|
||||
attribute :description, :aliases => 'DESCRIPTION'
|
||||
attribute :domain, :aliases => 'DOMAIN'
|
||||
|
@ -66,14 +66,14 @@ module Fog
|
|||
options[:description] = description if description
|
||||
options[:soa_email] = email if email
|
||||
options[:ttl_sec] = ttl if ttl
|
||||
data = unless identity
|
||||
connection.domain_create(domain, type, options).body['DATA']
|
||||
response = unless identity
|
||||
connection.domain_create(domain, type, options)
|
||||
else
|
||||
options[:domain] = domain if domain
|
||||
options[:type] = type if type
|
||||
connection.domain_update(identity, options)
|
||||
end
|
||||
merge_attributes(data)
|
||||
merge_attributes(response.body['DATA'])
|
||||
true
|
||||
end
|
||||
|
||||
|
|
|
@ -15,10 +15,11 @@ module Fog
|
|||
end
|
||||
|
||||
def get(zone_id)
|
||||
data = connection.domain_list(zone_id).body['DATA']
|
||||
new(data)
|
||||
rescue Excon::Errors::Forbidden
|
||||
nil
|
||||
if data = connection.domain_list(zone_id).body['DATA'].first
|
||||
new(data)
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -26,7 +26,6 @@ module Fog
|
|||
# * DATA<~Hash>:
|
||||
# * 'ResourceID'<~Integer>: ID of the resource record created
|
||||
def domain_resource_create(domain_id, type, options = {})
|
||||
|
||||
query= {}
|
||||
request(
|
||||
:expects => 200,
|
||||
|
|
|
@ -46,7 +46,7 @@ module Fog
|
|||
requires :ip, :name, :type, :zone
|
||||
options = {}
|
||||
options[:active] = active ? 'Y' : 'N'
|
||||
options[:aux] = notes if notes
|
||||
options[:aux] = description if description
|
||||
options[:ttl] = ttl if ttl
|
||||
data = connection.create_record(type, zone.id, name, ip, options)
|
||||
merge_attributes(data.body)
|
||||
|
|
|
@ -20,7 +20,7 @@ module Fog
|
|||
def get(record_id)
|
||||
data = connection.get_record(record_id).body
|
||||
new(data)
|
||||
rescue Excon::Errors::NotFound
|
||||
rescue Excon::Errors::Forbidden
|
||||
nil
|
||||
end
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ module Fog
|
|||
|
||||
def records
|
||||
@records ||= begin
|
||||
Fog::Zerigo::DNS::Records.new(
|
||||
Fog::Slicehost::DNS::Records.new(
|
||||
:zone => self,
|
||||
:connection => connection
|
||||
)
|
||||
|
|
|
@ -38,7 +38,7 @@ module Fog
|
|||
requires :zone, :type, :ip
|
||||
options = {}
|
||||
options[:hostname] = name if name
|
||||
options[:notes] = notes if notes
|
||||
options[:notes] = description if description
|
||||
options[:priority] = priority if priority
|
||||
options[:ttl] = ttl if ttl
|
||||
data = unless identity
|
||||
|
|
|
@ -25,7 +25,7 @@ module Fog
|
|||
def get(record_id)
|
||||
data = connection.get_host(record_id).body
|
||||
new(data)
|
||||
rescue Excon::Errors::NotFound
|
||||
rescue Fog::Service::NotFound
|
||||
nil
|
||||
end
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ module Fog
|
|||
zone = new(data)
|
||||
zone.records.load(data['hosts'])
|
||||
zone
|
||||
rescue Excon::Errors::Forbidden
|
||||
rescue Fog::Service::NotFound
|
||||
nil
|
||||
end
|
||||
|
||||
|
|
|
@ -4,7 +4,10 @@ def dns_providers
|
|||
:mocked => false
|
||||
},
|
||||
Linode => {
|
||||
:mocked => false
|
||||
:mocked => false,
|
||||
:zone_attributes => {
|
||||
:email => 'fog@example.com'
|
||||
}
|
||||
},
|
||||
Slicehost => {
|
||||
:mocked => false
|
||||
|
|
|
@ -2,16 +2,20 @@ for provider, config in dns_providers
|
|||
|
||||
Shindo.tests("#{provider}::DNS | record", [provider.to_s.downcase]) do
|
||||
|
||||
attributes = {
|
||||
record_attributes = {
|
||||
:ip => '1.2.3.4',
|
||||
:name => 'www.fogrecordtests.com',
|
||||
:type => 'A'
|
||||
}.merge!(config[:record_attributes] || {})
|
||||
|
||||
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
|
||||
end
|
||||
|
|
|
@ -2,16 +2,20 @@ for provider, config in dns_providers
|
|||
|
||||
Shindo.tests("#{provider}::DNS | records", [provider.to_s.downcase]) do
|
||||
|
||||
attributes = {
|
||||
record_attributes = {
|
||||
:ip => '1.2.3.4',
|
||||
:name => 'www.fogrecordstests.com',
|
||||
:type => 'A'
|
||||
}.merge!(config[:records_attributes] || {})
|
||||
}.merge!(config[:record_attributes] || {})
|
||||
|
||||
if !Fog.mocking? || configa[:mocked]
|
||||
@zone = provider[:dns].zones.create(:domain => 'fogrecordstests.com')
|
||||
if !Fog.mocking? || config[:mocked]
|
||||
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
|
||||
end
|
||||
|
|
|
@ -2,11 +2,11 @@ for provider, config in dns_providers
|
|||
|
||||
Shindo.tests("#{provider}::DNS | zone", [provider.to_s.downcase]) do
|
||||
|
||||
attributes = {
|
||||
zone_attributes = {
|
||||
:domain => 'fogzonetests.com'
|
||||
}.merge!(config[:zone_attributes] || {})
|
||||
|
||||
model_tests(provider[:dns].zones, attributes, config[:mocked])
|
||||
model_tests(provider[:dns].zones, zone_attributes, config[:mocked])
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -2,11 +2,11 @@ for provider, config in dns_providers
|
|||
|
||||
Shindo.tests("#{provider}::DNS | zones", [provider.to_s.downcase]) do
|
||||
|
||||
attributes = {
|
||||
zone_attributes = {
|
||||
: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
|
||||
|
||||
|
|
Loading…
Reference in a new issue