Sha256: afe7a969d1b0a90a01b0bccb497f07f4adfacec9b1dde91ae700b8d38c55fc15
Contents?: true
Size: 1.81 KB
Versions: 4
Compression:
Stored size: 1.81 KB
Contents
require "rbconfig" require 'test/unit' require 'socket' require 'openssl' require 'puma/minissl' require 'puma/server' require 'net/https' class TestPumaServerSSL < Test::Unit::TestCase def setup @port = 3212 @host = "127.0.0.1" @app = lambda { |env| [200, {}, [env['rack.url_scheme']]] } ctx = Puma::MiniSSL::Context.new if defined?(JRUBY_VERSION) ctx.keystore = File.expand_path "../../examples/puma/keystore.jks", __FILE__ ctx.keystore_pass = 'blahblah' else ctx.key = File.expand_path "../../examples/puma/puma_keypair.pem", __FILE__ ctx.cert = File.expand_path "../../examples/puma/cert_puma.pem", __FILE__ end ctx.verify_mode = Puma::MiniSSL::VERIFY_NONE @events = Puma::Events.new STDOUT, STDERR @server = Puma::Server.new @app, @events @server.add_ssl_listener @host, @port, ctx @server.run @http = Net::HTTP.new @host, @port @http.use_ssl = true @http.verify_mode = OpenSSL::SSL::VERIFY_NONE end def teardown @server.stop(true) end def test_url_scheme_for_https body = nil @http.start do req = Net::HTTP::Get.new "/", {} @http.request(req) do |rep| body = rep.body end end assert_equal "https", body end def test_very_large_return giant = "x" * 2056610 @server.app = proc do [200, {}, [giant]] end body = nil @http.start do req = Net::HTTP::Get.new "/" @http.request(req) do |rep| body = rep.body end end assert_equal giant.bytesize, body.bytesize end def test_form_submit body = nil @http.start do req = Net::HTTP::Post.new '/' req.set_form_data('a' => '1', 'b' => '2') @http.request(req) do |rep| body = rep.body end end assert_equal "https", body end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
puma-2.9.1-java | test/test_puma_server_ssl.rb |
puma-2.9.1 | test/test_puma_server_ssl.rb |
puma-2.9.0-java | test/test_puma_server_ssl.rb |
puma-2.9.0 | test/test_puma_server_ssl.rb |