From 39008468205e5c1bcbb2f5e55481bf995c2e3536 Mon Sep 17 00:00:00 2001 From: Dylan Egan Date: Tue, 30 Aug 2011 09:58:26 -0700 Subject: [PATCH] Support freeze and thaw. --- lib/fog/dynect/requests/dns/put_zone.rb | 45 ++++++++++++++----------- tests/dns/requests/dynect/dns_tests.rb | 22 ++++++++++-- 2 files changed, 45 insertions(+), 22 deletions(-) diff --git a/lib/fog/dynect/requests/dns/put_zone.rb b/lib/fog/dynect/requests/dns/put_zone.rb index e8184836c..6c0a1e03b 100644 --- a/lib/fog/dynect/requests/dns/put_zone.rb +++ b/lib/fog/dynect/requests/dns/put_zone.rb @@ -31,36 +31,43 @@ module Fog response = Excon::Response.new response.status = 200 - if options[:freeze] - zone[:frozen] = true - elsif options[:publish] + data = {} + + if options['freeze'] + zone['frozen'] = true + info = "freeze: Your zone is now frozen" + elsif options['publish'] zone[:changes] = {} zone[:records_to_delete].each do |record| zone[:records][record[:type]].delete_if { |r| r[:fqdn] == record[:fqdn] && r[:record_id] == record[:record_id] } end zone[:records_to_delete] = [] - response.body = { - "status" => "success", - "data" => { - "zone_type" => zone[:zone_type], - "serial_style" => zone[:serial_style], - "serial" => zone[:serial] += 1, - "zone" => zone[:zone] - }, - "job_id" => Fog::Dynect::Mock.job_id, - "msgs" => [{ - "INFO" => "publish: #{zone[:zone]} published", - "SOURCE"=>"BLL", - "ERR_CD"=>nil, - "LVL"=>"INFO" - }] + data = { + "zone_type" => zone[:zone_type], + "serial_style" => zone[:serial_style], + "serial" => zone[:serial] += 1, + "zone" => zone[:zone] } - elsif options[:thaw] + info = "publish: #{zone[:zone]} published" + elsif options['thaw'] zone[:frozen] = false + info = "thaw: Your zone is now thawed, you may edit normally" else raise ArgumentError end + response.body = { + "status" => "success", + "data" => data, + "job_id" => Fog::Dynect::Mock.job_id, + "msgs" => [{ + "INFO" => info, + "SOURCE"=>"BLL", + "ERR_CD"=>nil, + "LVL"=>"INFO" + }] + } + response end end diff --git a/tests/dns/requests/dynect/dns_tests.rb b/tests/dns/requests/dynect/dns_tests.rb index 20e7c2982..933cd3350 100644 --- a/tests/dns/requests/dynect/dns_tests.rb +++ b/tests/dns/requests/dynect/dns_tests.rb @@ -79,7 +79,7 @@ Shindo.tests('Dynect::dns | DNS requests', ['dynect', 'dns']) do @dns.post_record('A', @domain, @fqdn, {'address' => '1.2.3.4'}, {}).body end - put_zone_format = shared_format.merge({ + publish_zone_format = shared_format.merge({ 'data' => { 'serial' => Integer, 'serial_style' => String, @@ -88,8 +88,24 @@ Shindo.tests('Dynect::dns | DNS requests', ['dynect', 'dns']) do } }) - tests("put_zone('#{@domain}', :publish => true)").formats(put_zone_format) do - @dns.put_zone(@domain, :publish => true).body + tests("put_zone('#{@domain}', 'publish' => true)").formats(publish_zone_format) do + @dns.put_zone(@domain, 'publish' => true).body + end + + freeze_zone_format = shared_format.merge({ + 'data' => {} + }) + + tests("put_zone('#{@domain}', 'freeze' => true)").formats(freeze_zone_format) do + @dns.put_zone(@domain, 'freeze' => true).body + end + + thaw_zone_format = shared_format.merge({ + 'data' => {} + }) + + tests("put_zone('#{@domain}', 'thaw' => true)").formats(thaw_zone_format) do + @dns.put_zone(@domain, 'thaw' => true).body end get_node_list_format = shared_format.merge({