From cd1bbe970ca17034b0e380ff2996542e3af81e31 Mon Sep 17 00:00:00 2001 From: Azul Date: Mon, 29 Aug 2016 12:51:00 +0200 Subject: feature: keep trying if no Host header given So far we would error out if no host was specified in the config or the request. It's true that we can't do local lookup if we don't know our own domain. However we can still use HKP. In the future we will query leaps own API for other providers. If the host was not set in the initial request we might even proxy a request to ourselves. Providing the Host header will prevent an infinite loop in that case. --- test/integration/dispatcher_test.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'test/integration/dispatcher_test.rb') diff --git a/test/integration/dispatcher_test.rb b/test/integration/dispatcher_test.rb index 60d252b..4ec823b 100644 --- a/test/integration/dispatcher_test.rb +++ b/test/integration/dispatcher_test.rb @@ -15,16 +15,12 @@ class Nickserver::DispatcherTest < Minitest::Test def test_missing_domain handle address: ['valid@email.tld'] - assert_response status: 500, content: "500 HTTP request must include a Host header.\n" + assert_response_from_hkp end def test_email_from_hkp handle address: ['valid@email.tld'], headers: { "Host" => "http://nickserver.me" } - source = Minitest::Mock.new - source.expect :query, Nickserver::Response.new(200, "fake content"), [Nickserver::EmailAddress] - Nickserver::Hkp::Source.stub :new, source do - assert_response status: 200, content: "200 fake content" - end + assert_response_from_hkp end def test_fingerprint_to_short @@ -62,6 +58,14 @@ class Nickserver::DispatcherTest < Minitest::Test responder.verify end + def assert_response_from_hkp + source = Minitest::Mock.new + source.expect :query, Nickserver::Response.new(200, "fake content"), [Nickserver::EmailAddress] + Nickserver::Hkp::Source.stub :new, source do + assert_response status: 200, content: "200 fake content" + end + end + def dispatcher Nickserver::Dispatcher.new responder end -- cgit v1.2.3