summaryrefslogtreecommitdiff
path: root/test/remote/wkd_source_test.rb
diff options
context:
space:
mode:
authorazul <azul@riseup.net>2017-09-23 15:11:20 +0000
committerazul <azul@riseup.net>2017-09-23 15:11:20 +0000
commitfac140a8ff76e98c275194845125d4c97f4ba07b (patch)
tree08ffafb2c70935892e975704911080b9da84e391 /test/remote/wkd_source_test.rb
parent787287318c54b019a12ef79525c9f5b10d93724d (diff)
parent8ac6bb8492c9a3b9ec5d7b5bf2b35907a1f8c332 (diff)
Merge branch 'rubocop' into 'master'
Style fixes based on Rubocop See merge request leap/nickserver!19
Diffstat (limited to 'test/remote/wkd_source_test.rb')
-rw-r--r--test/remote/wkd_source_test.rb43
1 files changed, 43 insertions, 0 deletions
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