Skip to content

Commit 9b3eb02

Browse files
committedSep 9, 2011
[dynect|dns] support reauth for inactivity logout too.
1 parent 440bbc3 commit 9b3eb02

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed
 

‎lib/fog/dynect/dns.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def request(params)
9191
response
9292

9393
rescue Excon::Errors::HTTPStatusError => error
94-
if @auth_token && error.message =~ /login: Bad or expired credentials/
94+
if @auth_token && error.message =~ /login: (Bad or expired credentials|inactivity logout)/
9595
@auth_token = nil
9696
retry
9797
else

‎tests/dynect/requests/dns/dns_tests.rb

+9-1
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,20 @@
174174
end
175175

176176
tests('failure') do
177-
tests("#auth_token with bad credentials").raises(Excon::Errors::BadRequest) do
177+
tests("#auth_token with expired credentials").raises(Excon::Errors::BadRequest) do
178178
pending if Fog.mocking?
179179
@dns = Fog::DNS[:dynect]
180180
@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>') }
181181
@dns.instance_variable_get(:@connection).should_receive(:request).exactly(2).times
182182
@dns.auth_token
183183
end
184+
185+
tests("#auth_token with inactivity logout").raises(Excon::Errors::BadRequest) do
186+
pending if Fog.mocking?
187+
@dns = Fog::DNS[:dynect]
188+
@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>') }
189+
@dns.instance_variable_get(:@connection).should_receive(:request).exactly(2).times
190+
@dns.auth_token
191+
end
184192
end
185193
end

0 commit comments

Comments
 (0)
Please sign in to comment.