aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.codeclimate.yml2
-rw-r--r--.gitignore6
-rw-r--r--.travis.yml21
-rw-r--r--Gemfile4
-rw-r--r--Guardfile9
-rw-r--r--README.md7
-rw-r--r--Rakefile11
-rwxr-xr-xbin/plum2
-rw-r--r--circle.yml27
-rw-r--r--examples/client/large.rb2
-rw-r--r--examples/client/synchronous.rb1
-rw-r--r--examples/client/twitter.rb2
-rw-r--r--examples/non_tls_server.rb2
-rw-r--r--examples/static_server.rb20
-rw-r--r--lib/plum.rb72
-rw-r--r--lib/plum/binary_string.rb2
-rw-r--r--lib/plum/client.rb2
-rw-r--r--lib/plum/client/client_session.rb2
-rw-r--r--lib/plum/client/connection.rb3
-rw-r--r--lib/plum/client/legacy_client_session.rb2
-rw-r--r--lib/plum/client/response.rb2
-rw-r--r--lib/plum/client/upgrade_client_session.rb2
-rw-r--r--lib/plum/connection.rb2
-rw-r--r--lib/plum/errors.rb2
-rw-r--r--lib/plum/event_emitter.rb2
-rw-r--r--lib/plum/flow_control.rb2
-rw-r--r--lib/plum/frame.rb5
-rw-r--r--lib/plum/frame/continuation.rb2
-rw-r--r--lib/plum/frame/data.rb3
-rw-r--r--lib/plum/frame/goaway.rb3
-rw-r--r--lib/plum/frame/headers.rb3
-rw-r--r--lib/plum/frame/ping.rb3
-rw-r--r--lib/plum/frame/priority.rb3
-rw-r--r--lib/plum/frame/push_promise.rb3
-rw-r--r--lib/plum/frame/rst_stream.rb3
-rw-r--r--lib/plum/frame/settings.rb3
-rw-r--r--lib/plum/frame/unknown.rb3
-rw-r--r--lib/plum/frame/window_update.rb3
-rw-r--r--lib/plum/hpack/constants.rb2
-rw-r--r--lib/plum/hpack/context.rb2
-rw-r--r--lib/plum/hpack/decoder.rb2
-rw-r--r--lib/plum/hpack/encoder.rb2
-rw-r--r--lib/plum/hpack/huffman.rb2
-rw-r--r--lib/plum/rack.rb14
-rw-r--r--lib/plum/rack/cli.rb2
-rw-r--r--lib/plum/rack/config.rb2
-rw-r--r--lib/plum/rack/dsl.rb2
-rw-r--r--lib/plum/rack/legacy_session.rb2
-rw-r--r--lib/plum/rack/listener.rb5
-rw-r--r--lib/plum/rack/server.rb2
-rw-r--r--lib/plum/rack/session.rb2
-rw-r--r--lib/plum/rack/thread_pool.rb2
-rw-r--r--lib/plum/server/connection.rb3
-rw-r--r--lib/plum/server/http_connection.rb2
-rw-r--r--lib/plum/server/ssl_socket_connection.rb2
-rw-r--r--lib/plum/stream.rb2
-rw-r--r--lib/plum/version.rb5
-rw-r--r--lib/rack/handler/plum.rb4
-rw-r--r--plum.gemspec25
-rw-r--r--test/plum/client/test_client.rb20
-rw-r--r--test/plum/client/test_connection.rb6
-rw-r--r--test/plum/client/test_decoders.rb6
-rw-r--r--test/plum/client/test_legacy_client_session.rb12
-rw-r--r--test/plum/client/test_response.rb6
-rw-r--r--test/plum/client/test_upgrade_client_session.rb6
-rw-r--r--test/plum/connection/test_handle_frame.rb9
-rw-r--r--test/plum/hpack/test_context.rb6
-rw-r--r--test/plum/hpack/test_decoder.rb4
-rw-r--r--test/plum/hpack/test_encoder.rb8
-rw-r--r--test/plum/hpack/test_huffman.rb4
-rw-r--r--test/plum/server/test_connection.rb17
-rw-r--r--test/plum/server/test_http_connection.rb7
-rw-r--r--test/plum/stream/test_handle_frame.rb7
-rw-r--r--test/plum/test_binary_string.rb4
-rw-r--r--test/plum/test_connection.rb4
-rw-r--r--test/plum/test_connection_utils.rb6
-rw-r--r--test/plum/test_error.rb4
-rw-r--r--test/plum/test_event_emitter.rb6
-rw-r--r--test/plum/test_flow_control.rb5
-rw-r--r--test/plum/test_frame.rb4
-rw-r--r--test/plum/test_frame_factory.rb6
-rw-r--r--test/plum/test_frame_utils.rb4
-rw-r--r--test/plum/test_stream.rb7
-rw-r--r--test/plum/test_stream_utils.rb4
-rw-r--r--test/server.crt19
-rw-r--r--test/server.csr16
-rw-r--r--test/server.key27
-rw-r--r--test/test_helper.rb31
-rw-r--r--test/utils.rb130
-rw-r--r--test/utils/assertions.rb3
-rw-r--r--test/utils/client.rb19
-rw-r--r--test/utils/server.rb62
92 files changed, 306 insertions, 507 deletions
diff --git a/.codeclimate.yml b/.codeclimate.yml
deleted file mode 100644
index c1e90e1..0000000
--- a/.codeclimate.yml
+++ /dev/null
@@ -1,2 +0,0 @@
-exclude_paths:
-- "examples/**/*"
diff --git a/.gitignore b/.gitignore
index 9e96c04..976235e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,3 @@
-/.bundle
-/.yardoc
-/Gemfile.lock
-/coverage
/doc
-/pkg
+/html
/tmp
diff --git a/.travis.yml b/.travis.yml
index 4eeae85..936da5c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,14 +1,13 @@
language: ruby
-addons:
- code_climate:
- repo_token: f5092ab344fac7f2de9d7332e00597642a4d24e3d560f7d7f329172a2e5a2def
+rvm:
+ - 2.3.3
+ - 2.4.0
+ - ruby-head
install:
- - echo openssl_url=https://www.openssl.org/source >> $rvm_path/user/db
- - echo openssl_version=1.0.2g >> $rvm_path/user/db
- - rvm pkg install openssl
- - $rvm_path/usr/bin/openssl version
- - rvm install ruby-head --with-openssl-dir=$rvm_path/usr
- - rvm use ruby-head
- - bundle install
+ - curl -s https://www.openssl.org/source/openssl-1.1.0c.tar.gz | tar xzvf -
+ - (cd openssl-1.1.0c && ./config --prefix=$HOME/openssl -Wl,-rpath=$HOME/openssl/lib && make -j8 && make install_sw)
+ - $HOME/openssl/bin/openssl version
+ - gem install openssl http_parser.rb rack test-unit -- --with-openssl-dir=$HOME/openssl
+ - ruby -e'gem "openssl"; require "openssl"; p OpenSSL::OPENSSL_LIBRARY_VERSION'
script:
- - bundle exec rake test
+ - rake test
diff --git a/Gemfile b/Gemfile
deleted file mode 100644
index 1ffade3..0000000
--- a/Gemfile
+++ /dev/null
@@ -1,4 +0,0 @@
-source "https://rubygems.org"
-
-# Specify your gem's dependencies in plum.gemspec
-gemspec
diff --git a/Guardfile b/Guardfile
deleted file mode 100644
index 9e48349..0000000
--- a/Guardfile
+++ /dev/null
@@ -1,9 +0,0 @@
-# frozen-string-literal: true
-
-guard :minitest, env: { "SKIP_COVERAGE" => true } do
- # with Minitest::Unit
- watch(%r{^test/(.*)\/?test_(.*)\.rb$})
- watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| ["test/#{m[1]}test_#{m[2]}.rb", "test/#{m[1]}#{m[2]}"] }
- watch(%r{^test/test_helper\.rb$}) { "test" }
- watch(%r{^test/utils/.*\.rb}) { "test" }
-end
diff --git a/README.md b/README.md
index da8cacd..6a95b0d 100644
--- a/README.md
+++ b/README.md
@@ -4,12 +4,9 @@ A pure Ruby HTTP/2 server and client implementation.
WARNING: Plum is currently under heavy development. You *will* encounter bugs when using it.
-[![Circle CI](https://circleci.com/gh/rhenium/plum.svg?style=svg)](https://circleci.com/gh/rhenium/plum) [![Build Status](https://travis-ci.org/rhenium/plum.png?branch=master)](https://travis-ci.org/rhenium/plum) [![Code Climate](https://codeclimate.com/github/rhenium/plum/badges/gpa.svg)](https://codeclimate.com/github/rhenium/plum) [![Test Coverage](https://codeclimate.com/github/rhenium/plum/badges/coverage.svg)](https://codeclimate.com/github/rhenium/plum/coverage)
-
-
## Requirements
-* Ruby 2.3
+* Ruby/OpenSSL 2.0
* OpenSSL 1.0.2 or newer
* [http_parser.rb gem](https://rubygems.org/gems/http_parser.rb) - if you need HTTP/2 without TLS or HTTP/1.1 support
* [rack gem](https://rubygems.org/gems/rack) - if you use plum as a Rack server
@@ -146,7 +143,7 @@ Of course ideas and pull requests are welcome.
## Hacking
-Clone this Git repository and run `bundle install` to install development dependencies. You can run test with `rake test`. The tests are written with Minitest.
+Clone this Git repository and install dependencies. You can run test with `rake test`. The tests runs with test-unit.
## License
diff --git a/Rakefile b/Rakefile
index f3c95ee..02f9142 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,14 +1,5 @@
-# frozen-string-literal: true
-
-require "bundler/gem_tasks"
require "rake/testtask"
-require "yard"
Rake::TestTask.new do |t|
- t.libs << "test" << "lib"
- t.pattern = "test/**/test_*.rb"
-end
-
-YARD::Rake::YardocTask.new do |t|
- t.files = ["lib/**/*.rb"]
+ t.pattern = "test/plum/**/test_*.rb"
end
diff --git a/bin/plum b/bin/plum
index ba3b7ed..37c192f 100755
--- a/bin/plum
+++ b/bin/plum
@@ -1,5 +1,5 @@
#!/usr/bin/env ruby
-$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
+
require "plum/rack"
require "plum/rack/cli"
diff --git a/circle.yml b/circle.yml
deleted file mode 100644
index 58e89b2..0000000
--- a/circle.yml
+++ /dev/null
@@ -1,27 +0,0 @@
-machine:
- environment:
- CODECLIMATE_REPO_TOKEN: f5092ab344fac7f2de9d7332e00597642a4d24e3d560f7d7f329172a2e5a2def
-dependencies:
- pre:
- - echo openssl_url=https://www.openssl.org/source >> $rvm_path/user/db
- - echo openssl_version=1.0.2g >> $rvm_path/user/db
- - rvm pkg install openssl
- - >
- case $CIRCLE_NODE_INDEX in
- 0)
- rvm install ruby-2.3.1 --with-openssl-dir=$rvm_path/usr
- rvm use ruby-2.3.1 --default
- ;;
- 0)
- rvm install ruby-head --with-openssl-dir=$rvm_path/usr
- rvm use ruby-head --default
- ;;
- esac
- override:
- - gem install bundler
- - bundle install
-test:
- override:
- - $rvm_path/usr/bin/openssl version
- - ruby -v
- - bundle exec rake test
diff --git a/examples/client/large.rb b/examples/client/large.rb
index dc4d2a6..bee5b61 100644
--- a/examples/client/large.rb
+++ b/examples/client/large.rb
@@ -1,5 +1,3 @@
-# frozen-string-literal: true
-
# client/large.rb: download 3 large files in parallel
$LOAD_PATH.unshift File.expand_path("../../../lib", __FILE__)
require "plum"
diff --git a/examples/client/synchronous.rb b/examples/client/synchronous.rb
index 6701e1e..c44e7fb 100644
--- a/examples/client/synchronous.rb
+++ b/examples/client/synchronous.rb
@@ -1,4 +1,3 @@
-# frozen-string-literal: true
# client/synchronous.rb: download 3 files in sequence
$LOAD_PATH.unshift File.expand_path("../../../lib", __FILE__)
require "plum"
diff --git a/examples/client/twitter.rb b/examples/client/twitter.rb
index e029f59..d163052 100644
--- a/examples/client/twitter.rb
+++ b/examples/client/twitter.rb
@@ -1,5 +1,3 @@
-# frozen-string-literal: true
-
# client/twitter.rb
# Twitter の User stream に(現在はサーバーが非対応のため)HTTP/1.1 を使用して接続する。
# 「にゃーん」を含むツイートを受信したら、REST API で HTTP/2 を使用して返信する。
diff --git a/examples/non_tls_server.rb b/examples/non_tls_server.rb
index 7ea7ad2..b72972c 100644
--- a/examples/non_tls_server.rb
+++ b/examples/non_tls_server.rb
@@ -1,5 +1,3 @@
-# frozen-string-literal: true
-
$LOAD_PATH << File.expand_path("../../lib", __FILE__)
require "plum"
require "socket"
diff --git a/examples/static_server.rb b/examples/static_server.rb
index 452f718..189c9e6 100644
--- a/examples/static_server.rb
+++ b/examples/static_server.rb
@@ -1,5 +1,3 @@
-# frozen-string-literal: true
-
$LOAD_PATH << File.expand_path("../../lib", __FILE__)
require "plum"
require "openssl"
@@ -26,13 +24,17 @@ ctx.alpn_select_cb = -> protocols {
raise "Client does not support HTTP/2: #{protocols}" unless protocols.include?("h2")
"h2"
}
-if ctx.respond_to?(:tmp_ecdh_callback) && !ctx.respond_to?(:set_ecdh_curves)
- ctx.tmp_ecdh_callback = -> (sock, ise, keyl) {
- OpenSSL::PKey::EC.new("prime256v1")
- }
-end
-ctx.cert = OpenSSL::X509::Certificate.new File.read(File.expand_path("../../test/server.crt", __FILE__))
-ctx.key = OpenSSL::PKey::RSA.new File.read(File.expand_path("../../test/server.key", __FILE__))
+ctx.key = OpenSSL::PKey::RSA.new(2048)
+cert = OpenSSL::X509::Certificate.new
+cert.version = 2
+cert.serial = 12345
+cert.subject = OpenSSL::X509::Name.parse_rfc2253("CN=localhost")
+cert.issuer = cert.subject
+cert.public_key = ctx.key
+cert.not_before = Time.now - 3600
+cert.not_after = Time.now + 3600
+cert.sign(ctx.key, "sha256")
+ctx.cert = cert
tcp_server = TCPServer.new("0.0.0.0", 40443)
ssl_server = OpenSSL::SSL::SSLServer.new(tcp_server, ctx)
diff --git a/lib/plum.rb b/lib/plum.rb
index fa70317..7774143 100644
--- a/lib/plum.rb
+++ b/lib/plum.rb
@@ -3,37 +3,41 @@ require "socket"
require "base64"
require "set"
require "zlib"
-require "plum/version"
-require "plum/errors"
-require "plum/binary_string"
-require "plum/event_emitter"
-require "plum/hpack/constants"
-require "plum/hpack/huffman"
-require "plum/hpack/context"
-require "plum/hpack/decoder"
-require "plum/hpack/encoder"
-require "plum/frame"
-require "plum/frame/data"
-require "plum/frame/headers"
-require "plum/frame/priority"
-require "plum/frame/rst_stream"
-require "plum/frame/settings"
-require "plum/frame/push_promise"
-require "plum/frame/ping"
-require "plum/frame/goaway"
-require "plum/frame/window_update"
-require "plum/frame/continuation"
-require "plum/frame/unknown"
-require "plum/flow_control"
-require "plum/connection"
-require "plum/stream"
-require "plum/server/connection"
-require "plum/server/ssl_socket_connection"
-require "plum/server/http_connection"
-require "plum/client"
-require "plum/client/response"
-require "plum/client/decoders"
-require "plum/client/connection"
-require "plum/client/client_session"
-require "plum/client/legacy_client_session"
-require "plum/client/upgrade_client_session"
+
+module Plum
+ VERSION = "0.3.0"
+end
+
+require_relative "plum/errors"
+require_relative "plum/binary_string"
+require_relative "plum/event_emitter"
+require_relative "plum/hpack/constants"
+require_relative "plum/hpack/huffman"
+require_relative "plum/hpack/context"
+require_relative "plum/hpack/decoder"
+require_relative "plum/hpack/encoder"
+require_relative "plum/frame"
+require_relative "plum/frame/data"
+require_relative "plum/frame/headers"
+require_relative "plum/frame/priority"
+require_relative "plum/frame/rst_stream"
+require_relative "plum/frame/settings"
+require_relative "plum/frame/push_promise"
+require_relative "plum/frame/ping"
+require_relative "plum/frame/goaway"
+require_relative "plum/frame/window_update"
+require_relative "plum/frame/continuation"
+require_relative "plum/frame/unknown"
+require_relative "plum/flow_control"
+require_relative "plum/connection"
+require_relative "plum/stream"
+require_relative "plum/server/connection"
+require_relative "plum/server/ssl_socket_connection"
+require_relative "plum/server/http_connection"
+require_relative "plum/client"
+require_relative "plum/client/response"
+require_relative "plum/client/decoders"
+require_relative "plum/client/connection"
+require_relative "plum/client/client_session"
+require_relative "plum/client/legacy_client_session"
+require_relative "plum/client/upgrade_client_session"
diff --git a/lib/plum/binary_string.rb b/lib/plum/binary_string.rb
index 02b417b..ee98b93 100644
--- a/lib/plum/binary_string.rb
+++ b/lib/plum/binary_string.rb
@@ -1,5 +1,3 @@
-# frozen-string-literal: true
-
module Plum
module BinaryString
refine String do
diff --git a/lib/plum/client.rb b/lib/plum/client.rb
index d0e6e56..fe7ea6b 100644
--- a/lib/plum/client.rb
+++ b/lib/plum/client.rb
@@ -1,5 +1,3 @@
-# frozen-string-literal: true
-
module Plum
class Client
DEFAULT_CONFIG = {
diff --git a/lib/plum/client/client_session.rb b/lib/plum/client/client_session.rb
index 88cf15b..aa4c586 100644
--- a/lib/plum/client/client_session.rb
+++ b/lib/plum/client/client_session.rb
@@ -1,5 +1,3 @@
-# frozen-string-literal: true
-
module Plum
# HTTP/2 client session.
class ClientSession
diff --git a/lib/plum/client/connection.rb b/lib/plum/client/connection.rb
index a8433c9..b5a4a2d 100644
--- a/lib/plum/client/connection.rb
+++ b/lib/plum/client/connection.rb
@@ -1,6 +1,5 @@
-# frozen-string-literal: true
-
using Plum::BinaryString
+
module Plum
class ClientConnection < Connection
def initialize(writer, local_settings = {})
diff --git a/lib/plum/client/legacy_client_session.rb b/lib/plum/client/legacy_client_session.rb
index bdbce9a..ee061b4 100644
--- a/lib/plum/client/legacy_client_session.rb
+++ b/lib/plum/client/legacy_client_session.rb
@@ -1,5 +1,3 @@
-# frozen-string-literal: true
-
module Plum
# HTTP/1.x client session.
class LegacyClientSession
diff --git a/lib/plum/client/response.rb b/lib/plum/client/response.rb
index e937fa6..30dba63 100644
--- a/lib/plum/client/response.rb
+++ b/lib/plum/client/response.rb
@@ -1,5 +1,3 @@
-# frozen-string-literal: true
-
module Plum
class Response
# The response headers
diff --git a/lib/plum/client/upgrade_client_session.rb b/lib/plum/client/upgrade_client_session.rb
index a098c71..2b641e6 100644
--- a/lib/plum/client/upgrade_client_session.rb
+++ b/lib/plum/client/upgrade_client_session.rb
@@ -1,5 +1,3 @@
-# frozen-string-literal: true
-
module Plum
# Try upgrade to HTTP/2
class UpgradeClientSession
diff --git a/lib/plum/connection.rb b/lib/plum/connection.rb
index 739bbf3..3d43e6b 100644
--- a/lib/plum/connection.rb
+++ b/lib/plum/connection.rb
@@ -1,5 +1,3 @@
-# frozen-string-literal: true
-
using Plum::BinaryString
module Plum
diff --git a/lib/plum/errors.rb b/lib/plum/errors.rb
index 700e0ef..8cb8c71 100644
--- a/lib/plum/errors.rb
+++ b/lib/plum/errors.rb
@@ -1,5 +1,3 @@
-# frozen-string-literal: true
-
module Plum
class Error < StandardError; end
class HPACKError < Error; end
diff --git a/lib/plum/event_emitter.rb b/lib/plum/event_emitter.rb
index 3aa1127..187c8d9 100644
--- a/lib/plum/event_emitter.rb
+++ b/lib/plum/event_emitter.rb
@@ -1,5 +1,3 @@
-# frozen-string-literal: true
-
module Plum
module EventEmitter
# Registers an event handler to specified event. An event can have multiple handlers.
diff --git a/lib/plum/flow_control.rb b/lib/plum/flow_control.rb
index 4b7ef79..013371d 100644
--- a/lib/plum/flow_control.rb
+++ b/lib/plum/flow_control.rb
@@ -1,5 +1,3 @@
-# frozen-string-literal: true
-
using Plum::BinaryString
module Plum
diff --git a/lib/plum/frame.rb b/lib/plum/frame.rb
index 1a4b402..17f24b9 100644
--- a/lib/plum/frame.rb
+++ b/lib/plum/frame.rb
@@ -1,6 +1,5 @@
-# frozen-string-literal: true
-
using Plum::BinaryString
+
module Plum
class Frame
FRAME_TYPES = {
@@ -168,7 +167,7 @@ module Plum
cur = buffer.byteshift(9 + length)
type_value, flags_value, r_sid = cur.byteslice(3, 6).unpack("CCN")
# r = r_sid >> 31 # currently not used
- stream_id = r_sid # & ~(1 << 31)
+ stream_id = r_sid & ~(1 << 31)
frame = (SUB_CLASSES[type_value] || Frame::Unknown).allocate
frame.send(:initialize_base,
diff --git a/lib/plum/frame/continuation.rb b/lib/plum/frame/continuation.rb
index 1c5232c..27de5ab 100644
--- a/lib/plum/frame/continuation.rb
+++ b/lib/plum/frame/continuation.rb
@@ -1,5 +1,3 @@
-# frozen-string-literal: true
-
using Plum::BinaryString
module Plum
class Frame::Continuation < Frame
diff --git a/lib/plum/frame/data.rb b/lib/plum/frame/data.rb
index 7c02029..446cdce 100644
--- a/lib/plum/frame/data.rb
+++ b/lib/plum/frame/data.rb
@@ -1,6 +1,5 @@
-# frozen-string-literal: true
-
using Plum::BinaryString
+
module Plum
class Frame::Data < Frame
register_subclass 0x00
diff --git a/lib/plum/frame/goaway.rb b/lib/plum/frame/goaway.rb
index 5eeb28a..f0be7a9 100644
--- a/lib/plum/frame/goaway.rb
+++ b/lib/plum/frame/goaway.rb
@@ -1,6 +1,5 @@
-# frozen-string-literal: true
-
using Plum::BinaryString
+
module Plum
class Frame::Goaway < Frame
register_subclass 0x07
diff --git a/lib/plum/frame/headers.rb b/lib/plum/frame/headers.rb
index 12d6a61..3696a9b 100644
--- a/lib/plum/frame/headers.rb
+++ b/lib/plum/frame/headers.rb
@@ -1,6 +1,5 @@
-# frozen-string-literal: true
-
using Plum::BinaryString
+
module Plum
class Frame::Headers < Frame
register_subclass 0x01
diff --git a/lib/plum/frame/ping.rb b/lib/plum/frame/ping.rb
index b0b3804..baff916 100644
--- a/lib/plum/frame/ping.rb
+++ b/lib/plum/frame/ping.rb
@@ -1,6 +1,5 @@
-# frozen-string-literal: true
-
using Plum::BinaryString
+
module Plum
class Frame::Ping < Frame
register_subclass 0x06
diff --git a/lib/plum/frame/priority.rb b/lib/plum/frame/priority.rb
index 2d081ce..571954f 100644
--- a/lib/plum/frame/priority.rb
+++ b/lib/plum/frame/priority.rb
@@ -1,6 +1,5 @@
-# frozen-string-literal: true
-
using Plum::BinaryString
+
module Plum
class Frame::Priority < Frame
register_subclass 0x02
diff --git a/lib/plum/frame/push_promise.rb b/lib/plum/frame/push_promise.rb
index 200fa37..d9133c4 100644
--- a/lib/plum/frame/push_promise.rb
+++ b/lib/plum/frame/push_promise.rb
@@ -1,6 +1,5 @@
-# frozen-string-literal: true
-
using Plum::BinaryString
+
module Plum
class Frame::PushPromise < Frame
register_subclass 0x05
diff --git a/lib/plum/frame/rst_stream.rb b/lib/plum/frame/rst_stream.rb
index c7794a9..6de527c 100644
--- a/lib/plum/frame/rst_stream.rb
+++ b/lib/plum/frame/rst_stream.rb
@@ -1,6 +1,5 @@
-# frozen-string-literal: true
-
using Plum::BinaryString
+
module Plum
class Frame::RstStream < Frame
register_subclass 0x03
diff --git a/lib/plum/frame/settings.rb b/lib/plum/frame/settings.rb
index 71a92eb..bbf418f 100644
--- a/lib/plum/frame/settings.rb
+++ b/lib/plum/frame/settings.rb
@@ -1,6 +1,5 @@
-# frozen-string-literal: true
-
using Plum::BinaryString
+
module Plum
class Frame::Settings < Frame
register_subclass 0x04
diff --git a/lib/plum/frame/unknown.rb b/lib/plum/frame/unknown.rb
index 6e9decb..e965b22 100644
--- a/lib/plum/frame/unknown.rb
+++ b/lib/plum/frame/unknown.rb
@@ -1,6 +1,5 @@
-# frozen-string-literal: true
-
using Plum::BinaryString
+
module Plum
class Frame::Unknown < Frame
# Creates a frame with unknown type value.
diff --git a/lib/plum/frame/window_update.rb b/lib/plum/frame/window_update.rb
index 3fe5ecd..07e247e 100644
--- a/lib/plum/frame/window_update.rb
+++ b/lib/plum/frame/window_update.rb
@@ -1,6 +1,5 @@
-# frozen-string-literal: true
-
using Plum::BinaryString
+
module Plum
class Frame::WindowUpdate < Frame
register_subclass 0x08
diff --git a/lib/plum/hpack/constants.rb b/lib/plum/hpack/constants.rb
index bf5449b..296654e 100644
--- a/lib/plum/hpack/constants.rb
+++ b/lib/plum/hpack/constants.rb
@@ -1,5 +1,3 @@
-# frozen-string-literal: true
-
module Plum
module HPACK
# RFC7541 Appendix A
diff --git a/lib/plum/hpack/context.rb b/lib/plum/hpack/context.rb
index 5256e5e..f636cc0 100644
--- a/lib/plum/hpack/context.rb
+++ b/lib/plum/hpack/context.rb
@@ -1,5 +1,3 @@
-# frozen-string-literal: true
-
module Plum
module HPACK
module Context
diff --git a/lib/plum/hpack/decoder.rb b/lib/plum/hpack/decoder.rb
index f80494f..b5610de 100644
--- a/lib/plum/hpack/decoder.rb
+++ b/lib/plum/hpack/decoder.rb
@@ -1,5 +1,3 @@
-# frozen-string-literal: true
-
using Plum::BinaryString
module Plum
diff --git a/lib/plum/hpack/encoder.rb b/lib/plum/hpack/encoder.rb
index ab82fb4..426df2e 100644
--- a/lib/plum/hpack/encoder.rb
+++ b/lib/plum/hpack/encoder.rb
@@ -1,5 +1,3 @@
-# frozen-string-literal: true
-
using Plum::BinaryString
module Plum
diff --git a/lib/plum/hpack/huffman.rb b/lib/plum/hpack/huffman.rb
index 9604f1f..7b10835 100644
--- a/lib/plum/hpack/huffman.rb
+++ b/lib/plum/hpack/huffman.rb
@@ -1,5 +1,3 @@
-# frozen-string-literal: true
-
using Plum::BinaryString
module Plum
diff --git a/lib/plum/rack.rb b/lib/plum/rack.rb
index a9d2c66..9246334 100644
--- a/lib/plum/rack.rb
+++ b/lib/plum/rack.rb
@@ -3,10 +3,10 @@ require "stringio"
require "plum"
require "rack"
require "rack/handler/plum"
-require "plum/rack/config"
-require "plum/rack/dsl"
-require "plum/rack/listener"
-require "plum/rack/server"
-require "plum/rack/session"
-require "plum/rack/legacy_session"
-require "plum/rack/thread_pool"
+require_relative "rack/config"
+require_relative "rack/dsl"
+require_relative "rack/listener"
+require_relative "rack/server"
+require_relative "rack/session"
+require_relative "rack/legacy_session"
+require_relative "rack/thread_pool"
diff --git a/lib/plum/rack/cli.rb b/lib/plum/rack/cli.rb
index 8e47e02..77b60f2 100644
--- a/lib/plum/rack/cli.rb
+++ b/lib/plum/rack/cli.rb
@@ -1,5 +1,3 @@
-# frozen-string-literal: true
-
require "optparse"
require "rack/builder"
diff --git a/lib/plum/rack/config.rb b/lib/plum/rack/config.rb
index f452a05..f5d39d7 100644
--- a/lib/plum/rack/config.rb
+++ b/lib/plum/rack/config.rb
@@ -1,5 +1,3 @@
-# frozen-string-literal: true
-
module Plum
module Rack
class Config
diff --git a/lib/plum/rack/dsl.rb b/lib/plum/rack/dsl.rb
index f47313c..baf5344 100644
--- a/lib/plum/rack/dsl.rb
+++ b/lib/plum/rack/dsl.rb
@@ -1,5 +1,3 @@
-# frozen-string-literal: true
-
module Plum
module Rack
module DSL
diff --git a/lib/plum/rack/legacy_session.rb b/lib/plum/rack/legacy_session.rb
index 834c97c..e1a0b78 100644
--- a/lib/plum/rack/legacy_session.rb
+++ b/lib/plum/rack/legacy_session.rb
@@ -1,5 +1,3 @@
-# frozen-string-literal: true
-
using Plum::BinaryString
module Plum
diff --git a/lib/plum/rack/listener.rb b/lib/plum/rack/listener.rb
index 4296e3c..1558dc2 100644
--- a/lib/plum/rack/listener.rb
+++ b/lib/plum/rack/listener.rb
@@ -1,5 +1,3 @@
-# frozen-string-literal: true
-
module Plum
module Rack
class BaseListener
@@ -63,9 +61,6 @@ module Plum
ctx = OpenSSL::SSL::SSLContext.new
ctx.ssl_version = :TLSv1_2
ctx.alpn_select_cb = -> (protocols) { protocols.include?("h2") ? "h2" : protocols.first }
- if ctx.respond_to?(:tmp_ecdh_callback) && !ctx.respond_to?(:set_ecdh_curves)
- ctx.tmp_ecdh_callback = -> (sock, ise, keyl) { OpenSSL::PKey::EC.new("prime256v1") }
- end
*ctx.extra_chain_cert, ctx.cert = parse_chained_cert(cert)
ctx.key = OpenSSL::PKey::RSA.new(key)
ctx.servername_cb = proc { |sock, hostname|
diff --git a/lib/plum/rack/server.rb b/lib/plum/rack/server.rb
index 5ab2e71..99d5dc0 100644
--- a/lib/plum/rack/server.rb
+++ b/lib/plum/rack/server.rb
@@ -1,5 +1,3 @@
-# frozen-string-literal: true
-
module Plum
module Rack
class Server
diff --git a/lib/plum/rack/session.rb b/lib/plum/rack/session.rb
index 1c9a4df..824d14c 100644
--- a/lib/plum/rack/session.rb
+++ b/lib/plum/rack/session.rb
@@ -1,5 +1,3 @@
-# frozen-string-literal: true
-
using Plum::BinaryString
module Plum
diff --git a/lib/plum/rack/thread_pool.rb b/lib/plum/rack/thread_pool.rb
index 68ce2b6..3051e65 100644
--- a/lib/plum/rack/thread_pool.rb
+++ b/lib/plum/rack/thread_pool.rb
@@ -1,5 +1,3 @@
-# frozen-string-literal: true
-
module Plum
module Rack
class ThreadPool
diff --git a/lib/plum/server/connection.rb b/lib/plum/server/connection.rb
index aaaecf8..4370d06 100644
--- a/lib/plum/server/connection.rb
+++ b/lib/plum/server/connection.rb
@@ -1,6 +1,5 @@
-# frozen-string-literal: true
-
using Plum::BinaryString
+
module Plum
class ServerConnection < Connection
def initialize(writer, local_settings = {})
diff --git a/lib/plum/server/http_connection.rb b/lib/plum/server/http_connection.rb
index 473cef6..fd57023 100644
--- a/lib/plum/server/http_connection.rb
+++ b/lib/plum/server/http_connection.rb
@@ -1,5 +1,3 @@
-# frozen-string-literal: true
-
using Plum::BinaryString
module Plum
diff --git a/lib/plum/server/ssl_socket_connection.rb b/lib/plum/server/ssl_socket_connection.rb
index 4dd4fb1..338c114 100644
--- a/lib/plum/server/ssl_socket_connection.rb
+++ b/lib/plum/server/ssl_socket_connection.rb
@@ -1,5 +1,3 @@
-# frozen-string-literal: true
-
module Plum
class SSLSocketServerConnection < ServerConnection
attr_reader :sock
diff --git a/lib/plum/stream.rb b/lib/plum/stream.rb
index 6e6724e..d64cad1 100644
--- a/lib/plum/stream.rb
+++ b/lib/plum/stream.rb
@@ -1,5 +1,3 @@
-# frozen-string-literal: true
-
using Plum::BinaryString
module Plum
diff --git a/lib/plum/version.rb b/lib/plum/version.rb
deleted file mode 100644
index 1ba7997..0000000
--- a/lib/plum/version.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-# frozen-string-literal: true
-
-module Plum
- VERSION = "0.3.0"
-end
diff --git a/lib/rack/handler/plum.rb b/lib/rack/handler/plum.rb
index 6fc8ba5..cf21323 100644
--- a/lib/rack/handler/plum.rb
+++ b/lib/rack/handler/plum.rb
@@ -1,6 +1,4 @@
-# frozen-string-literal: true
-
-require "plum/rack"
+require_relative "../../plum/rack"
module Rack
module Handler
diff --git a/plum.gemspec b/plum.gemspec
index 3084464..7a45a21 100644
--- a/plum.gemspec
+++ b/plum.gemspec
@@ -1,33 +1,20 @@
-# frozen-string-literal: true
-
-lib = File.expand_path("../lib", __FILE__)
-$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
-require "plum/version"
-
Gem::Specification.new do |spec|
spec.name = "plum"
- spec.version = Plum::VERSION
- spec.authors = ["rhenium"]
+ spec.version = ENV["VERSION"]
+ spec.authors = ["Kazuki Yamaguchi"]
spec.email = ["k@rhe.jp"]
- spec.summary = %q{An HTTP/2 Library for Ruby}
+ spec.summary = "An HTTP/2 Library for Ruby"
spec.description = spec.summary
spec.homepage = "https://github.com/rhenium/plum"
spec.license = "MIT"
- spec.files = `git ls-files -z`.split("\x00")
+ spec.files = Dir["bin/plum", "lib/**/*.rb", "*.md", "LICENSE"]
spec.executables = spec.files.grep(%r{^bin/[^.]}) { |f| File.basename(f) }
- spec.test_files = spec.files.grep(%r{^test/})
spec.require_paths = ["lib"]
- spec.add_development_dependency "bundler", "~> 1.10"
+ spec.add_dependency "openssl", "~> 2.0"
+ spec.add_development_dependency "test-unit", "~> 3.0"
spec.add_development_dependency "http_parser.rb"
spec.add_development_dependency "rack"
- spec.add_development_dependency "rake"
- spec.add_development_dependency "yard"
- spec.add_development_dependency "minitest", "~> 5.8.0"
- spec.add_development_dependency "simplecov"
- spec.add_development_dependency "codeclimate-test-reporter"
- spec.add_development_dependency "guard"
- spec.add_development_dependency "guard-minitest"
end
diff --git a/test/plum/client/test_client.rb b/test/plum/client/test_client.rb
index c6c7af7..97a5176 100644
--- a/test/plum/client/test_client.rb
+++ b/test/plum/client/test_client.rb
@@ -1,15 +1,15 @@
-require "test_helper"
+require_relative "../../utils"
-using Plum::BinaryString
-class ClientTest < Minitest::Test
+using BinaryString
+class ClientTest < Test::Unit::TestCase
def test_request_async
res2 = nil
client = nil
server_thread = start_tls_server
Client.start("127.0.0.1", LISTEN_PORT, https: true, verify_mode: OpenSSL::SSL::VERIFY_NONE) { |c|
client = c
- res1 = client.request({ ":path" => "/", ":method" => "GET", ":scheme" => "https", "header" => "ccc" }, nil) { |res1|
- assert(res1.headers)
+ res1 = client.request({ ":path" => "/", ":method" => "GET", ":scheme" => "https", "header" => "ccc" }, nil) { |res1x|
+ assert(res1x.headers)
}
assert_nil(res1.headers)
@@ -35,7 +35,7 @@ class ClientTest < Minitest::Test
def test_raise_error_async_seq_resume
server_thread = start_tls_server
client = Client.start("127.0.0.1", LISTEN_PORT, https: true, verify_mode: OpenSSL::SSL::VERIFY_NONE)
- res = client.get("/error_in_data")
+ client.get("/error_in_data")
assert_raises(LocalConnectionError) {
client.resume
}
@@ -73,12 +73,12 @@ class ClientTest < Minitest::Test
def start_tls_server(&block)
ctx = OpenSSL::SSL::SSLContext.new
ctx.alpn_select_cb = -> protocols { "h2" }
- ctx.cert = TLS_CERT
- ctx.key = TLS_KEY
+ ctx.cert = issue_cert("CN=localhost", rsa2048)
+ ctx.key = rsa2048
tcp_server = TCPServer.new("127.0.0.1", LISTEN_PORT)
ssl_server = OpenSSL::SSL::SSLServer.new(tcp_server, ctx)
- server_thread = Thread.new {
+ Thread.new {
plum = nil
begin
Timeout.timeout(1) {
@@ -117,7 +117,7 @@ class ClientTest < Minitest::Test
rescue OpenSSL::SSL::SSLError
rescue Timeout::Error
flunk "server timeout"
- rescue ExampleError => e
+ rescue ExampleError
plum.goaway(:internal_error) if plum
ensure
tcp_server.close
diff --git a/test/plum/client/test_connection.rb b/test/plum/client/test_connection.rb
index 2903cfa..72d77b0 100644
--- a/test/plum/client/test_connection.rb
+++ b/test/plum/client/test_connection.rb
@@ -1,7 +1,7 @@
-require "test_helper"
+require_relative "../../utils"
-using Plum::BinaryString
-class ClientConnectionTest < Minitest::Test
+using BinaryString
+class ClientConnectionTest < Test::Unit::TestCase
def test_open_stream
con = open_client_connection
stream = con.open_stream
diff --git a/test/plum/client/test_decoders.rb b/test/plum/client/test_decoders.rb
index dfd67b1..416ed8f 100644
--- a/test/plum/client/test_decoders.rb
+++ b/test/plum/client/test_decoders.rb
@@ -1,7 +1,7 @@
-require "test_helper"
+require_relative "../../utils"
-using Plum::BinaryString
-class DecodersTest < Minitest::Test
+using BinaryString
+class DecodersTest < Test::Unit::TestCase
def test_base_decode
decoder = Decoders::Base.new
assert_equal("abc", decoder.decode("abc"))
diff --git a/test/plum/client/test_legacy_client_session.rb b/test/plum/client/test_legacy_client_session.rb
index 421a261..abc87e5 100644
--- a/test/plum/client/test_legacy_client_session.rb
+++ b/test/plum/client/test_legacy_client_session.rb
@@ -1,7 +1,7 @@
-require "test_helper"
+require_relative "../../utils"
-using Plum::BinaryString
-class LegacyClientSessionTest < Minitest::Test
+using BinaryString
+class LegacyClientSessionTest < Test::Unit::TestCase
def test_empty?
io = StringIO.new
session = LegacyClientSession.new(io, Client::DEFAULT_CONFIG)
@@ -48,7 +48,7 @@ class LegacyClientSessionTest < Minitest::Test
def test_chunked_chunked_string
io = StringIO.new
session = LegacyClientSession.new(io, Client::DEFAULT_CONFIG.merge(hostname: "hostname"))
- res = session.request({ ":method" => "GET", ":path" => "/aa" }, "a" * 1025, {})
+ session.request({ ":method" => "GET", ":path" => "/aa" }, "a" * 1025, {})
assert_equal(<<-EOR, io.string)
GET /aa HTTP/1.1\r
host: hostname\r
@@ -62,7 +62,7 @@ transfer-encoding: chunked\r
def test_chunked_chunked_io
io = StringIO.new
session = LegacyClientSession.new(io, Client::DEFAULT_CONFIG.merge(hostname: "hostname"))
- res = session.request({ ":method" => "GET", ":path" => "/aa" }, StringIO.new("a" * 1025), {})
+ session.request({ ":method" => "GET", ":path" => "/aa" }, StringIO.new("a" * 1025), {})
assert_equal(<<-EOR, io.string)
GET /aa HTTP/1.1\r
host: hostname\r
@@ -78,7 +78,7 @@ a\r
def test_chunked_sized
io = StringIO.new
session = LegacyClientSession.new(io, Client::DEFAULT_CONFIG.merge(hostname: "hostname"))
- res = session.request({ ":method" => "GET", ":path" => "/aa", "content-length" => 1025 }, StringIO.new("a" * 1025), {})
+ session.request({ ":method" => "GET", ":path" => "/aa", "content-length" => 1025 }, StringIO.new("a" * 1025), {})
assert_equal((<<-EOR).chomp, io.string)
GET /aa HTTP/1.1\r
content-length: 1025\r
diff --git a/test/plum/client/test_response.rb b/test/plum/client/test_response.rb
index a4c7fb8..1a33b4e 100644
--- a/test/plum/client/test_response.rb
+++ b/test/plum/client/test_response.rb
@@ -1,7 +1,7 @@
-require "test_helper"
+require_relative "../../utils"
-using Plum::BinaryString
-class ResponseTest < Minitest::Test
+using BinaryString
+class ResponseTest < Test::Unit::TestCase
def test_finished
resp = Response.new(nil)
resp.send(:set_headers, {})
diff --git a/test/plum/client/test_upgrade_client_session.rb b/test/plum/client/test_upgrade_client_session.rb
index 4c20e3b..e29365f 100644
--- a/test/plum/client/test_upgrade_client_session.rb
+++ b/test/plum/client/test_upgrade_client_session.rb
@@ -1,7 +1,7 @@
-require "test_helper"
+require_relative "../../utils"
-using Plum::BinaryString
-class UpgradeClientSessionTest < Minitest::Test
+using BinaryString
+class UpgradeClientSessionTest < Test::Unit::TestCase
def test_empty?
sock = StringSocket.new("HTTP/1.1 101\r\n\r\n")
session = UpgradeClientSession.new(sock, Client::DEFAULT_CONFIG)
diff --git a/test/plum/connection/test_handle_frame.rb b/test/plum/connection/test_handle_frame.rb
index ca4ef18..0b48043 100644
--- a/test/plum/connection/test_handle_frame.rb
+++ b/test/plum/connection/test_handle_frame.rb
@@ -1,8 +1,7 @@
-require "test_helper"
+require_relative "../../utils"
-using Plum::BinaryString
-
-class ServerConnectionHandleFrameTest < Minitest::Test
+using BinaryString
+class ServerConnectionHandleFrameTest < Test::Unit::TestCase
## SETTINGS
def test_server_handle_settings
open_server_connection { |con|
@@ -12,7 +11,7 @@ class ServerConnectionHandleFrameTest < Minitest::Test
}
end
- def test_server_handle_settings
+ def test_server_handle_settings_ack
open_server_connection { |con|
assert_no_error {
con << Frame.craft(type: :settings, stream_id: 0, flags: [:ack], payload: "").assemble
diff --git a/test/plum/hpack/test_context.rb b/test/plum/hpack/test_context.rb
index 4a54e6c..b04aaf2 100644
--- a/test/plum/hpack/test_context.rb
+++ b/test/plum/hpack/test_context.rb
@@ -1,6 +1,6 @@
-require "test_helper"
+require_relative "../../utils"
-class HPACKContextTest < Minitest::Test
+class HPACKContextTest < Test::Unit::TestCase
def test_store
context = new_context
context.store("あああ", "いい")
@@ -58,7 +58,7 @@ class HPACKContextTest < Minitest::Test
def new_context(limit = 1 << 31)
klass = Class.new {
include Plum::HPACK::Context
- public *Plum::HPACK::Context.private_instance_methods
+ public(*Plum::HPACK::Context.private_instance_methods)
}
klass.new(limit)
end
diff --git a/test/plum/hpack/test_decoder.rb b/test/plum/hpack/test_decoder.rb
index 9a500f7..d927f71 100644
--- a/test/plum/hpack/test_decoder.rb
+++ b/test/plum/hpack/test_decoder.rb
@@ -1,6 +1,6 @@
-require "test_helper"
+require_relative "../../utils"
-class HPACKDecoderTest < Minitest::Test
+class HPACKDecoderTest < Test::Unit::TestCase
# C.1.1
def test_hpack_read_integer_small
buf = [0b11001010, 0b00001111].pack("C*")
diff --git a/test/plum/hpack/test_encoder.rb b/test/plum/hpack/test_encoder.rb
index a0096ed..b76f2a5 100644
--- a/test/plum/hpack/test_encoder.rb
+++ b/test/plum/hpack/test_encoder.rb
@@ -1,6 +1,6 @@
-require "test_helper"
+require_relative "../../utils"
-class HPACKEncoderTest < Minitest::Test
+class HPACKEncoderTest < Test::Unit::TestCase
# C.1.1
def test_hpack_encode_integer_small
result = new_encoder(1 << 31).__send__(:encode_integer, 10, 5, 0b00000000)
@@ -41,10 +41,10 @@ class HPACKEncoderTest < Minitest::Test
def test_hpack_encode_without_indexing
encoder = new_encoder(1 << 31, indexing: false)
headers1 = [["custom-key", "custom-header"]]
- ret1 = encoder.encode(headers1)
+ encoder.encode(headers1)
assert_equal([], encoder.dynamic_table)
headers2 = [[":method", "custom-header"]]
- ret2 = encoder.encode(headers2)
+ encoder.encode(headers2)
assert_equal([], encoder.dynamic_table)
end
diff --git a/test/plum/hpack/test_huffman.rb b/test/plum/hpack/test_huffman.rb
index 27c3411..d30f759 100644
--- a/test/plum/hpack/test_huffman.rb
+++ b/test/plum/hpack/test_huffman.rb
@@ -1,6 +1,6 @@
-require "test_helper"
+require_relative "../../utils"
-class HPACKHuffmanTest < Minitest::Test
+class HPACKHuffmanTest < Test::Unit::TestCase
def test_hpack_huffman_encode
text = "\x10\x60\x2a\x1d\x94\x47\x82\x2c\x3d\x19\xbf\x8e\xd9\x24\xba\xe6\xb4\x1a\xe1\x5c\x39\x0f\x61\xf4\x3b\x08\x62\x54\x15\x0c"
expected = "\xff\xff\xfe\xdf\xff\xbf\x3f\xff\xff\xf3\xff\xff\xdd\x8b\xff\xf9\xfe\xa0\xff\xff\xff\x5f\xff\xfe\x3f\xff\xfd\x7f\xff\xe5\xff\xcf\xff\xfc\x7f\xff\xe8\xff\xff\xdb\xff\xff\xfe\xdf\xff\xfe\x7f\xff\xc1\xff\xff\xff\xec\x1f\xff\xff\xe7\xfb\xff\xff\xfe\x88\xf7\xff\xff\xff\x97\xff\xff\xf5\x7f"
diff --git a/test/plum/server/test_connection.rb b/test/plum/server/test_connection.rb
index ccc9dae..97c616f 100644
--- a/test/plum/server/test_connection.rb
+++ b/test/plum/server/test_connection.rb
@@ -1,8 +1,7 @@
-require "test_helper"
+require_relative "../../utils"
-using Plum::BinaryString
-
-class HTTPSConnectionNegotiationTest < Minitest::Test
+using BinaryString
+class HTTPSConnectionNegotiationTest < Test::Unit::TestCase
def test_server_must_raise_cprotocol_error_invalid_magic_short
con = ServerConnection.new(StringIO.new.method(:write))
assert_connection_error(:protocol_error) {
@@ -40,8 +39,8 @@ class HTTPSConnectionNegotiationTest < Minitest::Test
ctx = OpenSSL::SSL::SSLContext.new
ctx.alpn_select_cb = -> protocols { "h2" }
- ctx.cert = TLS_CERT
- ctx.key = TLS_KEY
+ ctx.cert = issue_cert("CN=localhost", rsa2048)
+ ctx.key = rsa2048
tcp_server = TCPServer.new("127.0.0.1", LISTEN_PORT)
ssl_server = OpenSSL::SSL::SSLServer.new(tcp_server, ctx)
@@ -67,9 +66,9 @@ class HTTPSConnectionNegotiationTest < Minitest::Test
client_thread = Thread.new {
sock = TCPSocket.new("127.0.0.1", LISTEN_PORT)
begin
- ctx = OpenSSL::SSL::SSLContext.new.tap { |ctx|
- ctx.alpn_protocols = ["h2"]
- ctx.ciphers = "AES256-GCM-SHA384"
+ ctx = OpenSSL::SSL::SSLContext.new.tap { |c|
+ c.alpn_protocols = ["h2"]
+ c.ciphers = "AES256-GCM-SHA384"
}
ssl = OpenSSL::SSL::SSLSocket.new(sock, ctx)
ssl.connect
diff --git a/test/plum/server/test_http_connection.rb b/test/plum/server/test_http_connection.rb
index e03523b..aac92d4 100644
--- a/test/plum/server/test_http_connection.rb
+++ b/test/plum/server/test_http_connection.rb
@@ -1,8 +1,7 @@
-require "test_helper"
+require_relative "../../utils"
-using Plum::BinaryString
-
-class HTTPConnectionNegotiationTest < Minitest::Test
+using BinaryString
+class HTTPConnectionNegotiationTest < Test::Unit::TestCase
## with Prior Knowledge (same as over TLS)
def test_server_must_raise_cprotocol_error_non_settings_after_magic
io = StringIO.new
diff --git a/test/plum/stream/test_handle_frame.rb b/test/plum/stream/test_handle_frame.rb
index 6defb82..e23c5c3 100644
--- a/test/plum/stream/test_handle_frame.rb
+++ b/test/plum/stream/test_handle_frame.rb
@@ -1,8 +1,7 @@
-require "test_helper"
+require_relative "../../utils"
-using Plum::BinaryString
-
-class StreamHandleFrameTest < Minitest::Test
+using BinaryString
+class StreamHandleFrameTest < Test::Unit::TestCase
## DATA
def test_stream_handle_data
payload = "ABC" * 5
diff --git a/test/plum/test_binary_string.rb b/test/plum/test_binary_string.rb
index e14123d..b360f64 100644
--- a/test/plum/test_binary_string.rb
+++ b/test/plum/test_binary_string.rb
@@ -1,8 +1,8 @@
-require "test_helper"
+require_relative "../utils"
using BinaryString
-class BinaryStringTest < Minitest::Test
+class BinaryStringTest < Test::Unit::TestCase
def test_uint8
assert_equal(0x67, "\x67".uint8)
assert_equal(0x75, "\x67\x75".uint8(1))
diff --git a/test/plum/test_connection.rb b/test/plum/test_connection.rb
index a28672b..91010c7 100644
--- a/test/plum/test_connection.rb
+++ b/test/plum/test_connection.rb
@@ -1,8 +1,8 @@
-require "test_helper"
+require_relative "../utils"
using Plum::BinaryString
-class ConnectionTest < Minitest::Test
+class ConnectionTest < Test::Unit::TestCase
def test_server_must_raise_frame_size_error_when_exeeeded_max_size
_settings = "".push_uint16(Frame::Settings::SETTINGS_TYPE[:max_frame_size]).push_uint32(2**14)
limit = 2 ** 14
diff --git a/test/plum/test_connection_utils.rb b/test/plum/test_connection_utils.rb
index 785c74c..7ceb891 100644
--- a/test/plum/test_connection_utils.rb
+++ b/test/plum/test_connection_utils.rb
@@ -1,8 +1,8 @@
-require "test_helper"
+require_relative "../utils"
-using BinaryString
+using Plum::BinaryString
-class ServerConnectionUtilsTest < Minitest::Test
+class ServerConnectionUtilsTest < Test::Unit::TestCase
def test_server_ping
open_server_connection { |con|
con.ping("ABCABCAB")
diff --git a/test/plum/test_error.rb b/test/plum/test_error.rb
index 8eaa489..a0d5afc 100644
--- a/test/plum/test_error.rb
+++ b/test/plum/test_error.rb
@@ -1,6 +1,6 @@
-require "test_helper"
+require_relative "../utils"
-class ErrorTest < Minitest::Test
+class ErrorTest < Test::Unit::TestCase
def test_http_error_http2_error_code
test = -> klass {
e = klass.new(:cancel)
diff --git a/test/plum/test_event_emitter.rb b/test/plum/test_event_emitter.rb
index 7efae16..b37ad00 100644
--- a/test/plum/test_event_emitter.rb
+++ b/test/plum/test_event_emitter.rb
@@ -1,7 +1,7 @@
-require "test_helper"
+require_relative "../utils"
using BinaryString
-class EventEmitterTest < Minitest::Test
+class EventEmitterTest < Test::Unit::TestCase
def test_simple
ret = nil
emitter = new_emitter
@@ -24,7 +24,7 @@ class EventEmitterTest < Minitest::Test
def new_emitter
klass = Class.new {
include EventEmitter
- public *EventEmitter.private_instance_methods
+ public(*EventEmitter.private_instance_methods)
}
klass.new
end
diff --git a/test/plum/test_flow_control.rb b/test/plum/test_flow_control.rb
index 38958b7..8de792e 100644
--- a/test/plum/test_flow_control.rb
+++ b/test/plum/test_flow_control.rb
@@ -1,8 +1,7 @@
-require "test_helper"
+require_relative "../utils"
using BinaryString
-
-class FlowControlTest < Minitest::Test
+class FlowControlTest < Test::Unit::TestCase
def test_flow_control_window_update_server
open_server_connection { |con|
before_ws = con.recv_remaining_window
diff --git a/test/plum/test_frame.rb b/test/plum/test_frame.rb
index 40cde01..9b6f88a 100644
--- a/test/plum/test_frame.rb
+++ b/test/plum/test_frame.rb
@@ -1,6 +1,6 @@
-require "test_helper"
+require_relative "../utils"
-class FrameTest < Minitest::Test
+class FrameTest < Test::Unit::TestCase
# Frame.parse!
def test_parse_header_uncomplete
buffer = "\x00\x00\x00" << "\x00" << "\x00"
diff --git a/test/plum/test_frame_factory.rb b/test/plum/test_frame_factory.rb
index df3093e..a744ebb 100644
--- a/test/plum/test_frame_factory.rb
+++ b/test/plum/test_frame_factory.rb
@@ -1,7 +1,7 @@
-require "test_helper"
+require_relative "../utils"
-using Plum::BinaryString
-class FrameFactoryTest < Minitest::Test
+using BinaryString
+class FrameFactoryTest < Test::Unit::TestCase
def test_rst_stream
frame = Frame::RstStream.new(123, :stream_closed)
assert_frame(frame,
diff --git a/test/plum/test_frame_utils.rb b/test/plum/test_frame_utils.rb
index 3851f6a..fff06f0 100644
--- a/test/plum/test_frame_utils.rb
+++ b/test/plum/test_frame_utils.rb
@@ -1,6 +1,6 @@
-require "test_helper"
+require_relative "../utils"
-class FrameUtilsTest < Minitest::Test
+class FrameUtilsTest < Test::Unit::TestCase
def test_frame_enough_short
frame = Frame::Data.new(1, "123")
ret = frame.to_enum(:split, 3).to_a
diff --git a/test/plum/test_stream.rb b/test/plum/test_stream.rb
index db681e7..bfa5cec 100644
--- a/test/plum/test_stream.rb
+++ b/test/plum/test_stream.rb
@@ -1,8 +1,7 @@
-require "test_helper"
+require_relative "../utils"
-using Plum::BinaryString
-
-class StreamTest < Minitest::Test
+using BinaryString
+class StreamTest < Test::Unit::TestCase
def test_stream_illegal_frame_type
open_new_stream { |stream|
assert_connection_error(:protocol_error) {
diff --git a/test/plum/test_stream_utils.rb b/test/plum/test_stream_utils.rb
index 933c510..85accb0 100644
--- a/test/plum/test_stream_utils.rb
+++ b/test/plum/test_stream_utils.rb
@@ -1,7 +1,7 @@
-require "test_helper"
+require_relative "../utils"
using BinaryString
-class StreamUtilsTest < Minitest::Test
+class StreamUtilsTest < Test::Unit::TestCase
def test_stream_promise
open_new_stream { |stream|
push_stream = stream.promise([])
diff --git a/test/server.crt b/test/server.crt
deleted file mode 100644
index 6ac1880..0000000
--- a/test/server.crt
+++ /dev/null
@@ -1,19 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIDADCCAegCCQCasnaEkilFpDANBgkqhkiG9w0BAQsFADBCMQswCQYDVQQGEwJK
-UDEOMAwGA1UECAwFVG9reW8xDzANBgNVBAoMBnJoZS5qcDESMBAGA1UEAwwJbG9j
-YWxob3N0MB4XDTE1MDcyMDA2NTc1N1oXDTI1MDcxNzA2NTc1N1owQjELMAkGA1UE
-BhMCSlAxDjAMBgNVBAgMBVRva3lvMQ8wDQYDVQQKDAZyaGUuanAxEjAQBgNVBAMM
-CWxvY2FsaG9zdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMTOiEAW
-dc+SQ5DOXd/C6fFCj9Ykfk1ykFaYainKYjDkzdPC1oX7h0HCF7v5CJ4gPObuKtT0
-YhQ74kiD0NbJGO0+KscZmmYaLbAmhNi1DDpv5c0mYmwzHR7I5qRbfbUlOnhHvwRX
-XIzzUVVYTGExEYgrVLaLnVva+dRAs+yKGUkqwTG4lo7XVVS/f7UXLn8pJiRRzC34
-kFoEwybWgjme1liC1M+oUft8rkrvZtgLsbZTifkM8uql9ytcIYVMxRteIy3d4W7I
-Lh60SGMoRBSIC5T1OwuM2jjsMJTcmIntmRHutRKH62gqryyZzNqf7O/o28g3M/E0
-0qDCKqL0JjNM/m8CAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAW3bWpzS5p+QurVBt
-wMgePDkv1OGb5suCYI3OHOry5j5uUSbZFMoQGxFDWlQkmRbPvWvkGB2lozcNy0Gd
-qgknNgpxnv2gM6rBX93UE3Xez6q9H6+jlC4cdsGXqw/mC8VzxH/YkdkCfn2CrR/H
-/dUy2++NtEKqbRBETRDB6tWM43K0fV1Ow/TketCBBztMTV0+smqc3dhKtv7wqcvD
-E024K17wDStFp/pB6ZXY0K9wEZt+NFdyYo8IXmkyGKzIksDrvjL+2D4PdagEbz7J
-bWhOWkMrJIawnhJm9+jf9I8c4VqumphM1lWcI1ZySTxVZV7jxOichE9PJJBpKiG8
-9jBWDg==
------END CERTIFICATE-----
diff --git a/test/server.csr b/test/server.csr
deleted file mode 100644
index c9854a4..0000000
--- a/test/server.csr
+++ /dev/null
@@ -1,16 +0,0 @@
------BEGIN CERTIFICATE REQUEST-----
-MIIChzCCAW8CAQAwQjELMAkGA1UEBhMCSlAxDjAMBgNVBAgMBVRva3lvMQ8wDQYD
-VQQKDAZyaGUuanAxEjAQBgNVBAMMCWxvY2FsaG9zdDCCASIwDQYJKoZIhvcNAQEB
-BQADggEPADCCAQoCggEBAMTOiEAWdc+SQ5DOXd/C6fFCj9Ykfk1ykFaYainKYjDk
-zdPC1oX7h0HCF7v5CJ4gPObuKtT0YhQ74kiD0NbJGO0+KscZmmYaLbAmhNi1DDpv
-5c0mYmwzHR7I5qRbfbUlOnhHvwRXXIzzUVVYTGExEYgrVLaLnVva+dRAs+yKGUkq
-wTG4lo7XVVS/f7UXLn8pJiRRzC34kFoEwybWgjme1liC1M+oUft8rkrvZtgLsbZT
-ifkM8uql9ytcIYVMxRteIy3d4W7ILh60SGMoRBSIC5T1OwuM2jjsMJTcmIntmRHu
-tRKH62gqryyZzNqf7O/o28g3M/E00qDCKqL0JjNM/m8CAwEAAaAAMA0GCSqGSIb3
-DQEBCwUAA4IBAQA0SapSebe5VEfJ5fzNXufuhOUUdspm6bFN6uZgq7i3ayISvfL9
-8gsqAyUzsRCMlejUDgRzIHDJCrN9gWCs4+IrqC4YkIoetxH4hs9gxAS9wATcLQPN
-iqe8/kJiput5kFjp+XPH21VSiDDCaJGuXmBMMywPvJwT2G4WbPZe1VbHplb3x50j
-A/OZjh+Uvlej+gHWWP9YVoQmp4oLPfUpksF00z4gw6h8tgMoww4T0cGF/z/qa5Vy
-yMJpRVGcQavhwV8lGpN6cNgtQQIal1kaKYcyOx9bDiWmzuMYAVUZ3KreqT5HpSVx
-PT/yMIBzcSI/9rjTAlnyMbjxQFnrZYWsb/6e
------END CERTIFICATE REQUEST-----
diff --git a/test/server.key b/test/server.key
deleted file mode 100644
index 08e19f7..0000000
--- a/test/server.key
+++ /dev/null
@@ -1,27 +0,0 @@
------BEGIN RSA PRIVATE KEY-----
-MIIEowIBAAKCAQEAxM6IQBZ1z5JDkM5d38Lp8UKP1iR+TXKQVphqKcpiMOTN08LW
-hfuHQcIXu/kIniA85u4q1PRiFDviSIPQ1skY7T4qxxmaZhotsCaE2LUMOm/lzSZi
-bDMdHsjmpFt9tSU6eEe/BFdcjPNRVVhMYTERiCtUtoudW9r51ECz7IoZSSrBMbiW
-jtdVVL9/tRcufykmJFHMLfiQWgTDJtaCOZ7WWILUz6hR+3yuSu9m2AuxtlOJ+Qzy
-6qX3K1whhUzFG14jLd3hbsguHrRIYyhEFIgLlPU7C4zaOOwwlNyYie2ZEe61Eofr
-aCqvLJnM2p/s7+jbyDcz8TTSoMIqovQmM0z+bwIDAQABAoIBAHXtY8szKijU9dOB
-NNLt0oyUW+fvOhdiPIcHESY1dRzjHUp0h2MFUwjeKqaiFL3bh2LA971fKp4BPBhD
-lBH/sgYGqE9hUhk4OoRAsH3CDq+9eS+yfmtjPWHC9CEsCWlQA3crVpRdXMHA0s2W
-+T2Lz3uOq1Yu1n3B+s1qb+We4oPqIkYj3qHpP+BxQYrL9y4L8Hk+dJZviYanlrcG
-MV8CH8WnwqbwkQRDwxE04qALrOWeIE44zY/ZzNCOs8Q4MzyLRFSyAOURECoh4V//
-1eNZd0ojiyxRlpRuDkVt7zn6+FdxZrRySuJxEwFQ5Qanl37yMJb/NN8ill3D8T9L
-vjRTwXECgYEA974PL0IVZmhuk5FcyObFaNDSL196evgUAnPxMQwATwXMzKPw6azE
-rRnBopoS4zq4XWXWR/GAIskmF8vag9zf/za9f8QlJzqT3eQE4mGZeZfpic2WYtBZ
-AojLgEwMGcof4TGHv0dCdSjuw95dXvL7qUopqfiB95TLSv2VXkW6arMCgYEAy13Z
-K2RUt0DLafs/nmNywYDt/isMTTkL0tf4QjdB8Os4C1WcyMUSd1yYblrmsNN8/eWe
-gOHrFt/zwD/kz0z5f/LBsIoEI3ZmJWjL29FQhSllM8q3JfkwCOfH5TmNDF/aAA1t
-b0g+LSSxoUwttLu2euJk64uTGTWXrU+7BxVWq1UCgYAtaVRFOFrN28SxHgsg9FQp
-Q2XTsy+zTLf2PyRt9iI0Wf7RYBev7bBbfoYk9RMTPdc/n4QoydbQCYkHAaH7W8hf
-crxHqD+bMjyahspyaKuGQ1dWoC25zTETqtmKmeX58Dfpwnd8k2ZWLXuewarh1a5V
-uLdsZZYFOOwOwe7YSfXCywKBgQCU2HCd2MZEhhEb1b/fjowsYtBOKnXLg4hK3rWe
-yVDjI1YWvaeOLudwI36RrsiP/YrLTievzyrAyFNgj6NJst4eLrBjJPEYf40NrmEe
-11mmzQB8Ys+f5H2q1vIwrOm2d+VYCnvhai/P3L6B/v6o/Ib39AHHgJW+asJEIEoU
-SiLwLQKBgHEY7WLyqs7dPf9ZxJErZH2eTstMtj649750GsfQGqr0Ul/zWWSq6QPJ
-lzVB2B+g/m6xnPQjn7dXPLeZ3lLbmcLTpl5O9T65qDXgVIzKPX4Ybd4ozjDOfHW5
-u5vKC+xEwJK+17JJ78Mb8XH7vmujCmKLueEuZtgrT6P9Cke26yEN
------END RSA PRIVATE KEY-----
diff --git a/test/test_helper.rb b/test/test_helper.rb
deleted file mode 100644
index f67ba51..0000000
--- a/test/test_helper.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-unless ENV["SKIP_COVERAGE"]
- begin
- require "simplecov"
- require "codeclimate-test-reporter"
- SimpleCov.formatters = [
- SimpleCov::Formatter::HTMLFormatter,
- CodeClimate::TestReporter::Formatter
- ]
- SimpleCov.start do
- add_filter "test/"
- end
- rescue LoadError
- end
-end
-
-require "timeout"
-require "minitest"
-require "minitest/unit"
-require "minitest/autorun"
-require "minitest/pride"
-require "plum"
-include Plum
-
-Dir.glob(File.expand_path("../utils/*.rb", __FILE__)).each do |file|
- require file
-end
-
-LISTEN_PORT = ENV["PLUM_LISTEN_PORT"] || 40444
-TLS_CERT = OpenSSL::X509::Certificate.new File.read(File.expand_path("../server.crt", __FILE__))
-TLS_KEY = OpenSSL::PKey::RSA.new File.read(File.expand_path("../server.key", __FILE__))
-ExampleError = Class.new(RuntimeError)
diff --git a/test/utils.rb b/test/utils.rb
new file mode 100644
index 0000000..60e3ef9
--- /dev/null
+++ b/test/utils.rb
@@ -0,0 +1,130 @@
+require "test/unit"
+require "timeout"
+require "socket"
+require "forwardable"
+gem "openssl"
+require "openssl"
+
+require "plum"
+require_relative "utils/assertions"
+require_relative "utils/string_socket"
+
+include Plum
+LISTEN_PORT = ENV["PLUM_LISTEN_PORT"] || 44444
+ExampleError = Class.new(RuntimeError)
+
+class Test::Unit::TestCase
+ def open_client_connection(scheme = :https)
+ io = StringIO.new
+ @_ccon = ClientConnection.new(io.method(:write))
+ @_ccon << Frame::Settings.ack.assemble
+ @_ccon << Frame::Settings.new.assemble
+ if block_given?
+ yield @_ccon
+ else
+ @_ccon
+ end
+ end
+
+ def open_server_connection(scheme = :https)
+ @_io = StringIO.new
+ @_con = (scheme == :https ? ServerConnection : HTTPServerConnection).new(@_io.method(:write))
+ @_con << Connection::CLIENT_CONNECTION_PREFACE
+ @_con << Frame::Settings.new.assemble
+ if block_given?
+ yield @_con
+ else
+ @_con
+ end
+ end
+
+ def open_new_stream(arg1 = nil, state: :idle, **kwargs)
+ if arg1.is_a?(ServerConnection)
+ con = arg1
+ else
+ con = open_server_connection
+ end
+
+ @_stream = con.instance_eval { stream(@max_stream_ids[1] + 2) }
+ @_stream.set_state(state)
+ @_stream.update_dependency(**kwargs)
+ if block_given?
+ yield @_stream
+ else
+ @_stream
+ end
+ end
+
+ def sent_frames(io = nil)
+ resp = (io || @_io).string.dup.force_encoding(Encoding::BINARY)
+ frames = []
+ while f = Frame.parse!(resp)
+ frames << f
+ end
+ frames
+ end
+
+ def parse_frames(io, &blk)
+ pos = io.string.bytesize
+ blk.call
+ resp = io.string.byteslice(pos, io.string.bytesize - pos).force_encoding(Encoding::BINARY)
+ frames = []
+ while f = Frame.parse!(resp)
+ frames << f
+ end
+ frames
+ end
+
+ def parse_frame(io, &blk)
+ frames = capture_frames(io, &blk)
+ assert_equal(1, frames.size, "Supplied block sent no frames or more than 1 frame")
+ frames.first
+ end
+
+ def rsa2048
+ OpenSSL::PKey.read <<~EOF
+ -----BEGIN RSA PRIVATE KEY-----
+ MIIEowIBAAKCAQEAxM6IQBZ1z5JDkM5d38Lp8UKP1iR+TXKQVphqKcpiMOTN08LW
+ hfuHQcIXu/kIniA85u4q1PRiFDviSIPQ1skY7T4qxxmaZhotsCaE2LUMOm/lzSZi
+ bDMdHsjmpFt9tSU6eEe/BFdcjPNRVVhMYTERiCtUtoudW9r51ECz7IoZSSrBMbiW
+ jtdVVL9/tRcufykmJFHMLfiQWgTDJtaCOZ7WWILUz6hR+3yuSu9m2AuxtlOJ+Qzy
+ 6qX3K1whhUzFG14jLd3hbsguHrRIYyhEFIgLlPU7C4zaOOwwlNyYie2ZEe61Eofr
+ aCqvLJnM2p/s7+jbyDcz8TTSoMIqovQmM0z+bwIDAQABAoIBAHXtY8szKijU9dOB
+ NNLt0oyUW+fvOhdiPIcHESY1dRzjHUp0h2MFUwjeKqaiFL3bh2LA971fKp4BPBhD
+ lBH/sgYGqE9hUhk4OoRAsH3CDq+9eS+yfmtjPWHC9CEsCWlQA3crVpRdXMHA0s2W
+ +T2Lz3uOq1Yu1n3B+s1qb+We4oPqIkYj3qHpP+BxQYrL9y4L8Hk+dJZviYanlrcG
+ MV8CH8WnwqbwkQRDwxE04qALrOWeIE44zY/ZzNCOs8Q4MzyLRFSyAOURECoh4V//
+ 1eNZd0ojiyxRlpRuDkVt7zn6+FdxZrRySuJxEwFQ5Qanl37yMJb/NN8ill3D8T9L
+ vjRTwXECgYEA974PL0IVZmhuk5FcyObFaNDSL196evgUAnPxMQwATwXMzKPw6azE
+ rRnBopoS4zq4XWXWR/GAIskmF8vag9zf/za9f8QlJzqT3eQE4mGZeZfpic2WYtBZ
+ AojLgEwMGcof4TGHv0dCdSjuw95dXvL7qUopqfiB95TLSv2VXkW6arMCgYEAy13Z
+ K2RUt0DLafs/nmNywYDt/isMTTkL0tf4QjdB8Os4C1WcyMUSd1yYblrmsNN8/eWe
+ gOHrFt/zwD/kz0z5f/LBsIoEI3ZmJWjL29FQhSllM8q3JfkwCOfH5TmNDF/aAA1t
+ b0g+LSSxoUwttLu2euJk64uTGTWXrU+7BxVWq1UCgYAtaVRFOFrN28SxHgsg9FQp
+ Q2XTsy+zTLf2PyRt9iI0Wf7RYBev7bBbfoYk9RMTPdc/n4QoydbQCYkHAaH7W8hf
+ crxHqD+bMjyahspyaKuGQ1dWoC25zTETqtmKmeX58Dfpwnd8k2ZWLXuewarh1a5V
+ uLdsZZYFOOwOwe7YSfXCywKBgQCU2HCd2MZEhhEb1b/fjowsYtBOKnXLg4hK3rWe
+ yVDjI1YWvaeOLudwI36RrsiP/YrLTievzyrAyFNgj6NJst4eLrBjJPEYf40NrmEe
+ 11mmzQB8Ys+f5H2q1vIwrOm2d+VYCnvhai/P3L6B/v6o/Ib39AHHgJW+asJEIEoU
+ SiLwLQKBgHEY7WLyqs7dPf9ZxJErZH2eTstMtj649750GsfQGqr0Ul/zWWSq6QPJ
+ lzVB2B+g/m6xnPQjn7dXPLeZ3lLbmcLTpl5O9T65qDXgVIzKPX4Ybd4ozjDOfHW5
+ u5vKC+xEwJK+17JJ78Mb8XH7vmujCmKLueEuZtgrT6P9Cke26yEN
+ -----END RSA PRIVATE KEY-----
+ EOF
+ end
+
+ def issue_cert(dn, pubkey)
+ cert = OpenSSL::X509::Certificate.new
+ ca_cert = cert
+ ca_key = pubkey
+ cert.version = 2
+ cert.serial = 12345
+ cert.subject = OpenSSL::X509::Name.parse_rfc2253(dn)
+ cert.issuer = ca_cert.subject
+ cert.public_key = pubkey
+ cert.not_before = Time.now - 3600
+ cert.not_after = Time.now + 3600
+ cert.sign(ca_key, "sha256")
+ cert
+ end
+end
diff --git a/test/utils/assertions.rb b/test/utils/assertions.rb
index 746d475..ee74523 100644
--- a/test/utils/assertions.rb
+++ b/test/utils/assertions.rb
@@ -1,4 +1,4 @@
-module CustomAssertions
+module Test::Unit::Assertions
def assert_connection_error(type, &blk)
assert_http_error(Plum::RemoteConnectionError, type, &blk)
end
@@ -36,7 +36,6 @@ module CustomAssertions
assert_equal(type, last, "#{klass.name} type: #{type} expected but type: #{last} was raised.")
end
end
-Minitest::Test.__send__(:prepend, CustomAssertions)
module LastErrorExtension
def initialize(type, message = nil)
diff --git a/test/utils/client.rb b/test/utils/client.rb
deleted file mode 100644
index ae8ca16..0000000
--- a/test/utils/client.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-require "timeout"
-
-module ServerUtils
- def open_client_connection(scheme = :https)
- io = StringIO.new
- @_ccon = ClientConnection.new(io.method(:write))
- @_ccon << Frame::Settings.ack.assemble
- @_ccon << Frame::Settings.new.assemble
- if block_given?
- yield @_ccon
- else
- @_ccon
- end
- end
-end
-
-class Minitest::Test
- include ServerUtils
-end
diff --git a/test/utils/server.rb b/test/utils/server.rb
deleted file mode 100644
index 001a3fe..0000000
--- a/test/utils/server.rb
+++ /dev/null
@@ -1,62 +0,0 @@
-require "timeout"
-
-module ServerUtils
- def open_server_connection(scheme = :https)
- @_io = StringIO.new
- @_con = (scheme == :https ? ServerConnection : HTTPServerConnection).new(@_io.method(:write))
- @_con << Connection::CLIENT_CONNECTION_PREFACE
- @_con << Frame::Settings.new.assemble
- if block_given?
- yield @_con
- else
- @_con
- end
- end
-
- def open_new_stream(arg1 = nil, state: :idle, **kwargs)
- if arg1.is_a?(ServerConnection)
- con = arg1
- else
- con = open_server_connection
- end
-
- @_stream = con.instance_eval { stream(@max_stream_ids[1] + 2) }
- @_stream.set_state(state)
- @_stream.update_dependency(**kwargs)
- if block_given?
- yield @_stream
- else
- @_stream
- end
- end
-
- def sent_frames(io = nil)
- resp = (io || @_io).string.dup.force_encoding(Encoding::BINARY)
- frames = []
- while f = Frame.parse!(resp)
- frames << f
- end
- frames
- end
-
- def parse_frames(io, &blk)
- pos = io.string.bytesize
- blk.call
- resp = io.string.byteslice(pos, io.string.bytesize - pos).force_encoding(Encoding::BINARY)
- frames = []
- while f = Frame.parse!(resp)
- frames << f
- end
- frames
- end
-
- def parse_frame(io, &blk)
- frames = capture_frames(io, &blk)
- assert_equal(1, frames.size, "Supplied block sent no frames or more than 1 frame")
- frames.first
- end
-end
-
-class Minitest::Test
- include ServerUtils
-end