summaryrefslogtreecommitdiff
path: root/test/unit/server_test.rb
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2012-12-24 02:02:24 -0800
committerelijah <elijah@riseup.net>2012-12-24 02:02:24 -0800
commit457c2bf135be68b3c49ff20d3f23a6f8507aeda5 (patch)
tree73afc8568c6a83706111b19d35ba04d0cd94b2e0 /test/unit/server_test.rb
initial commit
Diffstat (limited to 'test/unit/server_test.rb')
-rw-r--r--test/unit/server_test.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/unit/server_test.rb b/test/unit/server_test.rb
new file mode 100644
index 0000000..ba462d0
--- /dev/null
+++ b/test/unit/server_test.rb
@@ -0,0 +1,34 @@
+require File.expand_path('test_helper', File.dirname(__FILE__))
+
+class ServerTest < MiniTest::Unit::TestCase
+
+ def test_server
+ uid = 'cloudadmin@leap.se'
+ key_id = 'E818C478D3141282F7590D29D041EB11B1647490'
+ stub_vindex_response(uid, :body => file_content(:leap_vindex_result))
+ stub_get_response(key_id, :body => file_content(:leap_public_key))
+
+ EM.run do
+ EM.start_server '0.0.0.0', Nickserver::Config.port, Nickserver::Server
+
+ params = {:query => {}, :path => "key/#{CGI.escape(uid)}"}
+ http = EventMachine::HttpRequest.new("http://localhost:#{Nickserver::Config.port}").get(params)
+ http.callback {
+ assert_equal file_content(:leap_public_key), http.response
+ EM.stop
+ }.errback {
+ puts http.error
+ EM.stop
+ }
+
+ #socket = EM.connect('0.0.0.0', Nickserver::Config.port, TestSocketClient)
+ #socket.onopen = lambda {
+ # server.players.size.should == 1
+ # socket.data.last.chomp.should == "READY"
+ # EM.stop
+ #}
+ end
+ end
+
+end
+