Sha256: 4ad4559b2caeb3e0043a790a23318ba4575753ed6f5ee6a7ed3b05fbb39e0d1a

Contents?: true

Size: 1.46 KB

Versions: 5

Compression:

Stored size: 1.46 KB

Contents

require 'em_test_helper'

class TestSSLCipherList < Test::Unit::TestCase

  module ServerHandler

    def post_init
      start_tls({:cipher_list => $server_cipher_list})
    end

    def ssl_handshake_completed
      $server_called_back = true
    end

  end

  module ClientHandler

    def post_init
      start_tls({:cipher_list => $client_cipher_list})
    end

    def ssl_handshake_completed
      $client_called_back = true
      EM.stop_event_loop
    end

  end

  def test_ssl_compatible_cipher_list
    $server_called_back, $client_called_back = false, false

    $server_cipher_list = "ALL"
    $client_cipher_list = "DES-CBC3-SHA"

    EM.run {
      EM.start_server("127.0.0.1", 9999, ServerHandler)
      EM.connect("127.0.0.1", 9999, ClientHandler)
      EM.add_timer(0.5) { EM.stop }
    }

    assert($server_called_back, "server ssl handshake NOT completed in 0.5 seconds")
    assert($client_called_back, "client ssl handshake NOT completed in 0.5 seconds")
  end

  def test_ssl_non_compatible_cipher_list
    $server_called_back, $client_called_back = false, false

    $server_cipher_list = ""  # Use EM default cipher which does not include "DES-CBC3-SHA"
    $client_cipher_list = "DES-CBC3-SHA"

    EM.run {
      EM.start_server("127.0.0.1", 19999, ServerHandler)
      EM.connect("127.0.0.1", 19999, ClientHandler)
      EM.add_timer(0.5) { EM.stop }
    }

    assert_equal(false, $server_called_back)
    assert_equal(false, $client_called_back)
  end

end if EM.ssl?

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
eventmachine-le-1.1.7 tests/test_ssl_cipher_list.rb
eventmachine-le-1.1.6 tests/test_ssl_cipher_list.rb
eventmachine-le-1.1.5 tests/test_ssl_cipher_list.rb
eventmachine-le-1.1.4 tests/test_ssl_cipher_list.rb
eventmachine-le-1.1.4.beta.2 tests/test_ssl_cipher_list.rb