Skip to content

Commit

Permalink
Merge pull request openssl#344 from rhenium/ky/ssl-test-fixups
Browse files Browse the repository at this point in the history
test/openssl/test_ssl: test fixes
  • Loading branch information
rhenium committed Feb 19, 2020
2 parents ad379a2 + 3a68ea4 commit 4a7249e
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions test/openssl/test_ssl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,17 @@ def test_socket_open_with_context
def test_socket_open_with_local_address_port_context
start_server { |port|
begin
# Guess a free port number
random_port = rand(49152..65535)
ctx = OpenSSL::SSL::SSLContext.new
ssl = OpenSSL::SSL::SSLSocket.open("127.0.0.1", port, "127.0.0.1", 8000, context: ctx)
ssl = OpenSSL::SSL::SSLSocket.open("127.0.0.1", port, "127.0.0.1", random_port, context: ctx)
ssl.sync_close = true
ssl.connect

assert_equal ssl.context, ctx
assert_equal ctx, ssl.context
assert_equal random_port, ssl.io.local_address.ip_port
ssl.puts "abc"; assert_equal "abc\n", ssl.gets
rescue Errno::EADDRINUSE
ensure
ssl&.close
end
Expand Down Expand Up @@ -127,7 +131,7 @@ def test_add_certificate_multiple_certs
add0_chain_supported = openssl?(1, 0, 2)

if add0_chain_supported
ca2_key = Fixtures.pkey("rsa2048")
ca2_key = Fixtures.pkey("rsa-3")
ca2_exts = [
["basicConstraints", "CA:TRUE", true],
["keyUsage", "cRLSign, keyCertSign", true],
Expand Down Expand Up @@ -206,19 +210,6 @@ def test_sysread_and_syswrite
}
end

# TODO fix this test
# def test_sysread_nonblock_and_syswrite_nonblock_keywords
# start_server do |port|
# server_connect(port) do |ssl|
# assert_warning("") do
# ssl.send(:syswrite_nonblock, "12", exception: false)
# ssl.send(:sysread_nonblock, 1, exception: false) rescue nil
# ssl.send(:sysread_nonblock, 1, String.new, exception: false) rescue nil
# end
# end
# end
# end

def test_sync_close
start_server do |port|
begin
Expand Down Expand Up @@ -496,12 +487,14 @@ def test_finished_messages
ctx = OpenSSL::SSL::SSLContext.new
ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE
server_connect(port, ctx) { |ssl|
ssl.puts "abc"; ssl.gets

client_finished = ssl.finished_message
client_peer_finished = ssl.peer_finished_message
sleep 0.05
ssl.send :stop
}
}
assert_not_nil(server_finished)
assert_not_nil(client_finished)
assert_equal(server_finished, client_peer_finished)
assert_equal(server_peer_finished, client_finished)
end
Expand Down Expand Up @@ -1376,11 +1369,16 @@ def test_get_ephemeral_key
ctx.ssl_version = :TLSv1_2
ctx.ciphers = "kRSA"
}
start_server(ctx_proc: ctx_proc1) do |port|
start_server(ctx_proc: ctx_proc1, ignore_listener_error: true) do |port|
ctx = OpenSSL::SSL::SSLContext.new
ctx.ssl_version = :TLSv1_2
ctx.ciphers = "kRSA"
server_connect(port, ctx) { |ssl| assert_nil ssl.tmp_key }
begin
server_connect(port, ctx) { |ssl| assert_nil ssl.tmp_key }
rescue OpenSSL::SSL::SSLError
# kRSA seems disabled
raise unless $!.message =~ /no cipher/
end
end
end

Expand Down

0 comments on commit 4a7249e

Please sign in to comment.