summaryrefslogtreecommitdiff
path: root/test/remote/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/remote/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/remote/nicknym_source_test.rb')
-rw-r--r--test/remote/nicknym_source_test.rb15
1 files changed, 13 insertions, 2 deletions
diff --git a/test/remote/nicknym_source_test.rb b/test/remote/nicknym_source_test.rb
index 4ca3033..b97f2b2 100644
--- a/test/remote/nicknym_source_test.rb
+++ b/test/remote/nicknym_source_test.rb
@@ -10,13 +10,24 @@ require 'nickserver/email_address'
class RemoteNicknymSourceTest < CelluloidTest
include HttpAdapterHelper
- def test_availablility_check
+ def test_available_for_mail
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
+ # not a provider
+ def test_not_available
+ refute source.available_for? 'dl.bitmask.net'
+ rescue HTTP::ConnectionError => e
+ skip e.to_s
+ end
+
+ # cs.ucl.ac.uk only has an MX not an A-record
+ def test_not_available_without_a_record
+ refute source.available_for? 'cs.ucl.ac.uk'
+ end
+
def test_successful_query
response = source.query(email_with_key)
skip if response.status == 404