Sha256: b50946f45f500ab410b6587d8d33cf218d091f9e9577e02be4e0beba47785b01

Contents?: true

Size: 1.23 KB

Versions: 26

Compression:

Stored size: 1.23 KB

Contents

require 'em_test_helper'

class TestSSLEchoData < Test::Unit::TestCase
  def setup
      $dir = File.dirname(File.expand_path(__FILE__)) + '/'
  end

  module SslEchoServer
    def post_init
      start_tls(:private_key_file => $dir+'server.key', :cert_chain_file => $dir+'server.crt')
    end

    def receive_data data
      send_data data
    end

  end

  module SslEchoClient
    def connection_completed
      start_tls
    end

    def ssl_handshake_completed
      send_data $expected_return_data[$index]
      $index += 1
    end

    def receive_data data
      $actual_return_data ||= []
      $actual_return_data << data
      if $index < 10
        send_data $expected_return_data[$index]
        $index += 1
      else
        @stopping_on_purpose = true
        EM.stop
      end
    end

    def unbind
      fail "unexpected socket close" unless @stopping_on_purpose
    end

  end

  def test_ssl_echo_data
    $expected_return_data = (1..10).map {|n| "Hello, world! (#{n})"}
    $index = 0

    EM.run {
      EM.add_timer(12) { fail "TIMEOUT" }
      EM.start_server("127.0.0.1", 9999, SslEchoServer)
      EM.connect("127.0.0.1", 9999, SslEchoClient)
    }

    assert_equal($expected_return_data, $actual_return_data)
  end

end if EM.ssl?

Version data entries

26 entries across 26 versions & 2 rubygems

Version Path
sensu-em-2.7.0-java tests/test_ssl_echo_data.rb
sensu-em-2.6.0-java tests/test_ssl_echo_data.rb
sensu-em-2.5.2-java tests/test_ssl_echo_data.rb
sensu-em-2.5.2 tests/test_ssl_echo_data.rb
sensu-em-2.5.1-java tests/test_ssl_echo_data.rb
sensu-em-2.5.1 tests/test_ssl_echo_data.rb
sensu-em-2.5.0-java tests/test_ssl_echo_data.rb
sensu-em-2.5.0 tests/test_ssl_echo_data.rb
sensu-em-2.5.0.beta-java tests/test_ssl_echo_data.rb
sensu-em-2.5.0.beta tests/test_ssl_echo_data.rb
sensu-em-2.4.1-java tests/test_ssl_echo_data.rb
sensu-em-2.4.1 tests/test_ssl_echo_data.rb
sensu-em-2.4.0-x86-mingw32 tests/test_ssl_echo_data.rb
sonixlabs-eventmachine-java-1.0.3.2-java tests/test_ssl_echo_data.rb
sonixlabs-eventmachine-java-1.0.3.1-java tests/test_ssl_echo_data.rb
sonixlabs-eventmachine-java-1.0.3.1 tests/test_ssl_echo_data.rb
sensu-em-2.4.0-java tests/test_ssl_echo_data.rb
sensu-em-2.4.0 tests/test_ssl_echo_data.rb
sensu-em-2.3.0-java tests/test_ssl_echo_data.rb
sensu-em-2.3.0 tests/test_ssl_echo_data.rb