summaryrefslogtreecommitdiff
path: root/test/unit/nicknym/source_test.rb
diff options
context:
space:
mode:
authorAzul <azul@riseup.net>2017-07-24 09:55:28 +0200
committerAzul <azul@riseup.net>2017-07-24 10:03:22 +0200
commitb1738a78ccf5768f92068a27255f9f69be1c3147 (patch)
tree6cad7ae458d6bc349a0ba925f82477feb2010fa1 /test/unit/nicknym/source_test.rb
parentcfa6395c7e5728de02221b94b5f9cfe8a4debf09 (diff)
fix: #3 handle domains without A-record
If a domain only has an mx record but no A record it will trigger a ConnectionError when attempting the nicknym key lookup. We need to detect and handle this in the http adapter already because once the exception is handled by Celluloid our actor will be terminated. So now we allow for handing a rescue option to the adapter with a string that is checked for inclusion in the error message. If the string is found the exception will be caught and the adapter returns nil. We only make use of this when checking the availability of nicknym so far. That should be the only http request going out.
Diffstat (limited to 'test/unit/nicknym/source_test.rb')
-rw-r--r--test/unit/nicknym/source_test.rb13
1 files changed, 10 insertions, 3 deletions
diff --git a/test/unit/nicknym/source_test.rb b/test/unit/nicknym/source_test.rb
index f8c9b60..b17f22b 100644
--- a/test/unit/nicknym/source_test.rb
+++ b/test/unit/nicknym/source_test.rb
@@ -1,4 +1,6 @@
require 'test_helper'
+require 'http'
+require 'json'
require 'nickserver/nicknym/source'
require 'nickserver/email_address'
@@ -20,6 +22,11 @@ class NicknymSourceTest < Minitest::Test
refute available_on?(200, 'blablabla')
end
+ # adapter rescues name resolution errors and returns nothing
+ def test_not_available_without_response
+ refute available_on?
+ end
+
def test_proxy_successful_query
assert proxies_query_response?(200, 'dummy body')
end
@@ -39,9 +46,9 @@ class NicknymSourceTest < Minitest::Test
adapter.verify
end
- def available_on?(status = 0, body = nil)
- adapter.expect :get, [status, body],
- ['https://remote.tld/provider.json']
+ def available_on?(*args)
+ adapter.expect :get, args,
+ ['https://remote.tld/provider.json', Hash]
available = source.available_for?('remote.tld')
adapter.verify
return available