From 146d6e8b0c45affcf145592ba2cf655a29477d0f Mon Sep 17 00:00:00 2001 From: Michael Hale Date: Tue, 8 Feb 2011 10:08:50 -0500 Subject: [PATCH] parse session request and fix mock for tests --- lib/fog/dns/requests/dynect/session.rb | 6 ++++++ tests/dns/requests/dynect/dns_tests.rb | 9 +++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/fog/dns/requests/dynect/session.rb b/lib/fog/dns/requests/dynect/session.rb index cd1e2f33a..0ca51f530 100644 --- a/lib/fog/dns/requests/dynect/session.rb +++ b/lib/fog/dns/requests/dynect/session.rb @@ -2,6 +2,9 @@ module Fog module Dynect class DNS class Real + + require 'fog/dns/parsers/dynect/session' + def session builder = Builder::XmlMarkup.new xml = builder.parameters do |root| @@ -11,6 +14,7 @@ module Fog end request( + :parser => Fog::Parsers::Dynect::DNS::Session.new, :expects => 200, :method => "POST", :path => "/REST/Session/", @@ -25,6 +29,8 @@ module Fog response = Excon::Response.new response.status = 200 response.body = { + 'API-Version' => '2.3.1', + 'API-Token' => 'thetoken==' } response end diff --git a/tests/dns/requests/dynect/dns_tests.rb b/tests/dns/requests/dynect/dns_tests.rb index 636ecf175..afc6c362b 100644 --- a/tests/dns/requests/dynect/dns_tests.rb +++ b/tests/dns/requests/dynect/dns_tests.rb @@ -1,13 +1,10 @@ Shindo.tests('Dynect::dns | DNS requests', ['dynect', 'dns']) do tests( 'success') do test ('start api session') do - response = Dynect[:dns].session - if response.status == 200 - @auth_token = response.body['token'] - end - - response.status == 200 + returns(true) { response.body['API-Token'] =~ /.+=$/ && true } + returns(true) { response.body['API-Version'] == "2.3.1" } + returns(true) { response.status == 200 } end end end