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

[dynect|dns] support reauth for inactivity logout too.

This commit is contained in:
Dylan Egan 2011-09-09 11:36:28 -07:00
parent 440bbc30f5
commit 9b3eb02541
2 changed files with 10 additions and 2 deletions

View file

@ -91,7 +91,7 @@ module Fog
response
rescue Excon::Errors::HTTPStatusError => error
if @auth_token && error.message =~ /login: Bad or expired credentials/
if @auth_token && error.message =~ /login: (Bad or expired credentials|inactivity logout)/
@auth_token = nil
retry
else

View file

@ -174,12 +174,20 @@ Shindo.tests('Dynect::dns | DNS requests', ['dynect', 'dns']) do
end
tests('failure') do
tests("#auth_token with bad credentials").raises(Excon::Errors::BadRequest) do
tests("#auth_token with expired credentials").raises(Excon::Errors::BadRequest) do
pending if Fog.mocking?
@dns = Fog::DNS[:dynect]
@dns.instance_variable_get(:@connection).stub(:request) { raise Excon::Errors::BadRequest.new('Expected(200) <=> Actual(400 Bad Request) request => {:headers=>{"Content-Type"=>"application/json", "API-Version"=>"2.3.1", "Auth-Token"=>"auth-token", "Host"=>"api2.dynect.net:443", "Content-Length"=>0}, :host=>"api2.dynect.net", :mock=>nil, :path=>"/REST/CNAMERecord/domain.com/www.domain.com", :port=>"443", :query=>nil, :scheme=>"https", :expects=>200, :method=>:get} response => #<Excon::Response:0x00000008478b98 @body="{"status": "failure", "data": {}, "job_id": 21326025, "msgs": [{"INFO": "login: Bad or expired credentials", "SOURCE": "BLL", "ERR_CD": "INVALID_DATA", "LVL": "ERROR"}, {"INFO": "login: There was a problem with your credentials", "SOURCE": "BLL", "ERR_CD": null, "LVL": "INFO"}]}", @headers={"Server"=>"nginx/0.7.67", "Date"=>"Thu, 08 Sep 2011 20:04:21 GMT", "Content-Type"=>"application/json", "Transfer-Encoding"=>"chunked", "Connection"=>"keep-alive"}, @status=400>') }
@dns.instance_variable_get(:@connection).should_receive(:request).exactly(2).times
@dns.auth_token
end
tests("#auth_token with inactivity logout").raises(Excon::Errors::BadRequest) do
pending if Fog.mocking?
@dns = Fog::DNS[:dynect]
@dns.instance_variable_get(:@connection).stub(:request) { raise Excon::Errors::BadRequest.new('Expected(200) <=> Actual(400 Bad Request) request => {:headers=>{"Content-Type"=>"application/json", "API-Version"=>"2.3.1", "Auth-Token"=>"auth-token", "Host"=>"api2.dynect.net:443", "Content-Length"=>0}, :host=>"api2.dynect.net", :mock=>nil, :path=>"/REST/CNAMERecord/domain.com/www.domain.com", :port=>"443", :query=>nil, :scheme=>"https", :expects=>200, :method=>:get} response => #<Excon::Response:0x00000008478b98 @body="{"status": "failure", "data": {}, "job_id": 21326025, "msgs": [{"INFO": "login: inactivity logout", "SOURCE": "BLL", "ERR_CD": "INVALID_DATA", "LVL": "ERROR"}, {"INFO": "login: There was a problem with your credentials", "SOURCE": "BLL", "ERR_CD": null, "LVL": "INFO"}]}", @headers={"Server"=>"nginx/0.7.67", "Date"=>"Thu, 08 Sep 2011 20:04:21 GMT", "Content-Type"=>"application/json", "Transfer-Encoding"=>"chunked", "Connection"=>"keep-alive"}, @status=400>') }
@dns.instance_variable_get(:@connection).should_receive(:request).exactly(2).times
@dns.auth_token
end
end
end