summaryrefslogtreecommitdiff
path: root/test/integration/hkp_test.rb
diff options
context:
space:
mode:
authorazul <azul@riseup.net>2017-11-07 08:20:41 -0800
committerazul <azul@riseup.net>2017-11-07 08:20:41 -0800
commita43e647663100b7a5117008641765d3508edbe5b (patch)
tree6e415b50e29d8c36f84c0d477fe12b3ee2ee1123 /test/integration/hkp_test.rb
parentfac140a8ff76e98c275194845125d4c97f4ba07b (diff)
parent85a567286cf61a3a8193c339dd0967116d79299c (diff)
Merge branch 'refactor/clarify-response' into 'master'
Refactor/clarify response See merge request leap/nickserver!20
Diffstat (limited to 'test/integration/hkp_test.rb')
-rw-r--r--test/integration/hkp_test.rb34
1 files changed, 12 insertions, 22 deletions
diff --git a/test/integration/hkp_test.rb b/test/integration/hkp_test.rb
index c12588c..f6675e9 100644
--- a/test/integration/hkp_test.rb
+++ b/test/integration/hkp_test.rb
@@ -33,7 +33,7 @@ class HkpTest < Minitest::Test
stubbing_http do
uid = 'leaping_lemur@leap.se'
stub_sks_vindex_reponse(uid, status: 404)
- assert_response_status_for_uid uid, 404
+ assert_nil response_for_uid(uid)
end
end
@@ -41,7 +41,7 @@ class HkpTest < Minitest::Test
stubbing_http do
uid = 'leaping_lemur@leap.se'
stub_sks_vindex_reponse(uid, status: 200)
- assert_response_status_for_uid uid, 404
+ assert_nil response_for_uid(uid)
end
end
@@ -51,10 +51,9 @@ class HkpTest < Minitest::Test
stubbing_http do
stub_sks_vindex_reponse(uid, body: file_content(:leap_vindex_result))
stub_sks_get_reponse(key_id, body: file_content(:leap_public_key))
- assert_response_for_uid(uid) do |response|
- content = JSON.parse response.content
- assert_equal file_content(:leap_public_key), content['openpgp']
- end
+ response = response_for_uid(uid)
+ content = JSON.parse response.content
+ assert_equal file_content(:leap_public_key), content['openpgp']
end
end
@@ -65,7 +64,7 @@ class HkpTest < Minitest::Test
stubbing_http do
stub_sks_vindex_reponse(uid, body: file_content(:leap_vindex_result))
stub_sks_get_reponse(key_id, status: 404)
- assert_response_status_for_uid uid, 404
+ assert_equal 404, response_for_uid(uid).status
end
end
@@ -74,29 +73,20 @@ class HkpTest < Minitest::Test
stubbing_http do
stub_sks_vindex_reponse(uid, body: file_content(:short_key_vindex_result))
- assert_response_status_for_uid uid, 500
+ assert_equal 500, response_for_uid(uid).status
end
end
protected
- def assert_response_status_for_uid(uid, status)
- assert_response_for_uid(uid) do |response|
- assert_equal status, response.status
- end
- end
-
- def assert_response_for_uid(uid)
- Nickserver::Hkp::Source.new(adapter).query uid do |response|
- yield response
- end
+ def response_for_uid(uid)
+ Nickserver::Hkp::Source.new(adapter).query uid
end
def assert_key_info_for_uid(uid)
- Nickserver::Hkp::Source.new(adapter).search uid do |status, keys|
- assert_equal 200, status
- yield keys
- end
+ status, keys = Nickserver::Hkp::Source.new(adapter).search uid
+ assert_equal 200, status
+ yield keys
end
def fetch_key_info(body_source, uid, &block)