diff options
author | azul <azul@riseup.net> | 2016-09-16 10:23:25 +0000 |
---|---|---|
committer | azul <azul@riseup.net> | 2016-09-16 10:23:25 +0000 |
commit | c9f785d3c4adb780bd61d8f5e3fd6414915cca0a (patch) | |
tree | 9ec4a4af2a3dcae4beccb3eb2a32856a69529c20 /test/remote/nicknym_source_test.rb | |
parent | ec875169b0231d84bb8c55bbe91c52b896561f1e (diff) | |
parent | f5bf2c6554f0e541c75d90fdcf4f0095e9801d4d (diff) |
Merge branch 'feature/query-leap-servers' into 'master'
test: properly test nicknym source + fixes
See merge request !3
Diffstat (limited to 'test/remote/nicknym_source_test.rb')
-rw-r--r-- | test/remote/nicknym_source_test.rb | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/test/remote/nicknym_source_test.rb b/test/remote/nicknym_source_test.rb index e516895..2be7251 100644 --- a/test/remote/nicknym_source_test.rb +++ b/test/remote/nicknym_source_test.rb @@ -1,5 +1,6 @@ require 'test_helper' require 'nickserver/nicknym/source' +require 'nickserver/email_address' class RemoteNicknymSourceTest < Minitest::Test @@ -13,8 +14,23 @@ class RemoteNicknymSourceTest < Minitest::Test super end - def test_truth + def test_availablility_check assert source.available_for? 'mail.bitmask.net' + refute source.available_for? 'dl.bitmask.net' # not a provider + refute source.available_for? 'demo.bitmask.net' # provider without mx + end + + def test_successful_query + response = source.query(email_with_key) + json = JSON.parse response.content + assert_equal 200, response.status + assert_equal email_with_key.to_s, json["address"] + refute_empty json["openpgp"] + end + + def test_not_found + response = source.query(email_without_key) + assert_equal 404, response.status end protected @@ -23,5 +39,12 @@ class RemoteNicknymSourceTest < Minitest::Test @source ||= Nickserver::Nicknym::Source.new end + def email_with_key + Nickserver::EmailAddress.new('test@mail.bitmask.net') + end + + def email_without_key + Nickserver::EmailAddress.new('pleaseneverusethisemailweuseittotest@mail.bitmask.net') + end end |