summaryrefslogtreecommitdiff
path: root/test/integration
diff options
context:
space:
mode:
authorAzul <azul@riseup.net>2017-09-23 11:07:32 +0200
committerAzul <azul@riseup.net>2017-09-23 16:53:27 +0200
commit40916407517f4bdb75a295caf29e02d4f403349b (patch)
tree8219567c0ecdf583fdd916594ec7915ab9eb2f19 /test/integration
parent22c6c80310a8d3d3abbd1006598b4fbaec98ffd0 (diff)
style: rubocop mostly auto-correct
Diffstat (limited to 'test/integration')
-rw-r--r--test/integration/couch_db/source_test.rb2
-rw-r--r--test/integration/dispatcher_test.rb22
-rw-r--r--test/integration/hkp_test.rb7
-rw-r--r--test/integration/nickserver_test.rb35
4 files changed, 31 insertions, 35 deletions
diff --git a/test/integration/couch_db/source_test.rb b/test/integration/couch_db/source_test.rb
index cb1153e..ac237c6 100644
--- a/test/integration/couch_db/source_test.rb
+++ b/test/integration/couch_db/source_test.rb
@@ -4,7 +4,7 @@ require 'nickserver/couch_db/source'
module Nickserver::CouchDB
class SourceTest < Minitest::Test
- include FileContent
+ include FileContent
def test_couch_query_and_response
adapter = adapter_returns 200, file_content(:blue_couchdb_result)
diff --git a/test/integration/dispatcher_test.rb b/test/integration/dispatcher_test.rb
index b551e87..58aa972 100644
--- a/test/integration/dispatcher_test.rb
+++ b/test/integration/dispatcher_test.rb
@@ -13,7 +13,6 @@ require 'nickserver/dispatcher'
#
class Nickserver::DispatcherTest < Minitest::Test
-
def test_empty_query
handle
assert_response not_found
@@ -26,12 +25,12 @@ class Nickserver::DispatcherTest < Minitest::Test
def test_fingerprint_to_short
handle fingerprint: ['44F2F455E28']
- assert_response error("Fingerprint invalid: 44F2F455E28")
+ assert_response error('Fingerprint invalid: 44F2F455E28')
end
def test_fingerprint_is_not_hex
handle fingerprint: ['X36E738D69173C13Z709E44F2F455E2824D18DDX']
- assert_response error("Fingerprint invalid: X36E738D69173C13Z709E44F2F455E2824D18DDX")
+ assert_response error('Fingerprint invalid: X36E738D69173C13Z709E44F2F455E2824D18DDX')
end
def test_missing_domain
@@ -42,28 +41,28 @@ class Nickserver::DispatcherTest < Minitest::Test
end
def test_email_via_hkp
- handle address: ['valid@email.tld'], headers: { "Host" => "http://nickserver.me" }
+ handle address: ['valid@email.tld'], headers: { 'Host' => 'http://nickserver.me' }
stub_nicknym_not_available
hkp_source.expect :query, success, [Nickserver::EmailAddress]
assert_response success
end
def test_email_via_hkp_nicknym_unreachable
- handle address: ['valid@email.tld'], headers: { "Host" => "http://nickserver.me" }
+ handle address: ['valid@email.tld'], headers: { 'Host' => 'http://nickserver.me' }
stub_nicknym_raises
hkp_source.expect :query, success, [Nickserver::EmailAddress]
assert_response success
end
def test_email_not_found_hkp_nicknym_unreachable
- handle address: ['valid@email.tld'], headers: { "Host" => "http://nickserver.me" }
+ handle address: ['valid@email.tld'], headers: { 'Host' => 'http://nickserver.me' }
stub_nicknym_raises
hkp_source.expect :query, nil, [Nickserver::EmailAddress]
assert_response http_connection_error
end
def test_email_via_nicknym
- handle address: ['valid@email.tld'], headers: { "Host" => "http://nickserver.me" }
+ handle address: ['valid@email.tld'], headers: { 'Host' => 'http://nickserver.me' }
nicknym_source.expect :available_for?, true, [String]
nicknym_source.expect :query, success, [Nickserver::EmailAddress]
assert_response success
@@ -73,7 +72,7 @@ class Nickserver::DispatcherTest < Minitest::Test
handle fingerprint: ['E36E738D69173C13D709E44F2F455E2824D18DDF']
stub_nicknym_not_available
hkp_source.expect :get_key_by_fingerprint, success,
- ['E36E738D69173C13D709E44F2F455E2824D18DDF']
+ ['E36E738D69173C13D709E44F2F455E2824D18DDF']
assert_response success
end
@@ -81,7 +80,7 @@ class Nickserver::DispatcherTest < Minitest::Test
def handle(params = {})
@headers = params.delete(:headers) || {}
- @params = Hash[ params.map{ |k,v| [k.to_s, v] } ]
+ @params = Hash[params.map { |k, v| [k.to_s, v] }]
end
def assert_response(response)
@@ -115,7 +114,7 @@ class Nickserver::DispatcherTest < Minitest::Test
end
def success
- response status: 200, content: "fake content"
+ response status: 200, content: 'fake content'
end
def not_found
@@ -128,7 +127,7 @@ class Nickserver::DispatcherTest < Minitest::Test
def http_connection_error
response status: 502,
- content: JSON.dump(error: "HTTP::ConnectionError")
+ content: JSON.dump(error: 'HTTP::ConnectionError')
end
def response(options)
@@ -142,5 +141,4 @@ class Nickserver::DispatcherTest < Minitest::Test
def responder
@responder ||= Minitest::Mock.new
end
-
end
diff --git a/test/integration/hkp_test.rb b/test/integration/hkp_test.rb
index da128c2..c12588c 100644
--- a/test/integration/hkp_test.rb
+++ b/test/integration/hkp_test.rb
@@ -70,7 +70,7 @@ class HkpTest < Minitest::Test
end
def test_fetch_key_too_short
- uid = 'chiiph@leap.se'
+ uid = 'chiiph@leap.se'
stubbing_http do
stub_sks_vindex_reponse(uid, body: file_content(:short_key_vindex_result))
@@ -86,13 +86,13 @@ class HkpTest < Minitest::Test
end
end
- def assert_response_for_uid(uid, &block)
+ def assert_response_for_uid(uid)
Nickserver::Hkp::Source.new(adapter).query uid do |response|
yield response
end
end
- def assert_key_info_for_uid(uid, &block)
+ def assert_key_info_for_uid(uid)
Nickserver::Hkp::Source.new(adapter).search uid do |status, keys|
assert_equal 200, status
yield keys
@@ -105,5 +105,4 @@ class HkpTest < Minitest::Test
assert_key_info_for_uid(uid, &block)
end
end
-
end
diff --git a/test/integration/nickserver_test.rb b/test/integration/nickserver_test.rb
index 5dffcd2..fb9b952 100644
--- a/test/integration/nickserver_test.rb
+++ b/test/integration/nickserver_test.rb
@@ -33,9 +33,9 @@ class NickserverTest < CelluloidTest
stub_sks_get_reponse(key_id, body: file_content(:leap_public_key))
start do
- params = {query: {"address" => uid}}
+ params = { query: { 'address' => uid } }
get(params) do |response|
- assert_equal file_content(:leap_public_key), JSON.parse(response.to_s)["openpgp"]
+ assert_equal file_content(:leap_public_key), JSON.parse(response.to_s)['openpgp']
end
end
end
@@ -45,19 +45,19 @@ class NickserverTest < CelluloidTest
stub_sks_get_reponse(fingerprint, body: file_content(:leap_public_key))
start do
- params = {query: {"fingerprint" => fingerprint}}
+ params = { query: { 'fingerprint' => fingerprint } }
get(params) do |response|
- assert_equal file_content(:leap_public_key), JSON.parse(response.to_s)["openpgp"]
+ assert_equal file_content(:leap_public_key), JSON.parse(response.to_s)['openpgp']
end
end
end
def test_GET_served_via_couch_not_found
- domain = "example.org"
- uid = "bananas@" + domain
+ domain = 'example.org'
+ uid = 'bananas@' + domain
stub_couch_response(uid, status: 404) do
start do
- params = {query: {"address" => uid}, head: {"Host" => domain}}
+ params = { query: { 'address' => uid }, head: { 'Host' => domain } }
get(params) do |response|
assert_equal 404, response.code
end
@@ -66,11 +66,11 @@ class NickserverTest < CelluloidTest
end
def test_GET_served_via_couch_empty_results
- domain = "example.org"
- uid = "stompy@" + domain
+ domain = 'example.org'
+ uid = 'stompy@' + domain
stub_couch_response(uid, body: file_content(:empty_couchdb_result)) do
start do
- params = {query: {"address" => uid}, head: {host: domain}}
+ params = { query: { 'address' => uid }, head: { host: domain } }
get(params) do |response|
assert_equal 404, response.code
end
@@ -79,11 +79,11 @@ class NickserverTest < CelluloidTest
end
def test_GET_served_via_couch_success
- domain = "example.org"
- uid = "blue@" + domain
+ domain = 'example.org'
+ uid = 'blue@' + domain
stub_couch_response(uid, body: file_content(:blue_couchdb_result)) do
start do
- params = {query: {"address" => uid}, head: {"Host" => domain}}
+ params = { query: { 'address' => uid }, head: { 'Host' => domain } }
get(params) do |response|
assert_equal file_content(:blue_nickserver_result), response.to_s
end
@@ -104,7 +104,7 @@ class NickserverTest < CelluloidTest
#
# start nickserver
#
- def start(timeout = 1)
+ def start(_timeout = 1)
server = Nickserver::ReelServer.new '127.0.0.1', config.port
stubbing_http do
yield server
@@ -133,10 +133,9 @@ class NickserverTest < CelluloidTest
# this works because http requests to 127.0.0.1 are not stubbed, but requests to other domains are.
#
def request(method, options = {})
- response = HTTP.
- headers(options.delete(:head)).
- request method, "http://127.0.0.1:#{config.port}/", options
+ response = HTTP
+ .headers(options.delete(:head))
+ .request method, "http://127.0.0.1:#{config.port}/", options
yield response
end
-
end