summaryrefslogtreecommitdiff
path: root/test/unit
diff options
context:
space:
mode:
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/adapters/http_test.rb3
-rw-r--r--test/unit/couch_db/response_test.rb12
-rw-r--r--test/unit/couch_db/source_unit_test.rb9
-rw-r--r--test/unit/email_address_test.rb2
-rw-r--r--test/unit/error_response_test.rb4
-rw-r--r--test/unit/handler_chain_test.rb11
-rw-r--r--test/unit/hkp/client_test.rb22
-rw-r--r--test/unit/hkp/v_index_response_test.rb2
-rw-r--r--test/unit/logging_responder_test.rb6
-rw-r--r--test/unit/nicknym/source_test.rb7
-rw-r--r--test/unit/request_handlers/local_email_handler_test.rb1
-rw-r--r--test/unit/request_test.rb7
-rw-r--r--test/unit/response_test.rb6
-rw-r--r--test/unit/test_helper.rb1
-rw-r--r--test/unit/wkd/url_test.rb19
-rw-r--r--test/unit/zbase_test.rb3
16 files changed, 55 insertions, 60 deletions
diff --git a/test/unit/adapters/http_test.rb b/test/unit/adapters/http_test.rb
index f6768df..5bf3468 100644
--- a/test/unit/adapters/http_test.rb
+++ b/test/unit/adapters/http_test.rb
@@ -3,7 +3,6 @@ require 'http'
require 'nickserver/adapters/http'
class HttpAdapterTest < Minitest::Test
-
def test_normal_raise
stub_http_to_raise do
assert_raises HTTP::ConnectionError do
@@ -29,7 +28,7 @@ class HttpAdapterTest < Minitest::Test
protected
def stub_http_to_raise(&block)
- raises_exception = -> (*_args) {
+ raises_exception = lambda { |*_args|
raise HTTP::ConnectionError, 'for some reason'
}
HTTP.stub :get, raises_exception, &block
diff --git a/test/unit/couch_db/response_test.rb b/test/unit/couch_db/response_test.rb
index d44760d..3003307 100644
--- a/test/unit/couch_db/response_test.rb
+++ b/test/unit/couch_db/response_test.rb
@@ -6,20 +6,20 @@ class Nickserver::CouchDB::ResponseTest < Minitest::Test
include FileContent
def test_404
- response = response_for "bananas@example.org",
- status: 404, body: "{}"
+ response = response_for 'bananas@example.org',
+ status: 404, body: '{}'
assert_equal 404, response.status
end
def test_200_with_empty_response
- response = response_for "stompy@example.org",
- status: 200, body: file_content(:empty_couchdb_result)
+ response = response_for 'stompy@example.org',
+ status: 200, body: file_content(:empty_couchdb_result)
assert_equal 404, response.status
end
def test_200_with_success
- response = response_for "blue@example.org",
- status: 200, body: file_content(:blue_couchdb_result)
+ response = response_for 'blue@example.org',
+ status: 200, body: file_content(:blue_couchdb_result)
assert_equal 200, response.status
assert_equal file_content(:blue_nickserver_result), response.content
end
diff --git a/test/unit/couch_db/source_unit_test.rb b/test/unit/couch_db/source_unit_test.rb
index e5a4f43..d14ff2f 100644
--- a/test/unit/couch_db/source_unit_test.rb
+++ b/test/unit/couch_db/source_unit_test.rb
@@ -3,21 +3,20 @@ require 'nickserver/couch_db/source'
module Nickserver::CouchDB
class SourceUnitTest < Minitest::Test
-
def test_query
- address = "nick@domain.tl"
+ address = 'nick@domain.tl'
adapter = Minitest::Mock.new
adapter.expect :get, [200, nil],
- [String, {query: { reduce: "false", key: "\"#{address}\"" }}]
+ [String, { query: { reduce: 'false', key: "\"#{address}\"" } }]
Source.new(adapter).query address
adapter.verify
end
def test_401
- address = "nick@domain.tl"
+ address = 'nick@domain.tl'
adapter = Minitest::Mock.new
adapter.expect :get, [401, nil],
- [String, {query: { reduce: "false", key: "\"#{address}\"" }}]
+ [String, { query: { reduce: 'false', key: "\"#{address}\"" } }]
assert_raises Error do
Source.new(adapter).query address
end
diff --git a/test/unit/email_address_test.rb b/test/unit/email_address_test.rb
index 2fea65d..983e979 100644
--- a/test/unit/email_address_test.rb
+++ b/test/unit/email_address_test.rb
@@ -2,7 +2,6 @@ require 'test_helper'
require 'nickserver/email_address'
class EmailAddressTest < Minitest::Test
-
def test_domain
nick = Nickserver::EmailAddress.new 'nick@test.me'
assert_equal 'test.me', nick.domain
@@ -24,5 +23,4 @@ class EmailAddressTest < Minitest::Test
nick = Nickserver::EmailAddress.new 'asdf'
assert nick.invalid?
end
-
end
diff --git a/test/unit/error_response_test.rb b/test/unit/error_response_test.rb
index 7242b38..5b81e46 100644
--- a/test/unit/error_response_test.rb
+++ b/test/unit/error_response_test.rb
@@ -2,11 +2,9 @@ require 'test_helper'
require 'nickserver/error_response'
class ErrorResponseTest < Minitest::Test
-
def test_content
- response = Nickserver::ErrorResponse.new "Not a valid address"
+ response = Nickserver::ErrorResponse.new 'Not a valid address'
assert_equal "500 Not a valid address\n", response.content
assert_equal 500, response.status
end
-
end
diff --git a/test/unit/handler_chain_test.rb b/test/unit/handler_chain_test.rb
index fae0418..1d79f18 100644
--- a/test/unit/handler_chain_test.rb
+++ b/test/unit/handler_chain_test.rb
@@ -2,7 +2,6 @@ require 'test_helper'
require 'nickserver/handler_chain'
class HandlerChainTest < Minitest::Test
-
def test_initialization
assert chain
end
@@ -12,14 +11,14 @@ class HandlerChainTest < Minitest::Test
end
def test_triggering_handlers
- handler_mock.expect :call, nil, [:a, :b]
+ handler_mock.expect :call, nil, %i[a b]
chain handler_mock
chain.handle :a, :b
handler_mock.verify
end
def test_returns_handler_result
- chain handler_with_nil, handler_with_result
+ chain handler_with_nil, handler_with_result
assert_equal :result, chain.handle
end
@@ -55,14 +54,14 @@ class HandlerChainTest < Minitest::Test
end
def handler_with_nil
- Proc.new {}
+ proc {}
end
def handler_with_result
- Proc.new { :result }
+ proc { :result }
end
def handler_raising(exception = RuntimeError)
- Proc.new { raise exception }
+ proc { raise exception }
end
end
diff --git a/test/unit/hkp/client_test.rb b/test/unit/hkp/client_test.rb
index 9784d0a..8941c5e 100644
--- a/test/unit/hkp/client_test.rb
+++ b/test/unit/hkp/client_test.rb
@@ -3,22 +3,21 @@ require 'nickserver/hkp/client'
module Nickserver::Hkp
class ClientTest < Minitest::Test
-
def test_get_key_infos_by_email
- adapter_expects_query op: "vindex",
- search: email,
- options: "mr",
- fingerprint: "on",
- exact: "on"
+ adapter_expects_query op: 'vindex',
+ search: email,
+ options: 'mr',
+ fingerprint: 'on',
+ exact: 'on'
client.get_key_infos_by_email(email)
@adapter.verify
end
def test_key_by_fingerprint
- adapter_expects_query op: "get",
- search: "0x#{fingerprint}",
- options: "mr",
- exact: "on"
+ adapter_expects_query op: 'get',
+ search: "0x#{fingerprint}",
+ options: 'mr',
+ exact: 'on'
client.get_key_by_fingerprint(fingerprint)
@adapter.verify
end
@@ -34,7 +33,7 @@ module Nickserver::Hkp
def adapter_expects(*args)
@adapter = Minitest::Mock.new
@adapter.expect :get, dummy_response,
- args
+ args
end
def email
@@ -48,6 +47,5 @@ module Nickserver::Hkp
def dummy_response
[200, 'dummy_response']
end
-
end
end
diff --git a/test/unit/hkp/v_index_response_test.rb b/test/unit/hkp/v_index_response_test.rb
index d909520..270409a 100644
--- a/test/unit/hkp/v_index_response_test.rb
+++ b/test/unit/hkp/v_index_response_test.rb
@@ -7,7 +7,7 @@ class Nickserver::Hkp::VIndexResponseTest < Minitest::Test
def test_leap_public_key
response = response_for 'cloudadmin@leap.se',
- body: file_content(:leap_vindex_result)
+ body: file_content(:leap_vindex_result)
assert_equal 'E818C478D3141282F7590D29D041EB11B1647490', response.keys.first.keyid
end
diff --git a/test/unit/logging_responder_test.rb b/test/unit/logging_responder_test.rb
index bb6c4a0..9053860 100644
--- a/test/unit/logging_responder_test.rb
+++ b/test/unit/logging_responder_test.rb
@@ -3,10 +3,9 @@ require 'nickserver/logging_responder'
module Nickserver
class LoggingResponderTest < Minitest::Test
-
def test_responds_and_logs
- logger.expect :info, nil, [" -> 200"]
- respond_to 200, "body"
+ logger.expect :info, nil, [' -> 200']
+ respond_to 200, 'body'
logger.verify
end
@@ -26,6 +25,5 @@ module Nickserver
def logger
@logger ||= Minitest::Mock.new
end
-
end
end
diff --git a/test/unit/nicknym/source_test.rb b/test/unit/nicknym/source_test.rb
index b17f22b..040e0eb 100644
--- a/test/unit/nicknym/source_test.rb
+++ b/test/unit/nicknym/source_test.rb
@@ -5,7 +5,6 @@ require 'nickserver/nicknym/source'
require 'nickserver/email_address'
class NicknymSourceTest < Minitest::Test
-
def test_initialization
assert source
end
@@ -39,7 +38,7 @@ class NicknymSourceTest < Minitest::Test
def proxies_query_response?(status = 0, body = nil)
adapter.expect :get, [status, body],
- ['https://nicknym.leap_powered.tld:6425', query: {address: email_stub.to_s}]
+ ['https://nicknym.leap_powered.tld:6425', query: { address: email_stub.to_s }]
response = source.query(email_stub)
assert_equal status, response.status
assert_equal body, response.content
@@ -48,10 +47,10 @@ class NicknymSourceTest < Minitest::Test
def available_on?(*args)
adapter.expect :get, args,
- ['https://remote.tld/provider.json', Hash]
+ ['https://remote.tld/provider.json', Hash]
available = source.available_for?('remote.tld')
adapter.verify
- return available
+ available
end
def source
diff --git a/test/unit/request_handlers/local_email_handler_test.rb b/test/unit/request_handlers/local_email_handler_test.rb
index 1645451..badf3d6 100644
--- a/test/unit/request_handlers/local_email_handler_test.rb
+++ b/test/unit/request_handlers/local_email_handler_test.rb
@@ -32,5 +32,4 @@ class LocalEmailHandlerTest < MiniTest::Test
def source_class
Nickserver::CouchDB::Source
end
-
end
diff --git a/test/unit/request_test.rb b/test/unit/request_test.rb
index eee01c3..7010d9c 100644
--- a/test/unit/request_test.rb
+++ b/test/unit/request_test.rb
@@ -2,7 +2,6 @@ require 'test_helper'
require 'nickserver/request'
class Nickserver::RequestTest < Minitest::Test
-
def test_email
request = request_with_params address: fake_email
assert_equal fake_email, request.email
@@ -19,8 +18,7 @@ class Nickserver::RequestTest < Minitest::Test
end
def test_domain
- request = Nickserver::Request.new Hash.new,
- 'Host' => ' nicknym.my.domain.tld:123'
+ request = Nickserver::Request.new({}, 'Host' => ' nicknym.my.domain.tld:123')
assert_equal 'my.domain.tld', request.domain
end
@@ -29,7 +27,7 @@ class Nickserver::RequestTest < Minitest::Test
# params are encoded with strings as keys and arrays with the
# given value(s)
def request_with_params(params = {})
- params = params.collect{|k,v| [k.to_s, Array(v)]}.to_h
+ params = params.collect { |k, v| [k.to_s, Array(v)] }.to_h
Nickserver::Request.new params, {}
end
@@ -40,5 +38,4 @@ class Nickserver::RequestTest < Minitest::Test
def fake_fingerprint
'F' * 40
end
-
end
diff --git a/test/unit/response_test.rb b/test/unit/response_test.rb
index ac7a3a8..401f8ee 100644
--- a/test/unit/response_test.rb
+++ b/test/unit/response_test.rb
@@ -2,11 +2,9 @@ require 'test_helper'
require 'nickserver/response'
class ResponseTest < Minitest::Test
-
def test_ok_response
- response = Nickserver::Response.new 200, "content"
- assert_equal "content", response.content
+ response = Nickserver::Response.new 200, 'content'
+ assert_equal 'content', response.content
assert_equal 200, response.status
end
-
end
diff --git a/test/unit/test_helper.rb b/test/unit/test_helper.rb
deleted file mode 100644
index ade21a0..0000000
--- a/test/unit/test_helper.rb
+++ /dev/null
@@ -1 +0,0 @@
-require File.dirname(File.dirname(__FILE__)) + '/test_helper' \ No newline at end of file
diff --git a/test/unit/wkd/url_test.rb b/test/unit/wkd/url_test.rb
index 9bf8f64..d4e0e28 100644
--- a/test/unit/wkd/url_test.rb
+++ b/test/unit/wkd/url_test.rb
@@ -12,15 +12,30 @@ module Nickserver::Wkd
assert_equal sample_url, url.to_s
end
+ # we can be pretty sure this works for the person who proposed it
+ def test_gnupg_testuser_email
+ url = Url.new test_user_email
+ assert_equal test_user_url, url.to_s
+ end
+
protected
+ def test_user_email
+ Nickserver::EmailAddress.new 'dewey@test.gnupg.org'
+ end
+
+ def test_user_url
+ 'https://test.gnupg.org/.well-known/openpgpkey/hu/' \
+ '1g8totoxbt4zf6na1sukczp5fiewr1oe'
+ end
+
def sample_email
Nickserver::EmailAddress.new 'Joe.Doe@Example.ORG'
end
def sample_url
- 'https://example.org/.well-known/openpgpkey/' +
- 'hu/example.org/iy9q119eutrkn8s1mk4r39qejnbu3n5q'
+ 'https://example.org/.well-known/openpgpkey/hu/' \
+ 'iy9q119eutrkn8s1mk4r39qejnbu3n5q'
end
end
end
diff --git a/test/unit/zbase_test.rb b/test/unit/zbase_test.rb
index 97f0fc5..e2997a3 100644
--- a/test/unit/zbase_test.rb
+++ b/test/unit/zbase_test.rb
@@ -3,9 +3,8 @@ require 'minitest/autorun'
require 'zbase32'
class Zbase32Test < Minitest::Test
-
def test_samples
- samples.each do |k,v|
+ samples.each do |k, v|
assert_equal k, decode(v)
assert_equal v, encode(k)
end