Sha256: 261f033e04a9cd10b191c3b2ee13c0cd9107098e260601d94dbec1554c254efe

Contents?: true

Size: 1018 Bytes

Versions: 12

Compression:

Stored size: 1018 Bytes

Contents

require_relative 'test_helper'
require 'timeout'

class TestSSLBER < Test::Unit::TestCase
  # Transmits str to @to and reads it back from @from.
  #
  def transmit(str)
    Timeout::timeout(1) do
      @to.write(str)
      @to.close

      @from.read
    end
  end

  def setup
    @from, @to = IO.pipe

    # The production code operates on sockets, which do need #connect called
    # on them to work. Pipes are more robust for this test, so we'll skip
    # the #connect call since it fails.
    #
    # TODO: Replace test with real socket
    # https://github.com/ruby-ldap/ruby-net-ldap/pull/121#discussion_r18746386
    flexmock(OpenSSL::SSL::SSLSocket).
      new_instances.should_receive(:connect => nil)

    @to   = Net::LDAP::Connection.wrap_with_ssl(@to)
    @from = Net::LDAP::Connection.wrap_with_ssl(@from)
  end

  def test_transmit_strings
    assert_equal "foo", transmit("foo")
  end

  def test_transmit_ber_encoded_numbers
    @to.write 1234.to_ber
    assert_equal 1234, @from.read_ber
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
net-ldap-0.16.2 test/test_ssl_ber.rb
net-ldap-0.16.1 test/test_ssl_ber.rb
net-ldap-0.16.0 test/test_ssl_ber.rb
net-ldap-0.15.0 test/test_ssl_ber.rb
net-ldap-0.14.0 test/test_ssl_ber.rb
net-ldap-0.13.0 test/test_ssl_ber.rb
net-ldap-0.12.1 test/test_ssl_ber.rb
net-ldap-0.12.0 test/test_ssl_ber.rb
net-ldap-0.11 test/test_ssl_ber.rb
net-ldap-0.10.1 test/test_ssl_ber.rb
net-ldap-0.10.0 test/test_ssl_ber.rb
net-ldap-0.9.0 test/test_ssl_ber.rb