2011-06-15 20:25:01 -04:00
Shindo . tests ( 'Fog::DNS[:dnsmadeeasy] | DNS requests' , [ 'dnsmadeeasy' , 'dns' ] ) do
2011-05-29 19:41:27 -04:00
@domain = ''
@domain_count = 0
tests ( " success " ) do
test ( " get current domain count " ) do
pending if Fog . mocking?
2011-06-15 20:25:01 -04:00
response = Fog :: DNS [ :dnsmadeeasy ] . list_domains ( )
2011-05-29 19:41:27 -04:00
if response . status == 200
@domain_count = response . body [ 'list' ] . size
end
response . status == 200
end
test ( " create domain " ) do
pending if Fog . mocking?
domain = generate_unique_domain
2011-06-15 20:25:01 -04:00
response = Fog :: DNS [ :dnsmadeeasy ] . create_domain ( domain )
2011-05-29 19:41:27 -04:00
if response . status == 201
@domain = response . body
end
response . status == 201
end
test ( " get domain by name " ) do
pending if Fog . mocking?
2011-06-15 20:25:01 -04:00
response = Fog :: DNS [ :dnsmadeeasy ] . get_domain ( @domain [ " name " ] )
2011-05-29 19:41:27 -04:00
response . status == 200
end
test ( " create an A resource record " ) do
pending if Fog . mocking?
domain = @domain [ " name " ]
name = " www "
type = " A "
data = " 1.2.3.4 "
2011-06-15 20:25:01 -04:00
response = Fog :: DNS [ :dnsmadeeasy ] . create_record ( domain , name , type , data )
2011-05-29 19:41:27 -04:00
if response . status == 201
@record = response . body
end
response . status == 201
end
test ( " create a MX record " ) do
pending if Fog . mocking?
domain = @domain [ " name " ]
name = " "
type = " MX "
data = " 10 mail. #{ domain } "
options = { :ttl = > 60 }
2011-06-15 20:25:01 -04:00
response = Fog :: DNS [ :dnsmadeeasy ] . create_record ( domain , name , type , data , options )
2011-05-29 19:41:27 -04:00
response . status == 201
end
2011-06-05 15:31:09 -04:00
test ( " update a record " ) do
2011-05-29 19:41:27 -04:00
pending if Fog . mocking?
domain = @domain [ " name " ]
record_id = @record [ " id " ]
options = { :name = > '' , :type = > 'A' , :data = > " 2.3.4.5 " , :ttl = > 600 }
2011-06-15 20:25:01 -04:00
response = Fog :: DNS [ :dnsmadeeasy ] . update_record ( domain , record_id , options )
2011-05-29 19:41:27 -04:00
2011-06-05 15:31:09 -04:00
response . status == 200
end
2011-06-15 20:25:01 -04:00
test ( " get record - check ip/ttl " ) do
2011-06-05 15:31:09 -04:00
pending if Fog . mocking?
2011-06-15 20:25:01 -04:00
response = Fog :: DNS [ :dnsmadeeasy ] . get_record ( @domain [ " name " ] , @record [ 'id' ] )
2011-06-05 15:31:09 -04:00
record = response . body
result = false
if response . status == 200 && record [ 'data' ] == '2.3.4.5' && record [ 'ttl' ] == 600
2011-05-29 19:41:27 -04:00
result = true
end
result
end
test ( " list records " ) do
pending if Fog . mocking?
2011-06-15 20:25:01 -04:00
response = Fog :: DNS [ :dnsmadeeasy ] . list_records ( @domain [ " name " ] )
2011-05-29 19:41:27 -04:00
if response . status == 200
@records = response . body
end
( response . status == 200 ) and ( response . body . size == 2 )
end
test ( " delete records " ) do
pending if Fog . mocking?
domain = @domain [ " name " ]
result = true
@records . each do | record |
2011-06-15 20:25:01 -04:00
response = Fog :: DNS [ :dnsmadeeasy ] . delete_record ( domain , record [ " id " ] )
2011-05-29 19:41:27 -04:00
if ( response . status != 200 )
result = false
break
end
end
result
end
test ( " delete domain " ) do
pending if Fog . mocking?
puts " DNS Made Easy - Sleeping for 10 seconds, otherwise test fails because DNS Made Easy queues requests, it still might fail if DNS Made Easy is busy! MOCK IT! "
puts " THIS MOST LIKELY WILL FAIL ON LIVE because it can take while for DNS Made Easy to create a domain/zone, changing the host to api.sandbox.dnsmadeeasy.com should make it work "
sleep 10
2011-06-15 20:25:01 -04:00
response = Fog :: DNS [ :dnsmadeeasy ] . delete_domain ( @domain [ " name " ] )
2011-05-29 19:41:27 -04:00
response . status == 200
end
end
tests ( 'failure' ) do
end
end