mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* test/webrick/test_ssl_server.rb: Added basic test for webrick/ssl
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54939 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ed5b985650
commit
b39d4eac28
2 changed files with 32 additions and 0 deletions
|
@ -1,3 +1,7 @@
|
|||
Sat May 7 21:55:12 2016 SHIBATA Hiroshi <hsbt@ruby-lang.org>
|
||||
|
||||
* test/webrick/test_ssl_server.rb: Added basic test for `webrick/ssl`
|
||||
|
||||
Sat May 7 16:22:13 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* random.c (int_pair_to_real_inclusive): optimize to multiply
|
||||
|
|
28
test/webrick/test_ssl_server.rb
Normal file
28
test/webrick/test_ssl_server.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
require "test/unit"
|
||||
require "webrick"
|
||||
require "webrick/ssl"
|
||||
require_relative "utils"
|
||||
|
||||
class TestWEBrickSSLServer < Test::Unit::TestCase
|
||||
class Echo < WEBrick::GenericServer
|
||||
def run(sock)
|
||||
while line = sock.gets
|
||||
sock << line
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_self_signed_cert_server
|
||||
config = {
|
||||
:SSLEnable => true,
|
||||
:SSLCertName => [["C", "JP"], ["O", "www.ruby-lang.org"], ["CN", "Ruby"]]
|
||||
}
|
||||
TestWEBrick.start_server(Echo, config){|server, addr, port, log|
|
||||
sock = OpenSSL::SSL::SSLSocket.new(TCPSocket.new(addr, port))
|
||||
sock.connect
|
||||
sock.puts(server.ssl_context.cert.subject.to_s)
|
||||
assert_equal("/C=JP/O=www.ruby-lang.org/CN=Ruby\n", sock.gets, log.call)
|
||||
sock.close
|
||||
}
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue