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

add zone request

This commit is contained in:
Michael Hale 2011-02-08 21:47:44 -05:00 committed by geemus
parent 6f00b04f38
commit d006e59148
3 changed files with 44 additions and 8 deletions

View file

@ -14,6 +14,7 @@ module Fog
request_path 'fog/dns/requests/dynect'
request :session
request :zone
class Real
def initialize(options={})
@ -29,20 +30,20 @@ module Fog
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent] || true)
end
def auth_token
@auth_token ||= session.body['Auth-Token']
end
def request(params)
begin
params[:headers] ||= {}
params[:headers]['Content-Type'] = 'text/xml'
params[:headers]['API-Version'] = @version
params[:headers]['Auth-Token'] = auth_token unless params[:path] == "Session"
params[:path] = "#{@path}/#{params[:path]}"
response = @connection.request(params.merge!({:host => @host}))
rescue Excon::Errors::HTTPStatusError => error
raise case error
when Excon::Errors::NotFound
Fog::Dynect::DNS::NotFound.slurp(error)
else
error
end
raise error
end
response
@ -50,8 +51,6 @@ module Fog
end
class Mock
def zones
end
end
end

View file

@ -0,0 +1,31 @@
module Fog
module Dynect
class DNS
class Real
# require 'fog/dns/parsers/dynect/session'
def zone
request(
:expects => 200,
:method => "GET",
:path => "Zone",
)
end
end
class Mock
def zone
response = Excon::Response.new
response.status = 200
response.body = {
}
response
end
end
end
end
end

View file

@ -6,5 +6,11 @@ Shindo.tests('Dynect::dns | DNS requests', ['dynect', 'dns']) do
returns(true) { response.body['API-Version'] == "2.3.1" }
returns(true) { response.status == 200 }
end
test "list zones" do
response = Dynect[:dns].zone
returns(true) { response.body['zones'].size > 0 }
returns(true) { response.status == 200 }
end
end
end