diff options
author | Azul <azul@riseup.net> | 2016-09-22 11:31:01 +0200 |
---|---|---|
committer | Azul <azul@riseup.net> | 2016-09-22 11:31:01 +0200 |
commit | 1202e3b03c3bb88cd3a63dae3866167564f1d25d (patch) | |
tree | 5907eb5386d1113ab4d0a91fc8d14bcdd63ea3d7 | |
parent | 48cdd4b1ee0685674aa998d4daa295656d80ead3 (diff) |
hand on connection errors to dispatcher so it can handle it
-rw-r--r-- | lib/nickserver/nicknym/source.rb | 2 | ||||
-rw-r--r-- | test/remote/nicknym_source_test.rb | 8 | ||||
-rw-r--r-- | test/unit/nicknym/source_test.rb | 11 |
3 files changed, 7 insertions, 14 deletions
diff --git a/lib/nickserver/nicknym/source.rb b/lib/nickserver/nicknym/source.rb index 0638869..45daeaf 100644 --- a/lib/nickserver/nicknym/source.rb +++ b/lib/nickserver/nicknym/source.rb @@ -8,8 +8,6 @@ module Nickserver def available_for?(domain) status, body = adapter.get "https://#{domain}/provider.json" status == 200 && provider_with_mx?(body) - rescue HTTP::ConnectionError - return false end def query(email) diff --git a/test/remote/nicknym_source_test.rb b/test/remote/nicknym_source_test.rb index c95c820..b38a991 100644 --- a/test/remote/nicknym_source_test.rb +++ b/test/remote/nicknym_source_test.rb @@ -18,8 +18,10 @@ class RemoteNicknymSourceTest < Minitest::Test end def test_availablility_check - skip unless source.available_for? 'mail.bitmask.net' + source.available_for? 'mail.bitmask.net' refute source.available_for? 'dl.bitmask.net' # not a provider + rescue HTTP::ConnectionError => e + skip e.to_s end def test_successful_query @@ -28,12 +30,16 @@ class RemoteNicknymSourceTest < Minitest::Test json = JSON.parse response.content assert_equal email_with_key.to_s, json["address"] refute_empty json["openpgp"] + rescue HTTP::ConnectionError => e + skip e.to_s end def test_not_found response = source.query(email_without_key) skip if response.status == 200 assert response.status == 404 + rescue HTTP::ConnectionError => e + skip e.to_s end protected diff --git a/test/unit/nicknym/source_test.rb b/test/unit/nicknym/source_test.rb index cddb7c2..f8c9b60 100644 --- a/test/unit/nicknym/source_test.rb +++ b/test/unit/nicknym/source_test.rb @@ -20,11 +20,6 @@ class NicknymSourceTest < Minitest::Test refute available_on?(200, 'blablabla') end - def test_failing_network_means_no_nicknym - failing_network - refute source.available_for?('remote.tld') - end - def test_proxy_successful_query assert proxies_query_response?(200, 'dummy body') end @@ -52,12 +47,6 @@ class NicknymSourceTest < Minitest::Test return available end - def failing_network - def adapter.get(*args) - raise HTTP::ConnectionError - end - end - def source Nickserver::Nicknym::Source.new(adapter) end |