summaryrefslogtreecommitdiff
path: root/test/remote
diff options
context:
space:
mode:
Diffstat (limited to 'test/remote')
-rw-r--r--test/remote/celluloid_http_test.rb1
-rw-r--r--test/remote/hkp_source_test.rb10
-rw-r--r--test/remote/nicknym_source_test.rb5
-rw-r--r--test/remote/wkd_source_test.rb43
4 files changed, 49 insertions, 10 deletions
diff --git a/test/remote/celluloid_http_test.rb b/test/remote/celluloid_http_test.rb
index da5f5d7..b315c6b 100644
--- a/test/remote/celluloid_http_test.rb
+++ b/test/remote/celluloid_http_test.rb
@@ -3,7 +3,6 @@ require 'support/celluloid_test'
require 'nickserver/adapters/celluloid_http'
class Nickserver::Adapters::CelluloidHttpTest < CelluloidTest
-
def test_https_for_hkp
url = Nickserver::Config.hkp_url
status, _body = adapter.get url
diff --git a/test/remote/hkp_source_test.rb b/test/remote/hkp_source_test.rb
index ff61513..8232dce 100644
--- a/test/remote/hkp_source_test.rb
+++ b/test/remote/hkp_source_test.rb
@@ -19,8 +19,8 @@ class RemoteHkpSourceTest < CelluloidTest
ca_file = file_path('mayfirst-ca.pem')
config.stub(:hkp_url, hkp_url) do
+ # config.stub(:hkp_ca_file, file_path('autistici-ca.pem')) do
config.stub(:hkp_ca_file, ca_file) do
- #config.stub(:hkp_ca_file, file_path('autistici-ca.pem')) do
assert File.exist?(Nickserver::Config.hkp_ca_file)
uid = 'elijah@riseup.net'
assert_key_info_for_uid uid do |keys|
@@ -34,10 +34,9 @@ class RemoteHkpSourceTest < CelluloidTest
protected
def assert_key_info_for_uid(uid)
- source.search uid do |status, keys|
- assert_equal 200, status
- yield keys
- end
+ status, keys = source.search uid
+ assert_equal 200, status
+ yield keys
rescue HTTP::ConnectionError => e
skip "could not talk to hkp server: #{e}"
end
@@ -45,5 +44,4 @@ class RemoteHkpSourceTest < CelluloidTest
def source
Nickserver::Hkp::Source.new adapter
end
-
end
diff --git a/test/remote/nicknym_source_test.rb b/test/remote/nicknym_source_test.rb
index b97f2b2..6fff1f6 100644
--- a/test/remote/nicknym_source_test.rb
+++ b/test/remote/nicknym_source_test.rb
@@ -48,8 +48,8 @@ class RemoteNicknymSourceTest < CelluloidTest
def assert_pgp_key_in(response)
json = JSON.parse response.content
- assert_equal email_with_key.to_s, json["address"]
- refute_empty json["openpgp"]
+ assert_equal email_with_key.to_s, json['address']
+ refute_empty json['openpgp']
rescue JSON::ParserError
skip "invalid json response: #{response.content}"
end
@@ -65,5 +65,4 @@ class RemoteNicknymSourceTest < CelluloidTest
def email_without_key
Nickserver::EmailAddress.new('pleaseneverusethisemailweuseittotest@mail.bitmask.net')
end
-
end
diff --git a/test/remote/wkd_source_test.rb b/test/remote/wkd_source_test.rb
new file mode 100644
index 0000000..1ed7ea5
--- /dev/null
+++ b/test/remote/wkd_source_test.rb
@@ -0,0 +1,43 @@
+require 'test_helper'
+require 'file_content'
+require 'support/celluloid_test'
+require 'support/http_adapter_helper'
+require 'nickserver/wkd/source'
+require 'nickserver/email_address'
+
+class RemoteWkdSourceTest < CelluloidTest
+ include HttpAdapterHelper
+ include FileContent
+
+ def test_existing_key
+ response = source.query email_with_key
+ assert_equal 200, response.status
+ assert_pgp_key_in response
+ end
+
+ def test_missing_key
+ uid = 'thisemaildoesnotexist@test.gnupg.org'
+ email = Nickserver::EmailAddress.new uid
+ status, body = source.query email
+ assert_nil status
+ assert_nil body
+ end
+
+ protected
+
+ def assert_pgp_key_in(response)
+ json = JSON.parse response.content
+ assert_equal email_with_key.to_s, json["address"]
+ refute_empty json["openpgp"]
+ assert_equal file_content('dewey.pgp.asc'), json['openpgp']
+ end
+
+ def email_with_key
+ uid = 'dewey@test.gnupg.org'
+ Nickserver::EmailAddress.new uid
+ end
+
+ def source
+ Nickserver::Wkd::Source.new adapter
+ end
+end