From ec875169b0231d84bb8c55bbe91c52b896561f1e Mon Sep 17 00:00:00 2001 From: Azul Date: Mon, 12 Sep 2016 16:34:25 +0200 Subject: test: separate remote tests into own directory Dropped the webmock dependency. We have our own http adapter. So we can stub that to inject a mock. As an added bonus this does not mess with other http requests. Also wrote down testing strategy. Not completely implemented yet. --- test/remote/hkp_source_test.rb | 49 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 test/remote/hkp_source_test.rb (limited to 'test/remote/hkp_source_test.rb') diff --git a/test/remote/hkp_source_test.rb b/test/remote/hkp_source_test.rb new file mode 100644 index 0000000..aabc4d3 --- /dev/null +++ b/test/remote/hkp_source_test.rb @@ -0,0 +1,49 @@ +require 'test_helper' +require 'nickserver/hkp/source' + +class RemoteHkpSourceTest < Minitest::Test + + def setup + super + Celluloid.boot + end + + def teardown + Celluloid.shutdown + super + end + + def test_key_info + uid = 'elijah@riseup.net' + assert_key_info_for_uid uid do |keys| + assert_equal 1, keys.size + assert keys.first.keyid =~ /00440025$/ + end + end + + def test_tls_validation + hkp_url = 'https://keys.mayfirst.org/pks/lookup' + ca_file = file_path('mayfirst-ca.pem') + + config.stub(:hkp_url, hkp_url) 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| + assert_equal 1, keys.size + assert keys.first.keyid =~ /00440025$/ + end + end + end + end + + protected + + def assert_key_info_for_uid(uid, &block) + Nickserver::Hkp::Source.new.search uid do |status, keys| + assert_equal 200, status + yield keys + end + end +end -- cgit v1.2.3