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:
parent
8bda3ba52f
commit
0595cd7dfb
3 changed files with 30 additions and 5 deletions
23
lib/fog/dns/parsers/dynect/zone.rb
Normal file
23
lib/fog/dns/parsers/dynect/zone.rb
Normal 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
|
|
@ -3,10 +3,11 @@ module Fog
|
|||
class DNS
|
||||
class Real
|
||||
|
||||
# require 'fog/dns/parsers/dynect/session'
|
||||
require 'fog/dns/parsers/dynect/zone'
|
||||
|
||||
def zone
|
||||
request(
|
||||
:parser => Fog::Parsers::Dynect::DNS::Zone.new,
|
||||
:expects => 200,
|
||||
:method => "GET",
|
||||
:path => "Zone",
|
||||
|
@ -20,6 +21,7 @@ module Fog
|
|||
response = Excon::Response.new
|
||||
response.status = 200
|
||||
response.body = {
|
||||
"zones" => ["example.com"]
|
||||
}
|
||||
response
|
||||
end
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
Shindo.tests('Dynect::dns | DNS requests', ['dynect', 'dns']) do
|
||||
tests( 'success') do
|
||||
test "start api session" do
|
||||
tests "success" do
|
||||
tests "start api session" do
|
||||
response = Dynect[:dns].session
|
||||
returns(true) { response.body['Auth-Token'] =~ /.+=$/ && true }
|
||||
returns(true) { response.body['API-Version'] == "2.3.1" }
|
||||
returns(true) { response.status == 200 }
|
||||
end
|
||||
|
||||
test "list zones" do
|
||||
tests "list zones" do
|
||||
response = Dynect[:dns].zone
|
||||
returns(true) { response.body['zones'].size > 0 }
|
||||
returns(true) { response.body['zones'].first =~ /\.com/ && true }
|
||||
returns(true) { response.status == 200 }
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue