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

Merge pull request #642 from bensie/route53-elb

[aws|dns] Add support for aliasing records to Elastic Load Balancers
This commit is contained in:
Wesley Beary 2012-02-15 12:50:31 -08:00
commit 0bf1bf2677
10 changed files with 236 additions and 199 deletions

View file

@ -89,7 +89,7 @@ module Fog
@persistent = options[:persistent] || true
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@version = options[:version] || '2010-10-01'
@version = options[:version] || '2011-05-05'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
end
@ -104,7 +104,7 @@ module Fog
params[:headers] ||= {}
params[:headers]['Date'] = Fog::Time.now.to_date_header
params[:headers]['X-Amzn-Authorization'] = "AWS3-HTTPS AWSAccessKeyId=#{@aws_access_key_id},Algorithm=HmacSHA1,Signature=#{signature(params)}"
params[:path] = "/#{@version}/#{params[:path]}"
params[:path] = "/#{@version}/#{params[:path]}"
@connection.request(params, &block)
end

View file

@ -9,11 +9,12 @@ module Fog
@resource_record = []
@resource_record_set = {}
@resource_record_set['ResourceRecords'] = []
@alias_target = {}
@response = {}
@response['ResourceRecordSets'] = []
@section = :resource_record_set
end
def end_element(name)
if @section == :resource_record_set
case name
@ -21,6 +22,11 @@ module Fog
@resource_record_set[name] = value
when 'Value'
@resource_record_set['ResourceRecords'] << value
when 'AliasTarget'
@resource_record_set[name] = @alias_target
@alias_target = {}
when 'HostedZoneId', 'DNSName'
@alias_target[name] = value
when 'ResourceRecordSet'
@response['ResourceRecordSets'] << @resource_record_set
@resource_record_set = {}
@ -29,12 +35,12 @@ module Fog
@section = :main
end
elsif @section == :main
case name
when 'MaxItems'
@response[name]= value.to_i
when 'IsTruncated', 'NextRecordName', 'NextRecordType'
@response[name]= value
end
case name
when 'MaxItems'
@response[name] = value.to_i
when 'IsTruncated', 'NextRecordName', 'NextRecordType'
@response[name] = value
end
end
end

View file

@ -13,11 +13,14 @@ module Fog
# * comment<~String> - Any comments you want to include about the change.
# * change_batch<~Array> - The information for a change request
# * changes<~Hash> -
# * action<~String> - 'CREATE' or 'DELETE'
# * action<~String> - 'CREATE' or 'DELETE'
# * name<~String> - This must be a fully-specified name, ending with a final period
# * type<~String> - A | AAAA | CNAME | MX | NS | PTR | SOA | SPF | SRV | TXT
# * ttl<~Integer> -
# * resource_record<~String>
# * type<~String> - A | AAAA | CNAME | MX | NS | PTR | SOA | SPF | SRV | TXT
# * ttl<~Integer> - Time-to-live value - omit if using an alias record
# * resource_record<~String> - Omit if using an alias record
# * alias_target<~Hash> - Information about the domain to which you are redirecting traffic (Alias record sets only)
# * dns_name<~String> - The Elastic Load Balancing domain to which you want to reroute traffic
# * hosted_zone_id<~String> - The ID of the hosted zone that contains the Elastic Load Balancing domain to which you want to reroute traffic
#
# ==== Returns
# * response<~Excon::Response>:
@ -29,43 +32,55 @@ module Fog
# * status<~Integer> - 201 when successful
def change_resource_record_sets(zone_id, change_batch, options = {})
# AWS methods return zone_ids that looks like '/hostedzone/id'. Let the caller either use
# AWS methods return zone_ids that looks like '/hostedzone/id'. Let the caller either use
# that form or just the actual id (which is what this request needs)
zone_id = zone_id.sub('/hostedzone/', '')
optional_tags = ''
options.each { |option, value|
options.each do |option, value|
case option
when :comment
optional_tags+= "<Comment>#{value}</Comment>"
optional_tags += "<Comment>#{value}</Comment>"
end
}
#build XML
if change_batch.count > 0
changes= "<ChangeBatch>#{optional_tags}<Changes>"
change_batch.each { |change_item|
action_tag = %Q{<Action>#{change_item[:action]}</Action>}
name_tag = %Q{<Name>#{change_item[:name]}</Name>}
type_tag = %Q{<Type>#{change_item[:type]}</Type>}
ttl_tag = %Q{<TTL>#{change_item[:ttl]}</TTL>}
resource_records= change_item[:resource_records]
resource_record_tags = ''
resource_records.each { |record|
resource_record_tags+= %Q{<ResourceRecord><Value>#{record}</Value></ResourceRecord>}
}
resource_tag= %Q{<ResourceRecords>#{resource_record_tags}</ResourceRecords>}
change_tags = %Q{<Change>#{action_tag}<ResourceRecordSet>#{name_tag}#{type_tag}#{ttl_tag}#{resource_tag}</ResourceRecordSet></Change>}
changes+= change_tags
}
changes+= '</Changes></ChangeBatch>'
end
body = %Q{<?xml version="1.0" encoding="UTF-8"?><ChangeResourceRecordSetsRequest xmlns="https://route53.amazonaws.com/doc/2010-10-01/">#{changes}</ChangeResourceRecordSetsRequest>}
#build XML
if change_batch.count > 0
changes = "<ChangeBatch>#{optional_tags}<Changes>"
change_batch.each do |change_item|
action_tag = %Q{<Action>#{change_item[:action]}</Action>}
name_tag = %Q{<Name>#{change_item[:name]}</Name>}
type_tag = %Q{<Type>#{change_item[:type]}</Type>}
# TTL must be omitted if using an alias record
ttl_tag = ''
ttl_tag += %Q{<TTL>#{change_item[:ttl]}</TTL>} unless change_item[:alias_target]
resource_records = change_item[:resource_records] || []
resource_record_tags = ''
resource_records.each do |record|
resource_record_tags += %Q{<ResourceRecord><Value>#{record}</Value></ResourceRecord>}
end
# ResourceRecords must be omitted if using an alias record
resource_tag = ''
resource_tag += %Q{<ResourceRecords>#{resource_record_tags}</ResourceRecords>} if resource_records.any?
alias_target_tag = ''
if change_item[:alias_target]
alias_target_tag += %Q{<AliasTarget><HostedZoneId>#{change_item[:alias_target][:hosted_zone_id]}</HostedZoneId><DNSName>#{change_item[:alias_target][:dns_name]}</DNSName></AliasTarget>}
end
change_tags = %Q{<Change>#{action_tag}<ResourceRecordSet>#{name_tag}#{type_tag}#{ttl_tag}#{resource_tag}#{alias_target_tag}</ResourceRecordSet></Change>}
changes += change_tags
end
changes += '</Changes></ChangeBatch>'
end
body = %Q{<?xml version="1.0" encoding="UTF-8"?><ChangeResourceRecordSetsRequest xmlns="https://route53.amazonaws.com/doc/2011-05-05/">#{changes}</ChangeResourceRecordSetsRequest>}
request({
:body => body,
:parser => Fog::Parsers::DNS::AWS::ChangeResourceRecordSets.new,

View file

@ -12,7 +12,7 @@ module Fog
# * options<~Hash>
# * caller_ref<~String> - unique string that identifies the request & allows failed
# calls to be retried without the risk of executing the operation twice
# * comment<~Integer> -
# * comment<~String> -
#
# ==== Returns
# * response<~Excon::Response>:
@ -33,22 +33,22 @@ module Fog
optional_tags = ''
if options[:caller_ref]
optional_tags+= "<CallerReference>#{options[:caller_ref]}</CallerReference>"
optional_tags += "<CallerReference>#{options[:caller_ref]}</CallerReference>"
else
#make sure we have a unique call reference
caller_ref = "ref-#{rand(1000000).to_s}"
optional_tags+= "<CallerReference>#{caller_ref}</CallerReference>"
optional_tags += "<CallerReference>#{caller_ref}</CallerReference>"
end
if options[:comment]
optional_tags+= "<HostedZoneConfig><Comment>#{options[:comment]}</Comment></HostedZoneConfig>"
optional_tags += "<HostedZoneConfig><Comment>#{options[:comment]}</Comment></HostedZoneConfig>"
end
request({
:body => %Q{<?xml version="1.0" encoding="UTF-8"?><CreateHostedZoneRequest xmlns="https://route53.amazonaws.com/doc/2010-10-01/"><Name>#{name}</Name>#{optional_tags}</CreateHostedZoneRequest>},
:parser => Fog::Parsers::DNS::AWS::CreateHostedZone.new,
:expects => 201,
:method => 'POST',
:path => "hostedzone"
:body => %Q{<?xml version="1.0" encoding="UTF-8"?><CreateHostedZoneRequest xmlns="https://route53.amazonaws.com/doc/2011-05-05/"><Name>#{name}</Name>#{optional_tags}</CreateHostedZoneRequest>},
:parser => Fog::Parsers::DNS::AWS::CreateHostedZone.new,
:expects => 201,
:method => 'POST',
:path => "hostedzone"
})
end

View file

@ -8,7 +8,7 @@ module Fog
# Delete a hosted zone
#
# ==== Parameters
# * zone_id<~String> -
# * zone_id<~String> -
#
# ==== Returns
# * response<~Excon::Response>:
@ -20,15 +20,15 @@ module Fog
# * status<~Integer> - 200 when successful
def delete_hosted_zone(zone_id)
# AWS methods return zone_ids that looks like '/hostedzone/id'. Let the caller either use
# AWS methods return zone_ids that looks like '/hostedzone/id'. Let the caller either use
# that form or just the actual id (which is what this request needs)
zone_id = zone_id.sub('/hostedzone/', '')
request({
:expects => 200,
:parser => Fog::Parsers::DNS::AWS::DeleteHostedZone.new,
:method => 'DELETE',
:path => "hostedzone/#{zone_id}"
:expects => 200,
:parser => Fog::Parsers::DNS::AWS::DeleteHostedZone.new,
:method => 'DELETE',
:path => "hostedzone/#{zone_id}"
})
end

View file

@ -19,15 +19,15 @@ module Fog
# * status<~Integer> - 200 when successful
def get_change(change_id)
# AWS methods return change_ids that looks like '/change/id'. Let the caller either use
# AWS methods return change_ids that looks like '/change/id'. Let the caller either use
# that form or just the actual id (which is what this request needs)
change_id = change_id.sub('/change/', '')
request({
:expects => 200,
:parser => Fog::Parsers::DNS::AWS::GetChange.new,
:method => 'GET',
:path => "change/#{change_id}"
:expects => 200,
:parser => Fog::Parsers::DNS::AWS::GetChange.new,
:method => 'GET',
:path => "change/#{change_id}"
})
end

View file

@ -14,24 +14,24 @@ module Fog
# * response<~Excon::Response>:
# * body<~Hash>:
# * 'HostedZone'<~Hash>:
# * 'Id'<~String> -
# * 'Name'<~String> -
# * 'Id'<~String> -
# * 'Name'<~String> -
# * 'CallerReference'<~String>
# * 'Comment'<~String> -
# * 'Comment'<~String> -
# * 'NameServers'<~Array>
# * 'NameServer'<~String>
# * status<~Integer> - 201 when successful
def get_hosted_zone(zone_id)
# AWS methods return zone_ids that looks like '/hostedzone/id'. Let the caller either use
# AWS methods return zone_ids that looks like '/hostedzone/id'. Let the caller either use
# that form or just the actual id (which is what this request needs)
zone_id = zone_id.sub('/hostedzone/', '')
request({
:expects => 200,
:parser => Fog::Parsers::DNS::AWS::GetHostedZone.new,
:method => 'GET',
:path => "hostedzone/#{zone_id}"
:expects => 200,
:parser => Fog::Parsers::DNS::AWS::GetHostedZone.new,
:method => 'GET',
:path => "hostedzone/#{zone_id}"
})
end

View file

@ -9,7 +9,7 @@ module Fog
#
# ==== Parameters
# * options<~Hash>
# * marker<~String> - Indicates where to begin in your list of hosted zones.
# * marker<~String> - Indicates where to begin in your list of hosted zones.
# * max_items<~Integer> - The maximum number of hosted zones to be included in the response body
#
# ==== Returns
@ -17,33 +17,33 @@ module Fog
# * body<~Hash>:
# * 'HostedZones'<~Array>:
# * 'HostedZone'<~Hash>:
# * 'Id'<~String> -
# * 'Name'<~String> -
# * 'Id'<~String> -
# * 'Name'<~String> -
# * 'CallerReference'<~String>
# * 'Comment'<~String> -
# * 'Marker'<~String> -
# * 'MaxItems'<~Integer> -
# * 'IsTruncated'<~String> -
# * 'Comment'<~String> -
# * 'Marker'<~String> -
# * 'MaxItems'<~Integer> -
# * 'IsTruncated'<~String> -
# * 'NextMarket'<~String>
# * status<~Integer> - 200 when successful
def list_hosted_zones(options = {})
parameters = {}
options.each { |option, value|
options.each do |option, value|
case option
when :marker
parameters[option] = value
when :max_items
parameters[:maxitems] = value
end
}
end
request({
:query => parameters,
:parser => Fog::Parsers::DNS::AWS::ListHostedZones.new,
:expects => 200,
:method => 'GET',
:path => "hostedzone"
:query => parameters,
:parser => Fog::Parsers::DNS::AWS::ListHostedZones.new,
:expects => 200,
:method => 'GET',
:path => "hostedzone"
})
end

View file

@ -8,48 +8,51 @@ module Fog
# list your resource record sets
#
# ==== Parameters
# * zone_id<~String> -
# * zone_id<~String> -
# * options<~Hash>
# * type<~String> -
# * type<~String> -
# * name<~String> -
# * max_items<~Integer> -
# * max_items<~Integer> -
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Hash>:
# * 'ResourceRecordSet'<~Array>:
# * 'Name'<~String> -
# * 'Type'<~String> -
# * 'TTL'<~Integer> -
# * 'Name'<~String> -
# * 'Type'<~String> -
# * 'TTL'<~Integer> -
# * 'AliasTarget'<~Hash> -
# * 'HostedZoneId'<~String> -
# * 'DNSName'<~String> -
# * 'ResourceRecords'<~Array>
# * 'Value'<~String> -
# * 'IsTruncated'<~String> -
# * 'MaxItems'<~String> -
# * 'Value'<~String> -
# * 'IsTruncated'<~String> -
# * 'MaxItems'<~String> -
# * 'NextRecordName'<~String>
# * 'NexRecordType'<~String>
# * status<~Integer> - 201 when successful
def list_resource_record_sets(zone_id, options = {})
# AWS methods return zone_ids that looks like '/hostedzone/id'. Let the caller either use
# AWS methods return zone_ids that looks like '/hostedzone/id'. Let the caller either use
# that form or just the actual id (which is what this request needs)
zone_id = zone_id.sub('/hostedzone/', '')
parameters = {}
options.each { |option, value|
options.each do |option, value|
case option
when :type, :name
parameters[option]= "#{value}"
parameters[option] = "#{value}"
when :max_items
parameters['maxitems']= "#{value}"
parameters['maxitems'] = "#{value}"
end
}
end
request({
:query => parameters,
:parser => Fog::Parsers::DNS::AWS::ListResourceRecordSets.new,
:expects => 200,
:method => 'GET',
:path => "hostedzone/#{zone_id}/rrset"
:query => parameters,
:parser => Fog::Parsers::DNS::AWS::ListResourceRecordSets.new,
:expects => 200,
:method => 'GET',
:path => "hostedzone/#{zone_id}/rrset"
})
end

View file

@ -3,42 +3,19 @@ Shindo.tests('Fog::DNS[:aws] | DNS requests', ['aws', 'dns']) do
@org_zone_count = 0
@zone_id = ''
@change_id = ''
@new_records =[]
# NOTE: can't use generate_unique_domain() as we do in other DNS provider
# test suites as AWS charges $1/mth for each domain, even if it exists
# on AWS for only the time that this test suite runs!!
# http://aws.amazon.com/route53/pricing/
@test_domain = 'test-343246324434.com'
tests( 'success') do
@new_records = []
@domain_name = generate_unique_domain
test('see if test domain already exists') do
pending if Fog.mocking?
@zone_id = nil
response = Fog::DNS[:aws].list_hosted_zones()
if response.status == 200
@hosted_zones = response.body['HostedZones']
end
@elb_connection = Fog::AWS::ELB.new
@r53_connection = Fog::DNS[:aws]
tests('success') do
#go through zones for this account
@hosted_zones.each { |zone|
domain = zone['Name']
if domain.chomp == @test_domain
@zone_id = zone['Id']
end
}
@zone_id.nil?
end
test('get current zone count') do
pending if Fog.mocking?
@org_zone_count= 0
response = Fog::DNS[:aws].list_hosted_zones()
response = @r53_connection.list_hosted_zones
if response.status == 200
@hosted_zones = response.body['HostedZones']
@org_zone_count = @hosted_zones.count
@ -51,13 +28,13 @@ Shindo.tests('Fog::DNS[:aws] | DNS requests', ['aws', 'dns']) do
pending if Fog.mocking?
result = false
response = Fog::DNS[:aws].create_hosted_zone( @test_domain)
response = @r53_connection.create_hosted_zone(@domain_name)
if response.status == 201
zone= response.body['HostedZone']
zone = response.body['HostedZone']
change_info = response.body['ChangeInfo']
ns_servers = response.body['NameServers']
ns_servers = response.body['NameServers']
if (zone and change_info and ns_servers)
@ -66,7 +43,7 @@ Shindo.tests('Fog::DNS[:aws] | DNS requests', ['aws', 'dns']) do
@change_id = change_info['Id']
status = change_info['Status']
ns_srv_count = ns_servers.count
if (@zone_id.length > 0) and (caller_ref.length > 0) and (@change_id.length > 0) and
(status.length > 0) and (ns_srv_count > 0)
result = true
@ -76,28 +53,28 @@ Shindo.tests('Fog::DNS[:aws] | DNS requests', ['aws', 'dns']) do
result
}
test("get status of change #{@change_id}") {
pending if Fog.mocking?
result = false
response = Fog::DNS[:aws].get_change(@change_id)
response = @r53_connection.get_change(@change_id)
if response.status == 200
status = response.body['Status']
if (status == 'PENDING') or (status == 'INSYNC')
result= true
result = true
end
end
result
}
test("get info on hosted zone #{@zone_id}") {
pending if Fog.mocking?
result = false
response = Fog::DNS[:aws].get_hosted_zone( @zone_id)
response = @r53_connection.get_hosted_zone(@zone_id)
if response.status == 200
zone = response.body['HostedZone']
zone_id = zone['Id']
@ -106,111 +83,144 @@ Shindo.tests('Fog::DNS[:aws] | DNS requests', ['aws', 'dns']) do
ns_servers = response.body['NameServers']
# AWS returns domain with a dot at end - so when compare, remove dot
if (zone_id == @zone_id) and (name.chop == @test_domain) and (caller_ref.length > 0) and
if (zone_id == @zone_id) and (name.chop == @domain_name) and (caller_ref.length > 0) and
(ns_servers.count > 0)
result = true
end
end
result
}
test('list zones') do
pending if Fog.mocking?
result = false
response = Fog::DNS[:aws].list_hosted_zones()
response = @r53_connection.list_hosted_zones
if response.status == 200
zones= response.body['HostedZones']
if (zones.count > 0)
zone= zones[0]
zone = zones[0]
zone_id = zone['Id']
zone_name= zone['Name']
caller_ref = zone['CallerReference']
end
max_items = response.body['MaxItems']
if (zone_id.length > 0) and (zone_name.length > 0) and (caller_ref.length > 0) and
if (zone_id.length > 0) and (zone_name.length > 0) and (caller_ref.length > 0) and
(max_items > 0)
result = true
end
end
end
result
end
test("add a A resource record") {
pending if Fog.mocking?
result = false
# create an A resource record
host = 'www.' + @test_domain
host = 'www.' + @domain_name
ip_addrs = ['1.2.3.4']
resource_record = { :name => host, :type => 'A', :ttl => 3600, :resource_records => ip_addrs }
resource_record_set = resource_record.merge( :action => 'CREATE')
resource_record_set = resource_record.merge(:action => 'CREATE')
change_batch = []
change_batch << resource_record_set
options = { :comment => 'add A record to domain'}
response = Fog::DNS[:aws].change_resource_record_sets( @zone_id, change_batch, options)
options = { :comment => 'add A record to domain'}
response = @r53_connection.change_resource_record_sets(@zone_id, change_batch, options)
if response.status == 200
change_id = response.body['Id']
status = response.body['Status']
@new_records << resource_record
end
response.status == 200
}
test("add a CNAME resource record") {
pending if Fog.mocking?
result = false
# create a CNAME resource record
host = 'mail.' + @test_domain
value = ['www.' + @test_domain]
host = 'mail.' + @domain_name
value = ['www.' + @domain_name]
resource_record = { :name => host, :type => 'CNAME', :ttl => 3600, :resource_records => value }
resource_record_set = resource_record.merge( :action => 'CREATE')
resource_record_set = resource_record.merge(:action => 'CREATE')
change_batch = []
change_batch << resource_record_set
options = { :comment => 'add CNAME record to domain'}
response = Fog::DNS[:aws].change_resource_record_sets( @zone_id, change_batch, options)
options = { :comment => 'add CNAME record to domain'}
response = @r53_connection.change_resource_record_sets( @zone_id, change_batch, options)
if response.status == 200
change_id = response.body['Id']
status = response.body['Status']
@new_records << resource_record
end
response.status == 200
}
test("add a MX resource record") {
pending if Fog.mocking?
result = false
# create a MX resource record
host = @test_domain
value = ['7 mail.' + @test_domain]
host = @domain_name
value = ['7 mail.' + @domain_name]
resource_record = { :name => host, :type => 'MX', :ttl => 3600, :resource_records => value }
resource_record_set = resource_record.merge( :action => 'CREATE')
change_batch = []
change_batch << resource_record_set
options = { :comment => 'add MX record to domain'}
response = Fog::DNS[:aws].change_resource_record_sets( @zone_id, change_batch, options)
options = { :comment => 'add MX record to domain'}
response = @r53_connection.change_resource_record_sets( @zone_id, change_batch, options)
if response.status == 200
change_id = response.body['Id']
status = response.body['Status']
@new_records << resource_record
end
response.status == 200
}
test("add an ALIAS resource record") {
pending if Fog.mocking?
# create a load balancer
@elb_connection.create_load_balancer(["us-east-1a"], "fog", [{"Protocol" => "HTTP", "LoadBalancerPort" => "80", "InstancePort" => "80"}])
elb_response = @elb_connection.describe_load_balancers("fog")
elb = elb_response.body["DescribeLoadBalancersResult"]["LoadBalancerDescriptions"].first
hosted_zone_id = elb["CanonicalHostedZoneNameID"]
dns_name = elb["DNSName"]
# create an ALIAS record
host = @domain_name
alias_target = {
:hosted_zone_id => hosted_zone_id,
:dns_name => dns_name
}
resource_record = { :name => host, :type => 'A', :alias_target => alias_target }
resource_record_set = resource_record.merge(:action => 'CREATE')
change_batch = []
change_batch << resource_record_set
options = { :comment => 'add ALIAS record to domain'}
puts "Hosted Zone ID (ELB): #{hosted_zone_id}"
puts "DNS Name (ELB): #{dns_name}"
puts "Zone ID for Route 53: #{@zone_id}"
sleep 120
response = @r53_connection.change_resource_record_sets(@zone_id, change_batch, options)
if response.status == 200
change_id = response.body['Id']
status = response.body['Status']
@new_records << resource_record
end
response.status == 200
}
@ -218,7 +228,7 @@ Shindo.tests('Fog::DNS[:aws] | DNS requests', ['aws', 'dns']) do
pending if Fog.mocking?
# get resource records for zone
response = Fog::DNS[:aws].list_resource_record_sets( @zone_id)
response = @r53_connection.list_resource_record_sets( @zone_id)
if response.status == 200
record_sets= response.body['ResourceRecordSets']
num_records= record_sets.count
@ -231,14 +241,14 @@ Shindo.tests('Fog::DNS[:aws] | DNS requests', ['aws', 'dns']) do
pending if Fog.mocking?
result = true
change_batch = []
@new_records.each { |record|
@new_records.each { |record|
resource_record_set = record.merge( :action => 'DELETE')
change_batch << resource_record_set
}
options = { :comment => 'remove records from domain'}
response = Fog::DNS[:aws].change_resource_record_sets( @zone_id, change_batch, options)
options = { :comment => 'remove records from domain'}
response = @r53_connection.change_resource_record_sets(@zone_id, change_batch, options)
if response.status != 200
result = false
break
@ -246,31 +256,34 @@ Shindo.tests('Fog::DNS[:aws] | DNS requests', ['aws', 'dns']) do
result
}
test("delete hosted zone #{@zone_id}") {
pending if Fog.mocking?
response = Fog::DNS[:aws].delete_hosted_zone( @zone_id)
# cleanup the ELB as well
@elb_connection.delete_load_balancer("fog")
response = @r53_connection.delete_hosted_zone(@zone_id)
response.status == 200
}
end
tests( 'failure') do
tests('failure') do
tests('create hosted zone using invalid domain name').raises(Excon::Errors::BadRequest) do
pending if Fog.mocking?
response = Fog::DNS[:aws].create_hosted_zone('invalid-domain')
response = @r53_connection.create_hosted_zone('invalid-domain')
end
tests('get hosted zone using invalid ID').raises(Excon::Errors::Forbidden) do
pending if Fog.mocking?
zone_id = 'dummy-id'
response = Fog::DNS[:aws].get_hosted_zone(zone_id)
response = @r53_connection.get_hosted_zone(zone_id)
end
end
end