summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/integration/dispatcher_test.rb6
-rw-r--r--test/integration/nicknym_test.rb11
-rw-r--r--test/support/client_integration_test.rb13
-rw-r--r--test/unit/error_response_test.rb12
-rw-r--r--test/unit/nicknym/source_test.rb14
-rw-r--r--test/unit/response_test.rb7
6 files changed, 57 insertions, 6 deletions
diff --git a/test/integration/dispatcher_test.rb b/test/integration/dispatcher_test.rb
index 4ec823b..60ad9d7 100644
--- a/test/integration/dispatcher_test.rb
+++ b/test/integration/dispatcher_test.rb
@@ -38,10 +38,10 @@ class Nickserver::DispatcherTest < Minitest::Test
handle fingerprint: ['E36E738D69173C13D709E44F2F455E2824D18DDF']
source = Minitest::Mock.new
source.expect :get_key_by_fingerprint,
- Nickserver::Response.new(200, "fake fingerprint"),
+ Nickserver::Response.new(200, "fake key response"),
['E36E738D69173C13D709E44F2F455E2824D18DDF']
Nickserver::Hkp::Source.stub :new, source do
- assert_response status: 200, content: "200 fake fingerprint"
+ assert_response status: 200, content: "fake key response"
end
end
@@ -62,7 +62,7 @@ class Nickserver::DispatcherTest < Minitest::Test
source = Minitest::Mock.new
source.expect :query, Nickserver::Response.new(200, "fake content"), [Nickserver::EmailAddress]
Nickserver::Hkp::Source.stub :new, source do
- assert_response status: 200, content: "200 fake content"
+ assert_response status: 200, content: "fake content"
end
end
diff --git a/test/integration/nicknym_test.rb b/test/integration/nicknym_test.rb
new file mode 100644
index 0000000..bfcd7e1
--- /dev/null
+++ b/test/integration/nicknym_test.rb
@@ -0,0 +1,11 @@
+require 'test_helper'
+require 'support/client_integration_test'
+require 'nickserver/nicknym/source'
+
+class NicknymClientTest < ClientIntegrationTest
+
+ def test_truth
+ assert true
+ end
+
+end
diff --git a/test/support/client_integration_test.rb b/test/support/client_integration_test.rb
new file mode 100644
index 0000000..b05db73
--- /dev/null
+++ b/test/support/client_integration_test.rb
@@ -0,0 +1,13 @@
+class ClientIntegrationTest
+
+ def setup
+ super
+ Celluloid.boot
+ end
+
+ def teardown
+ Celluloid.shutdown
+ super
+ end
+
+end
diff --git a/test/unit/error_response_test.rb b/test/unit/error_response_test.rb
new file mode 100644
index 0000000..7242b38
--- /dev/null
+++ b/test/unit/error_response_test.rb
@@ -0,0 +1,12 @@
+require 'test_helper'
+require 'nickserver/error_response'
+
+class ErrorResponseTest < Minitest::Test
+
+ def test_content
+ 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/nicknym/source_test.rb b/test/unit/nicknym/source_test.rb
index 586dc0e..41f5ac0 100644
--- a/test/unit/nicknym/source_test.rb
+++ b/test/unit/nicknym/source_test.rb
@@ -1,5 +1,6 @@
require 'test_helper'
require 'nickserver/nicknym/source'
+require 'nickserver/email_address'
class NicknymSourceTest < Minitest::Test
@@ -21,6 +22,15 @@ class NicknymSourceTest < Minitest::Test
adapter.verify
end
+ def test_successful_query
+ adapter.expect :get, [200, 'dummy body'],
+ ['https://nicknym.leap_powered.tld', address: email_stub.to_s]
+ response = source.query(email_stub)
+ assert_equal 200, response.status
+ assert_equal 'dummy body', response.content
+ adapter.verify
+ end
+
protected
def source
@@ -30,4 +40,8 @@ class NicknymSourceTest < Minitest::Test
def adapter
@adapter ||= Minitest::Mock.new
end
+
+ def email_stub
+ @email_stub ||= Nickserver::EmailAddress.new 'test@leap_powered.tld'
+ end
end
diff --git a/test/unit/response_test.rb b/test/unit/response_test.rb
index 8a53066..ac7a3a8 100644
--- a/test/unit/response_test.rb
+++ b/test/unit/response_test.rb
@@ -3,9 +3,10 @@ require 'nickserver/response'
class ResponseTest < Minitest::Test
- def test_content
- response = Nickserver::Response.new 500, "Not a valid address"
- assert_equal "500 Not a valid address", response.content
+ def test_ok_response
+ response = Nickserver::Response.new 200, "content"
+ assert_equal "content", response.content
+ assert_equal 200, response.status
end
end