summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAzul <azul@riseup.net>2016-05-25 12:51:47 +0200
committerAzul <azul@riseup.net>2016-05-25 12:51:47 +0200
commitb883fa9e91ffd7c526a17f37df54ef63c5c6a4b8 (patch)
tree2291052d1a0bf5eadae43969aa915af44855a0aa /test
parent69f9b2cb51ff3b9fb3de39f657f734e507ccec68 (diff)
rubocop: initialize and use ruby 1.9 hash syntax
Diffstat (limited to 'test')
-rw-r--r--test/test_helper.rb12
-rw-r--r--test/unit/hkp_test.rb16
-rw-r--r--test/unit/nickserver_test.rb24
3 files changed, 26 insertions, 26 deletions
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 7fbe400..d4765bc 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -15,7 +15,7 @@ class Minitest::Test
Nickserver::Config.load
# by default, mock all non-localhost network connections
- WebMock.disable_net_connect!(:allow_localhost => true)
+ WebMock.disable_net_connect!(allow_localhost: true)
end
def file_content(filename)
@@ -35,23 +35,23 @@ class Minitest::Test
end
def stub_sks_vindex_reponse(uid, opts = {})
- options = {:status => 200, :body => ""}.merge(opts)
+ options = {status: 200, body: ""}.merge(opts)
stub_http_request(:get, Nickserver::Config.hkp_url).with(
- :query => {:op => 'vindex', :search => uid, :exact => 'on', :options => 'mr', :fingerprint => 'on'}
+ query: {op: 'vindex', search: uid, exact: 'on', options: 'mr', fingerprint: 'on'}
).to_return(options)
end
def stub_sks_get_reponse(key_id, opts = {})
- options = {:status => 200, :body => ""}.merge(opts)
+ options = {status: 200, body: ""}.merge(opts)
stub_http_request(:get, Nickserver::Config.hkp_url).with(
- :query => {:op => 'get', :search => "0x"+key_id, :exact => 'on', :options => 'mr'}
+ query: {op: 'get', search: "0x"+key_id, exact: 'on', options: 'mr'}
).to_return(options)
end
def stub_couch_response(uid, opts = {})
# can't stub localhost, so set couch_host to anything else
Nickserver::Config.stub :couch_host, 'notlocalhost' do
- options = {:status => 200, :body => ""}.merge(opts)
+ options = {status: 200, body: ""}.merge(opts)
query = "\?key=#{"%22#{uid}%22"}&reduce=false"
stub_http_request(:get, /#{Regexp.escape(Nickserver::Couch::FetchKey.couch_url)}.*#{query}/).to_return(options)
yield
diff --git a/test/unit/hkp_test.rb b/test/unit/hkp_test.rb
index f3cdc95..f23fe72 100644
--- a/test/unit/hkp_test.rb
+++ b/test/unit/hkp_test.rb
@@ -28,7 +28,7 @@ class HkpTest < Minitest::Test
def test_key_info_not_found
uid = 'leaping_lemur@leap.se'
- stub_sks_vindex_reponse(uid, :status => 404)
+ stub_sks_vindex_reponse(uid, status: 404)
test_em_errback "Nickserver::HKP::FetchKeyInfo.new.search '#{uid}'" do |error|
assert_equal 404, error
end
@@ -36,7 +36,7 @@ class HkpTest < Minitest::Test
def test_no_matching_key_found
uid = 'leaping_lemur@leap.se'
- stub_sks_vindex_reponse(uid, :status => 200)
+ stub_sks_vindex_reponse(uid, status: 200)
test_em_errback "Nickserver::HKP::FetchKeyInfo.new.search '#{uid}'" do |error|
assert_equal 404, error
end
@@ -45,8 +45,8 @@ class HkpTest < Minitest::Test
def test_fetch_key
uid = 'cloudadmin@leap.se'
key_id = 'E818C478D3141282F7590D29D041EB11B1647490'
- stub_sks_vindex_reponse(uid, :body => file_content(:leap_vindex_result))
- stub_sks_get_reponse(key_id, :body => file_content(:leap_public_key))
+ stub_sks_vindex_reponse(uid, body: file_content(:leap_vindex_result))
+ stub_sks_get_reponse(key_id, body: file_content(:leap_public_key))
test_em_callback "Nickserver::HKP::FetchKey.new.get '#{uid}'" do |key_text|
assert_equal file_content(:leap_public_key), key_text
@@ -57,8 +57,8 @@ class HkpTest < Minitest::Test
uid = 'cloudadmin@leap.se'
key_id = 'E818C478D3141282F7590D29D041EB11B1647490'
- stub_sks_vindex_reponse(uid, :body => file_content(:leap_vindex_result))
- stub_sks_get_reponse(key_id, :status => 404)
+ stub_sks_vindex_reponse(uid, body: file_content(:leap_vindex_result))
+ stub_sks_get_reponse(key_id, status: 404)
test_em_errback "Nickserver::HKP::FetchKey.new.get '#{uid}'" do |error|
assert_equal 404, error
@@ -69,7 +69,7 @@ class HkpTest < Minitest::Test
uid = 'chiiph@leap.se'
key_id = '9A753A6B'
- stub_sks_vindex_reponse(uid, :body => file_content(:short_key_vindex_result))
+ stub_sks_vindex_reponse(uid, body: file_content(:short_key_vindex_result))
test_em_errback "Nickserver::HKP::FetchKey.new.get '#{uid}'" do |error|
assert_equal 500, error
end
@@ -156,7 +156,7 @@ class HkpTest < Minitest::Test
end
def fetch_key_info(body_source, uid, &block)
- stub_sks_vindex_reponse(uid, :body => file_content(body_source))
+ stub_sks_vindex_reponse(uid, body: file_content(body_source))
test_em_callback "Nickserver::HKP::FetchKeyInfo.new.search '#{uid}'", &block
end
diff --git a/test/unit/nickserver_test.rb b/test/unit/nickserver_test.rb
index c74d3d8..65ade8c 100644
--- a/test/unit/nickserver_test.rb
+++ b/test/unit/nickserver_test.rb
@@ -19,11 +19,11 @@ class NickserverTest < Minitest::Test
def test_GET_served_via_SKS
uid = 'cloudadmin@leap.se'
key_id = 'E818C478D3141282F7590D29D041EB11B1647490'
- stub_sks_vindex_reponse(uid, :body => file_content(:leap_vindex_result))
- stub_sks_get_reponse(key_id, :body => file_content(:leap_public_key))
+ stub_sks_vindex_reponse(uid, body: file_content(:leap_vindex_result))
+ 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 |http|
assert_equal file_content(:leap_public_key), JSON.parse(http.response)["openpgp"]
stop
@@ -34,11 +34,11 @@ class NickserverTest < Minitest::Test
def test_POST_served_via_SKS
uid = 'cloudadmin@leap.se'
key_id = 'E818C478D3141282F7590D29D041EB11B1647490'
- stub_sks_vindex_reponse(uid, :body => file_content(:leap_vindex_result))
- stub_sks_get_reponse(key_id, :body => file_content(:leap_public_key))
+ stub_sks_vindex_reponse(uid, body: file_content(:leap_vindex_result))
+ stub_sks_get_reponse(key_id, body: file_content(:leap_public_key))
start do
- params = {:body => {"address" => uid}}
+ params = {body: {"address" => uid}}
post(params) do |http|
assert_equal file_content(:leap_public_key), JSON.parse(http.response)["openpgp"]
stop
@@ -49,9 +49,9 @@ class NickserverTest < Minitest::Test
def test_GET_served_via_couch_not_found
domain = "example.org"
uid = "bananas@" + domain
- stub_couch_response(uid, :status => 404) do
+ 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 |http|
assert_equal 404, http.response_header.status
stop
@@ -63,9 +63,9 @@ class NickserverTest < Minitest::Test
def test_GET_served_via_couch_empty_results
domain = "example.org"
uid = "stompy@" + domain
- stub_couch_response(uid, :body => file_content(:empty_couchdb_result)) do
+ 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 |http|
assert_equal 404, http.response_header.status
stop
@@ -77,9 +77,9 @@ class NickserverTest < Minitest::Test
def test_GET_served_via_couch_success
domain = "example.org"
uid = "blue@" + domain
- stub_couch_response(uid, :body => file_content(:blue_couchdb_result)) do
+ 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 |http|
assert_equal file_content(:blue_nickserver_result), http.response
stop