2011-08-28 10:53:43 -04:00
|
|
|
Shindo.tests('Fog::DNS[:rackspace] | dns records requests', ['rackspace', 'dns']) do
|
|
|
|
|
2011-09-23 11:42:46 -04:00
|
|
|
pending if Fog.mocking?
|
2011-08-28 10:53:43 -04:00
|
|
|
|
2011-11-10 19:34:04 -05:00
|
|
|
domain_name = uniq_id + '.com'
|
|
|
|
|
|
|
|
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-28 10:53:43 -04:00
|
|
|
|
|
|
|
tests('success on single record') do
|
|
|
|
|
|
|
|
tests("list_records(#{@domain_id})").formats(RECORD_LIST_FORMAT) do
|
2011-09-23 11:42:46 -04:00
|
|
|
Fog::DNS[:rackspace].list_records(@domain_id).body
|
2011-08-28 10:53:43 -04:00
|
|
|
end
|
|
|
|
|
2011-11-10 19:34:04 -05:00
|
|
|
tests("add_records(#{@domain_id}, [{ :name => 'test1.#{domain_name}', :type => 'A', :data => '192.168.2.1'}])").formats(RECORD_LIST_FORMAT) do
|
|
|
|
response = wait_for Fog::DNS[:rackspace], Fog::DNS[:rackspace].add_records(@domain_id, [{ :name => 'test1.' + domain_name, :type => 'A', :data => '192.168.2.1'}])
|
|
|
|
@record_id = response.body['response']['records'].first['id']
|
|
|
|
response.body['response']
|
2011-08-28 10:53:43 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
tests("list_record_details(#{@domain_id}, #{@record_id})").formats(RECORD_FORMAT) do
|
2011-09-23 11:42:46 -04:00
|
|
|
Fog::DNS[:rackspace].list_record_details(@domain_id, @record_id).body
|
2011-08-28 10:53:43 -04:00
|
|
|
end
|
|
|
|
|
2011-11-10 19:34:04 -05:00
|
|
|
tests("modify_record(#{@domain_id}, #{@record_id}, { :ttl => 500, :name => 'test2.#{domain_name}', :data => '192.168.3.1' })").succeeds do
|
|
|
|
wait_for Fog::DNS[:rackspace], Fog::DNS[:rackspace].modify_record(@domain_id, @record_id, { :ttl => 500, :name => 'test2.' + domain_name, :data => '192.168.3.1' })
|
2011-08-28 10:53:43 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
tests("remove_record(#{@domain_id}, #{@record_id})").succeeds do
|
2011-09-23 11:42:46 -04:00
|
|
|
wait_for Fog::DNS[:rackspace], Fog::DNS[:rackspace].remove_record(@domain_id, @record_id)
|
2011-08-28 10:53:43 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
tests('success on multiple records') do
|
|
|
|
|
|
|
|
records_attributes =
|
|
|
|
[
|
2011-11-10 19:34:04 -05:00
|
|
|
{ :name => 'test1.' + domain_name, :type => 'A', :data => '192.168.2.1'},
|
|
|
|
{ :name => domain_name, :type => 'MX', :priority => 10, :data => 'mx.' + domain_name}
|
2011-08-28 10:53:43 -04:00
|
|
|
]
|
|
|
|
|
|
|
|
tests("add_records(#{@domain_id}, #{records_attributes})").formats(RECORD_LIST_FORMAT) do
|
2011-09-23 11:42:46 -04:00
|
|
|
response = wait_for Fog::DNS[:rackspace], Fog::DNS[:rackspace].add_records(@domain_id, records_attributes)
|
2011-11-10 19:34:04 -05:00
|
|
|
@record_ids = response.body['response']['records'].collect { |record| record['id'] }
|
|
|
|
response.body['response']
|
2011-08-28 10:53:43 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
tests("remove_records(#{@domain_id}, #{@record_ids})").succeeds do
|
2011-09-23 11:42:46 -04:00
|
|
|
wait_for Fog::DNS[:rackspace], Fog::DNS[:rackspace].remove_records(@domain_id, @record_ids)
|
2011-08-28 10:53:43 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
tests( 'failure') do
|
|
|
|
tests("list_records('')").raises(ArgumentError) do
|
2011-09-23 11:42:46 -04:00
|
|
|
Fog::DNS[:rackspace].list_records('')
|
2011-08-28 10:53:43 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
tests("list_records('abc')").raises(Fog::Rackspace::Errors::NotFound) do
|
2011-09-23 11:42:46 -04:00
|
|
|
Fog::DNS[:rackspace].list_records('abc')
|
2011-08-28 10:53:43 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
tests("list_record_details(#{@domain_id}, '')").raises(ArgumentError) do
|
2011-09-23 11:42:46 -04:00
|
|
|
Fog::DNS[:rackspace].list_record_details(@domain_id, '')
|
2011-08-28 10:53:43 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
tests("list_record_details(#{@domain_id}, 'abc')").raises(Fog::Rackspace::Errors::NotFound) do
|
2011-09-23 11:42:46 -04:00
|
|
|
Fog::DNS[:rackspace].list_record_details(@domain_id, 'abc')
|
2011-08-28 10:53:43 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
tests("remove_record(#{@domain_id}, '')").raises(ArgumentError) do
|
2011-09-23 11:42:46 -04:00
|
|
|
Fog::DNS[:rackspace].remove_record(@domain_id, '')
|
2011-08-28 10:53:43 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
tests("remove_record(#{@domain_id}, 'abc')").raises(Fog::Rackspace::Errors::NotFound) do
|
2011-09-23 11:42:46 -04:00
|
|
|
Fog::DNS[:rackspace].remove_record(@domain_id, 'abc')
|
2011-08-28 10:53:43 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
tests("add_record(#{@domain_id}, [{ :name => '', :type => '', :data => ''}])").raises(Fog::Rackspace::Errors::BadRequest) do
|
2011-09-23 11:42:46 -04:00
|
|
|
Fog::DNS[:rackspace].add_records(@domain_id, [{ :name => '', :type => '', :data => ''}])
|
2011-08-28 10:53:43 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|