aboutsummaryrefslogtreecommitdiffstats
path: root/test/plum
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2015-11-16 18:48:35 +0900
committerKazuki Yamaguchi <k@rhe.jp>2015-11-16 18:48:35 +0900
commitde62f5962e9047e867eb39ef933738ea3b9722c1 (patch)
treede71f3b397232151fb59929cd6f347c8d6598505 /test/plum
parentcae4777e2da251aeb9a8377cb19f65fa2b2e757b (diff)
downloadplum-de62f5962e9047e867eb39ef933738ea3b9722c1.tar.gz
server/connection: reorganize subclasses
* HTTPSServerConnection is renamed to SSLSocketServerConnection * HTTPServerConnection now accepts writer Proc (Method) instead of IO
Diffstat (limited to 'test/plum')
-rw-r--r--test/plum/client/test_client.rb2
-rw-r--r--test/plum/server/test_connection.rb (renamed from test/plum/server/test_https_connection.rb)10
-rw-r--r--test/plum/server/test_http_connection.rb10
3 files changed, 12 insertions, 10 deletions
diff --git a/test/plum/client/test_client.rb b/test/plum/client/test_client.rb
index 214e30f..35c0638 100644
--- a/test/plum/client/test_client.rb
+++ b/test/plum/client/test_client.rb
@@ -112,7 +112,7 @@ class ClientTest < Minitest::Test
begin
Timeout.timeout(1) {
sock = ssl_server.accept
- plum = HTTPSServerConnection.new(sock)
+ plum = ServerConnection.new(sock.method(:write))
plum.on(:stream) { |stream|
headers = data = nil
diff --git a/test/plum/server/test_https_connection.rb b/test/plum/server/test_connection.rb
index d227f73..4a45eaa 100644
--- a/test/plum/server/test_https_connection.rb
+++ b/test/plum/server/test_connection.rb
@@ -4,21 +4,21 @@ using Plum::BinaryString
class HTTPSConnectionNegotiationTest < Minitest::Test
def test_server_must_raise_cprotocol_error_invalid_magic_short
- con = HTTPSServerConnection.new(StringIO.new)
+ con = ServerConnection.new(StringIO.new.method(:write))
assert_connection_error(:protocol_error) {
con << "HELLO"
}
end
def test_server_must_raise_cprotocol_error_invalid_magic_long
- con = HTTPSServerConnection.new(StringIO.new)
+ con = ServerConnection.new(StringIO.new.method(:write))
assert_connection_error(:protocol_error) {
con << ("HELLO" * 100) # over 24
}
end
def test_server_must_raise_cprotocol_error_non_settings_after_magic
- con = HTTPSServerConnection.new(StringIO.new)
+ con = ServerConnection.new(StringIO.new.method(:write))
con << Connection::CLIENT_CONNECTION_PREFACE
assert_connection_error(:protocol_error) {
con << Frame.new(type: :window_update, stream_id: 0, payload: "".push_uint32(1)).assemble
@@ -27,7 +27,7 @@ class HTTPSConnectionNegotiationTest < Minitest::Test
def test_server_accept_fragmented_magic
magic = Connection::CLIENT_CONNECTION_PREFACE
- con = HTTPSServerConnection.new(StringIO.new)
+ con = ServerConnection.new(StringIO.new.method(:write))
assert_no_error {
con << magic[0...5]
con << magic[5..-1]
@@ -49,7 +49,7 @@ class HTTPSConnectionNegotiationTest < Minitest::Test
begin
Timeout.timeout(3) {
sock = ssl_server.accept
- plum = HTTPSServerConnection.new(sock)
+ plum = SSLSocketServerConnection.new(sock)
assert_connection_error(:inadequate_security) {
run = true
while !sock.closed? && !sock.eof?
diff --git a/test/plum/server/test_http_connection.rb b/test/plum/server/test_http_connection.rb
index bd586a5..3093d5b 100644
--- a/test/plum/server/test_http_connection.rb
+++ b/test/plum/server/test_http_connection.rb
@@ -5,7 +5,8 @@ using Plum::BinaryString
class HTTPConnectionNegotiationTest < Minitest::Test
## with Prior Knowledge (same as over TLS)
def test_server_must_raise_cprotocol_error_non_settings_after_magic
- con = HTTPServerConnection.new(StringIO.new)
+ io = StringIO.new
+ con = HTTPServerConnection.new(io.method(:write))
con << Connection::CLIENT_CONNECTION_PREFACE
assert_connection_error(:protocol_error) {
con << Frame.new(type: :window_update, stream_id: 0, payload: "".push_uint32(1)).assemble
@@ -14,7 +15,8 @@ class HTTPConnectionNegotiationTest < Minitest::Test
def test_server_accept_fragmented_magic
magic = Connection::CLIENT_CONNECTION_PREFACE
- con = HTTPServerConnection.new(StringIO.new)
+ io = StringIO.new
+ con = HTTPServerConnection.new(io.method(:write))
assert_no_error {
con << magic[0...5]
con << magic[5..-1]
@@ -25,7 +27,7 @@ class HTTPConnectionNegotiationTest < Minitest::Test
## with HTTP/1.1 Upgrade
def test_server_accept_upgrade
io = StringIO.new
- con = HTTPServerConnection.new(io)
+ con = HTTPServerConnection.new(io.method(:write))
heads = nil
con.on(:headers) {|_, _h| heads = _h.to_h }
req = "GET / HTTP/1.1\r\n" <<
@@ -47,7 +49,7 @@ class HTTPConnectionNegotiationTest < Minitest::Test
def test_server_deny_non_upgrade
io = StringIO.new
- con = HTTPServerConnection.new(io)
+ con = HTTPServerConnection.new(io.method(:write))
req = "GET / HTTP/1.1\r\n" <<
"Host: rhe.jp\r\n" <<
"User-Agent: nya\r\n" <<