2011-08-16 20:59:57 -04:00
|
|
|
Shindo.tests('Fog::DNS[:rackspace] | DNS requests', ['rackspace', 'dns']) do
|
|
|
|
|
2011-09-23 11:42:46 -04:00
|
|
|
pending if Fog.mocking?
|
2011-11-10 19:34:04 -05:00
|
|
|
domain_name = uniq_id + '.com'
|
2011-08-16 20:59:57 -04:00
|
|
|
|
2011-08-27 18:46:15 -04:00
|
|
|
tests('success on simple domain') do
|
2011-11-10 19:34:04 -05:00
|
|
|
domain_tests(Fog::DNS[:rackspace], {:name => domain_name, :email => 'hostmaster@' + domain_name, :records => [{:ttl => 300, :name => domain_name, :type => 'A', :data => '192.168.1.1'}]}) do
|
2011-08-27 18:46:15 -04:00
|
|
|
|
2011-09-27 12:04:40 -04:00
|
|
|
tests('list_domains').formats(LIST_DOMAIN_FORMAT.reject {|key,value| key == 'links'}) do
|
2011-09-23 11:42:46 -04:00
|
|
|
Fog::DNS[:rackspace].list_domains.body
|
2011-08-27 18:46:15 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
tests("list_domains :limit => 5, :offset => 10, :domain => #{@domain_details.first['name']} --> All possible attributes").formats(LIST_DOMAIN_FORMAT) do
|
2011-09-23 11:42:46 -04:00
|
|
|
Fog::DNS[:rackspace].list_domains(:limit => 5, :offset => 10, :domain => @domain_details.first['name']).body
|
2011-08-27 18:46:15 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
tests("list_domain_details('#{@domain_id}')").formats(LIST_DOMAIN_DETAILS_WITH_RECORDS) do
|
2011-09-23 11:42:46 -04:00
|
|
|
Fog::DNS[:rackspace].list_domain_details(@domain_id).body
|
2011-08-27 18:46:15 -04:00
|
|
|
end
|
|
|
|
|
2011-08-27 22:06:46 -04:00
|
|
|
tests("modify_domain('#{@domain_id}', :ttl => 500, :comment => 'woot', :email => 'randomemail@randomhost.com')").succeeds do
|
2011-09-23 11:42:46 -04:00
|
|
|
response = Fog::DNS[:rackspace].modify_domain @domain_id, :ttl => 500, :comment => 'woot', :email => 'randomemail@randomhost.com'
|
|
|
|
wait_for Fog::DNS[:rackspace], response
|
2011-08-27 18:46:15 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
tests('success for domain with multiple records') do
|
2011-09-23 11:42:46 -04:00
|
|
|
domain_tests(Fog::DNS[:rackspace],
|
2011-08-27 18:46:15 -04:00
|
|
|
{
|
2011-11-10 19:34:04 -05:00
|
|
|
:name => domain_name,
|
|
|
|
:email => 'hostmaster@' + domain_name,
|
2011-08-27 18:46:15 -04:00
|
|
|
:records =>
|
|
|
|
[
|
|
|
|
{
|
|
|
|
:ttl => 300,
|
2011-11-10 19:34:04 -05:00
|
|
|
:name => domain_name,
|
2011-08-27 18:46:15 -04:00
|
|
|
:type => 'A',
|
|
|
|
:data => '192.168.1.1'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
:ttl => 3600,
|
2011-11-10 19:34:04 -05:00
|
|
|
:name => domain_name,
|
2011-08-27 18:46:15 -04:00
|
|
|
:type => 'MX',
|
2011-11-10 19:34:04 -05:00
|
|
|
:data => 'mx.' + domain_name,
|
2011-08-27 18:46:15 -04:00
|
|
|
:priority => 10
|
|
|
|
}
|
|
|
|
]
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
tests('success for multiple domains') do
|
2011-11-10 19:34:04 -05:00
|
|
|
domain1_name = uniq_id + '-1.com'
|
|
|
|
domain2_name = uniq_id + '-2.com'
|
|
|
|
|
2011-09-23 11:42:46 -04:00
|
|
|
domains_tests(Fog::DNS[:rackspace],
|
2011-08-27 18:46:15 -04:00
|
|
|
[
|
2011-11-10 19:34:04 -05:00
|
|
|
{:name => domain1_name, :email => 'hostmaster@' + domain1_name, :records => [{:ttl => 300, :name => domain1_name, :type => 'A', :data => '192.168.1.1'}]},
|
|
|
|
{:name => domain2_name, :email => 'hostmaster@' + domain2_name, :records => [{:ttl => 300, :name => domain2_name, :type => 'A', :data => '192.168.1.1'}]}
|
2011-08-27 18:46:15 -04:00
|
|
|
])
|
|
|
|
end
|
|
|
|
|
|
|
|
tests('success for domain with subdomain') do
|
2011-09-23 11:42:46 -04:00
|
|
|
domains_tests(Fog::DNS[:rackspace],
|
2011-08-27 18:46:15 -04:00
|
|
|
[
|
2011-11-10 19:34:04 -05:00
|
|
|
{:name => domain_name, :email => 'hostmaster@' + domain_name, :records => [{:ttl => 300, :name => domain_name, :type => 'A', :data => '192.168.1.1'}]},
|
|
|
|
{:name => 'subdomain.' + domain_name, :email => 'hostmaster@subdomain.' + domain_name, :records => [{:ttl => 300, :name =>'subdomain.' + domain_name, :type => 'A', :data => '192.168.1.1'}]}
|
2011-08-27 18:46:15 -04:00
|
|
|
], true) do
|
|
|
|
|
2011-11-10 19:34:04 -05:00
|
|
|
@root_domain_id = @domain_details.find { |domain| domain['name'] == domain_name }['id']
|
2011-08-27 18:46:15 -04:00
|
|
|
|
|
|
|
tests("list_domain_details('#{@root_domain_id}', :show_records => false, :show_subdomains => false)") do
|
2011-09-23 11:42:46 -04:00
|
|
|
response = Fog::DNS[:rackspace].list_domain_details(@root_domain_id, :show_records => false, :show_subdomains => false)
|
2011-08-27 18:46:15 -04:00
|
|
|
|
|
|
|
formats(LIST_DOMAIN_DETAILS_WITHOUT_RECORDS_AND_SUBDOMAINS_FORMAT) { response.body }
|
|
|
|
returns(nil) { response.body['recordsList'] }
|
|
|
|
returns(nil) { response.body['subdomains'] }
|
|
|
|
end
|
|
|
|
|
|
|
|
tests("list_domain_details('#{@root_domain_id}', :show_records => true, :show_subdomains => true)") do
|
2011-09-23 11:42:46 -04:00
|
|
|
response = Fog::DNS[:rackspace].list_domain_details(@root_domain_id, :show_records => true, :show_subdomains => true)
|
2011-08-27 18:46:15 -04:00
|
|
|
|
|
|
|
formats(LIST_DOMAIN_DETAILS_WITH_RECORDS_AND_SUBDOMAINS_FORMAT) { response.body }
|
|
|
|
returns(false) { response.body['recordsList'].nil? }
|
|
|
|
returns(false) { response.body['subdomains'].nil? }
|
|
|
|
end
|
|
|
|
|
|
|
|
tests("list_subdomains('#{@root_domain_id}')").formats(LIST_SUBDOMAINS_FORMAT) do
|
2011-09-23 11:42:46 -04:00
|
|
|
Fog::DNS[:rackspace].list_subdomains(@root_domain_id).body
|
2011-08-27 18:46:15 -04:00
|
|
|
end
|
|
|
|
|
2011-08-28 10:53:43 -04:00
|
|
|
tests("remove_domain('#{@root_domain_id}', :delete_subdomains => true)") do
|
2011-09-23 11:42:46 -04:00
|
|
|
wait_for Fog::DNS[:rackspace], Fog::DNS[:rackspace].remove_domain(@root_domain_id, :delete_subdomains => true)
|
2011-08-27 18:46:15 -04:00
|
|
|
|
|
|
|
test('domain and subdomains were really deleted') do
|
2011-11-10 19:34:04 -05:00
|
|
|
(Fog::DNS[:rackspace].list_domains.body['domains'].collect { |domain| domain['name'] } & [domain_name, 'subdomain.' + domain_name]).empty?
|
2011-08-27 18:46:15 -04:00
|
|
|
end
|
|
|
|
end
|
2011-08-16 22:33:15 -04:00
|
|
|
end
|
2011-08-16 20:59:57 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
tests( 'failure') do
|
2011-08-27 18:46:15 -04:00
|
|
|
|
2011-11-24 11:33:12 -05:00
|
|
|
tests('create_domain(invalid)').returns('ERROR') do
|
|
|
|
response = wait_for Fog::DNS[:rackspace], Fog::DNS[:rackspace].create_domains([{:name => 'badtestdomain.com', :email => '', :records => [{:ttl => 300, :name => 'badtestdomain.com', :type => 'A', :data => '192.168.1.1'}]}])
|
|
|
|
|
|
|
|
response.body['status']
|
2011-08-27 18:46:15 -04:00
|
|
|
end
|
|
|
|
|
2011-08-16 22:33:15 -04:00
|
|
|
tests('list_domains :limit => 5, :offset => 8').raises(Fog::Rackspace::Errors::BadRequest) do
|
2011-09-23 11:42:46 -04:00
|
|
|
Fog::DNS[:rackspace].list_domains :limit => 5, :offset => 8
|
2011-08-16 22:33:15 -04:00
|
|
|
end
|
2011-08-27 18:46:15 -04:00
|
|
|
|
|
|
|
tests('list_domain_details 34335353').raises(Fog::Rackspace::Errors::NotFound) do
|
2011-09-23 11:42:46 -04:00
|
|
|
Fog::DNS[:rackspace].list_domain_details 34335353
|
2011-08-27 18:46:15 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
#tests('create_domains(#{domains})').raises(Fog::Rackspace::Errors::Conflict) do
|
2011-09-23 11:42:46 -04:00
|
|
|
# wait_for Fog::DNS[:rackspace].create_domains(domains)
|
2011-08-27 18:46:15 -04:00
|
|
|
#end
|
2011-08-28 10:53:43 -04:00
|
|
|
#tests('remove_domain(34343435)').raises(Fog::DNS::Rackspace::DeleteFault) do
|
2011-09-23 11:42:46 -04:00
|
|
|
# Fog::DNS[:rackspace].remove_domain 34343435
|
2011-08-27 18:46:15 -04:00
|
|
|
#end
|
2011-08-16 20:59:57 -04:00
|
|
|
end
|
|
|
|
end
|