1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

parse the list of zones returned

This commit is contained in:
Michael Hale 2011-02-08 22:03:06 -05:00 committed by geemus
parent 8bda3ba52f
commit 0595cd7dfb
3 changed files with 30 additions and 5 deletions

View file

@ -0,0 +1,23 @@
module Fog
module Parsers
module Dynect
module DNS
class Zone < Fog::Parsers::Base
def reset
@response = {"zones" => []}
end
def end_element(name)
case name
when 'ZoneURI'
@response['zones'] << @value.match(/\/REST\/Zone\/(.+)\//)[1]
end
end
end
end
end
end
end

View file

@ -3,10 +3,11 @@ module Fog
class DNS class DNS
class Real class Real
# require 'fog/dns/parsers/dynect/session' require 'fog/dns/parsers/dynect/zone'
def zone def zone
request( request(
:parser => Fog::Parsers::Dynect::DNS::Zone.new,
:expects => 200, :expects => 200,
:method => "GET", :method => "GET",
:path => "Zone", :path => "Zone",
@ -20,6 +21,7 @@ module Fog
response = Excon::Response.new response = Excon::Response.new
response.status = 200 response.status = 200
response.body = { response.body = {
"zones" => ["example.com"]
} }
response response
end end

View file

@ -1,15 +1,15 @@
Shindo.tests('Dynect::dns | DNS requests', ['dynect', 'dns']) do Shindo.tests('Dynect::dns | DNS requests', ['dynect', 'dns']) do
tests( 'success') do tests "success" do
test "start api session" do tests "start api session" do
response = Dynect[:dns].session response = Dynect[:dns].session
returns(true) { response.body['Auth-Token'] =~ /.+=$/ && true } returns(true) { response.body['Auth-Token'] =~ /.+=$/ && true }
returns(true) { response.body['API-Version'] == "2.3.1" } returns(true) { response.body['API-Version'] == "2.3.1" }
returns(true) { response.status == 200 } returns(true) { response.status == 200 }
end end
test "list zones" do tests "list zones" do
response = Dynect[:dns].zone response = Dynect[:dns].zone
returns(true) { response.body['zones'].size > 0 } returns(true) { response.body['zones'].first =~ /\.com/ && true }
returns(true) { response.status == 200 } returns(true) { response.status == 200 }
end end
end end