diff options
author | Azul <azul@riseup.net> | 2017-09-22 15:30:40 +0200 |
---|---|---|
committer | Azul <azul@riseup.net> | 2017-09-23 16:53:27 +0200 |
commit | 22c6c80310a8d3d3abbd1006598b4fbaec98ffd0 (patch) | |
tree | 23bcd565750f68c3ffb644c30be06138b4c3e341 /test/remote | |
parent | 787287318c54b019a12ef79525c9f5b10d93724d (diff) |
wkd: implement basic lookup of keys through wkd
wkd is the web key directory. See the Readme.md in
/lib/nickserver/wkd
Diffstat (limited to 'test/remote')
-rw-r--r-- | test/remote/hkp_source_test.rb | 8 | ||||
-rw-r--r-- | test/remote/wkd_source_test.rb | 43 |
2 files changed, 46 insertions, 5 deletions
diff --git a/test/remote/hkp_source_test.rb b/test/remote/hkp_source_test.rb index ff61513..c246097 100644 --- a/test/remote/hkp_source_test.rb +++ b/test/remote/hkp_source_test.rb @@ -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/wkd_source_test.rb b/test/remote/wkd_source_test.rb new file mode 100644 index 0000000..acb6759 --- /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' + email = Nickserver::EmailAddress.new uid + end + + def source + Nickserver::Wkd::Source.new adapter + end +end |