diff options
author | Azul <azul@riseup.net> | 2016-08-27 11:25:30 +0200 |
---|---|---|
committer | Azul <azul@riseup.net> | 2016-08-29 08:59:58 +0200 |
commit | 16d77cc03068b19791e704abfc2eb14f8cd141f0 (patch) | |
tree | a6d5f0b6fbe32fed887d9506150b1082297d49d8 /test/unit | |
parent | 47343fad827ac2bef2ed7bc08768e4e58ac9a95f (diff) |
expose Request class from RequestHandler
This way we can separate the EmailHandler and the FingerprintHandler as well.
Diffstat (limited to 'test/unit')
-rw-r--r-- | test/unit/request_test.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/test/unit/request_test.rb b/test/unit/request_test.rb new file mode 100644 index 0000000..698a275 --- /dev/null +++ b/test/unit/request_test.rb @@ -0,0 +1,44 @@ +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 + end + + def test_blank_email + request = request_with_params + assert_equal nil, request.email + end + + def test_fingerprint + request = request_with_params fingerprint: fake_fingerprint + assert_equal fake_fingerprint, request.fingerprint + end + + def test_domain + request = Nickserver::Request.new Hash.new, + 'Host' => ' nicknym.my.domain.tld:123' + assert_equal 'my.domain.tld', request.domain + end + + protected + + # 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 + Nickserver::Request.new params, {} + end + + def fake_email + 'test@domain.tld' + end + + def fake_fingerprint + 'F' * 40 + end + +end |