1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/tests/dns/requests/dynect/dns_tests.rb
2011-08-30 10:01:22 -07:00

162 lines
4.2 KiB
Ruby

Shindo.tests('Dynect::dns | DNS requests', ['dynect', 'dns']) do
shared_format = {
'job_id' => Integer,
'msgs' => [{
'ERR_CD' => Fog::Nullable::String,
'INFO' => String,
'LVL' => String,
'SOURCE' => String
}],
'status' => String
}
tests "success" do
@dns = Fog::DNS[:dynect]
@domain = generate_unique_domain
@fqdn = "www.#{@domain}"
post_session_format = shared_format.merge({
'data' => {
'token' => String,
'version' => String
}
})
tests("post_session").formats(post_session_format) do
@dns.post_session.body
end
post_zone_format = shared_format.merge({
'data' => {
'serial' => Integer,
'zone' => String,
'zone_type' => String,
'serial_style' => String
}
})
tests("post_zone('netops@#{@domain}', 3600, '#{@domain}')").formats(post_zone_format) do
@dns.post_zone("netops@#{@domain}", 3600, @domain).body
end
get_zones_format = shared_format.merge({
'data' => [String]
})
tests("get_zone").formats(get_zones_format) do
@dns.get_zone.body
end
get_zone_format = shared_format.merge({
'data' => {
"serial" => Integer,
"serial_style" => String,
"zone" => String,
"zone_type" => String
}
})
tests("get_zone('zone' => '#{@domain}')").formats(get_zone_format) do
@dns.get_zone('zone' => @domain).body
end
post_record_format = shared_format.merge({
'data' => {
'fqdn' => String,
'rdata' => {
'address' => String
},
'record_id' => Integer,
'record_type' => String,
'ttl' => Integer,
'zone' => String
}
})
tests("post_record('A', '#{@domain}', '#{@fqdn}', 'address' => '1.2.3.4')").formats(post_record_format) do
@dns.post_record('A', @domain, @fqdn, {'address' => '1.2.3.4'}, {}).body
end
publish_zone_format = shared_format.merge({
'data' => {
'serial' => Integer,
'serial_style' => String,
'zone' => String,
'zone_type' => String
}
})
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({
'data' => [String]
})
tests("get_node_list('#{@domain}')").formats(get_node_list_format) do
@dns.get_node_list(@domain).body
end
get_records_format = shared_format.merge({
'data' => [String]
})
tests("get_record('A', '#{@domain}', '#{@fqdn}')").formats(get_records_format) do
data = @dns.get_record('A', @domain, @fqdn).body
@record_id = data['data'].first.split('/').last
data
end
get_record_format = shared_format.merge({
'data' => {
'zone' => String,
'ttl' => Integer,
'fqdn' => String,
'record_type' => String,
'rdata' => {
'address' => String
},
'record_id' => Integer
}
})
tests("get_record('A', '#{@domain}', '#{@fqdn}', 'record_id' => '#{@record_id}')").formats(get_record_format) do
@dns.get_record('A', @domain, @fqdn, 'record_id' => @record_id).body
end
delete_record_format = shared_format.merge({
'data' => {}
})
tests("delete_record('A', '#{@domain}', '#{@fqdn}', '#{@record_id}')").formats(delete_record_format) do
@dns.delete_record('A', @domain, "#{@fqdn}", @record_id).body
end
delete_zone_format = shared_format.merge({
'data' => {}
})
tests("delete_zone('#{@domain}')").formats(delete_zone_format) do
@dns.delete_zone(@domain).body
end
end
end