summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzul <azul@riseup.net>2016-06-11 10:20:06 +0200
committerAzul <azul@riseup.net>2016-06-11 10:20:06 +0200
commit92c86fc4e1e6dcb86793992e69dfd0608c118c9a (patch)
treed91707d8193ad90848370aa415b65d7218d148bf
parent10a57e4f92432ff2b82c4a6bb5027bb3bcbdfab9 (diff)
use the adapter not EM in hkp source
-rw-r--r--lib/nickserver/hkp/source.rb19
-rw-r--r--test/integration/hkp_test.rb3
2 files changed, 11 insertions, 11 deletions
diff --git a/lib/nickserver/hkp/source.rb b/lib/nickserver/hkp/source.rb
index 1dd386d..48a63d8 100644
--- a/lib/nickserver/hkp/source.rb
+++ b/lib/nickserver/hkp/source.rb
@@ -22,23 +22,22 @@ module Nickserver; module Hkp
}
end
+ protected
+
+ attr_reader :adapter
+
#
# fetches ascii armored OpenPGP public key from the keyserver
#
def get_key_by_fingerprint(nick, key_id)
params = {op: 'get', search: "0x" + key_id, exact: 'on', options: 'mr'}
- http = EventMachine::HttpRequest.new(Config.hkp_url).get(query: params)
- http.callback {
- status = http.response_header.status
- if status != 200
- yield Nickserver::Response.new status, "HKP Request failed"
+ adapter.get Config.hkp_url, query: params do |status, response|
+ if status == 200
+ yield Response.new nick, response
else
- yield Response.new nick, http.response
+ yield Nickserver::Response.new status, "HKP Request failed"
end
- }
- http.errback {
- yield Nickserver::Response.new 500, http.error
- }
+ end
end
protected
diff --git a/test/integration/hkp_test.rb b/test/integration/hkp_test.rb
index 0410c4a..3988fa5 100644
--- a/test/integration/hkp_test.rb
+++ b/test/integration/hkp_test.rb
@@ -1,5 +1,6 @@
require 'test_helper'
require 'nickserver/hkp/source'
+require 'nickserver/adapters/em_http'
class HkpTest < Minitest::Test
@@ -111,7 +112,7 @@ class HkpTest < Minitest::Test
def assert_response_for_uid(uid, &block)
EM.run do
- Nickserver::Hkp::Source.new(nil).query(uid, &block)
+ Nickserver::Hkp::Source.new(Nickserver::Adapters::EmHttp.new).query(uid, &block)
EM.stop
end
end