From 22c6c80310a8d3d3abbd1006598b4fbaec98ffd0 Mon Sep 17 00:00:00 2001 From: Azul Date: Fri, 22 Sep 2017 15:30:40 +0200 Subject: wkd: implement basic lookup of keys through wkd wkd is the web key directory. See the Readme.md in /lib/nickserver/wkd --- test/remote/wkd_source_test.rb | 43 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 test/remote/wkd_source_test.rb (limited to 'test/remote/wkd_source_test.rb') 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 -- cgit v1.2.3 From 40916407517f4bdb75a295caf29e02d4f403349b Mon Sep 17 00:00:00 2001 From: Azul Date: Sat, 23 Sep 2017 11:07:32 +0200 Subject: style: rubocop mostly auto-correct --- test/remote/wkd_source_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/remote/wkd_source_test.rb') diff --git a/test/remote/wkd_source_test.rb b/test/remote/wkd_source_test.rb index acb6759..7eaab79 100644 --- a/test/remote/wkd_source_test.rb +++ b/test/remote/wkd_source_test.rb @@ -27,8 +27,8 @@ class RemoteWkdSourceTest < 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'] assert_equal file_content('dewey.pgp.asc'), json['openpgp'] end -- cgit v1.2.3 From f40ef14010af08c49810c0a6a2349072948170e6 Mon Sep 17 00:00:00 2001 From: Azul Date: Sat, 23 Sep 2017 13:43:29 +0200 Subject: style: more rubocop fixes --- test/remote/wkd_source_test.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'test/remote/wkd_source_test.rb') diff --git a/test/remote/wkd_source_test.rb b/test/remote/wkd_source_test.rb index 7eaab79..1ed7ea5 100644 --- a/test/remote/wkd_source_test.rb +++ b/test/remote/wkd_source_test.rb @@ -27,14 +27,14 @@ class RemoteWkdSourceTest < 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"] assert_equal file_content('dewey.pgp.asc'), json['openpgp'] end def email_with_key uid = 'dewey@test.gnupg.org' - email = Nickserver::EmailAddress.new uid + Nickserver::EmailAddress.new uid end def source -- cgit v1.2.3