1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/tests/dnsimple/requests/dns/dns_tests.rb

119 lines
2.6 KiB
Ruby
Raw Normal View History

Shindo.tests('Fog::DNS[:dnsimple] | DNS requests', ['dnsimple', 'dns']) do
@domain = ''
@domain_count = 0
2011-02-24 18:22:38 -05:00
tests("success") do
2011-02-24 18:22:38 -05:00
test("get current domain count") do
pending if Fog.mocking?
response = Fog::DNS[:dnsimple].list_domains()
if response.status == 200
@domain_count = response.body.size
end
response.status == 200
end
2011-02-24 18:22:38 -05:00
test("create domain") do
pending if Fog.mocking?
domain = generate_unique_domain
response = Fog::DNS[:dnsimple].create_domain(domain)
if response.status == 201
2011-02-24 00:56:16 -05:00
@domain = response.body["domain"]
end
response.status == 201
end
2011-02-24 00:56:16 -05:00
test("get domain by id") do
pending if Fog.mocking?
response = Fog::DNS[:dnsimple].get_domain(@domain["id"])
response.status == 200
end
2011-02-24 00:56:16 -05:00
test("create an A resource record") do
pending if Fog.mocking?
2011-02-24 00:56:16 -05:00
domain = @domain["name"]
name = "www"
type = "A"
content = "1.2.3.4"
response = Fog::DNS[:dnsimple].create_record(domain, name, type, content)
2011-02-24 00:56:16 -05:00
if response.status == 201
2011-02-24 18:22:38 -05:00
@record = response.body["record"]
end
2011-02-24 00:56:16 -05:00
response.status == 201
end
2011-02-24 18:22:38 -05:00
test("create a MX record") do
pending if Fog.mocking?
domain = @domain["name"]
name = ""
type = "MX"
content = "mail.#{domain}"
options = { :ttl => 60, :prio => 10 }
response = Fog::DNS[:dnsimple].create_record(domain, name, type, content, options)
2011-02-24 18:22:38 -05:00
response.status == 201
end
test("update a record") do
pending if Fog.mocking?
domain = @domain["name"]
record_id = @record["id"]
options = { :content => "2.3.4.5", :ttl => 600 }
response = Fog::DNS[:dnsimple].update_record(domain, record_id, options)
2011-02-24 18:22:38 -05:00
response.status == 200
end
test("list records") do
pending if Fog.mocking?
response = Fog::DNS[:dnsimple].list_records(@domain["name"])
2011-02-24 18:22:38 -05: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|
response = Fog::DNS[:dnsimple].delete_record(domain, record["record"]["id"])
2011-02-24 18:22:38 -05:00
if(response.status != 200)
result = false
break
end
end
result
end
2011-02-24 00:56:16 -05:00
test("delete domain") do
pending if Fog.mocking?
response = Fog::DNS[:dnsimple].delete_domain(@domain["name"])
2011-02-24 00:56:16 -05:00
response.status == 200
end
end
tests( 'failure') do
end
end