File tree Expand file tree Collapse file tree 3 files changed +38
-39
lines changed Expand file tree Collapse file tree 3 files changed +38
-39
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11# Add 'lib' to load path.
22require 'test/unit'
33require 'net/ldap'
4+ require 'flexmock/test_unit'
Original file line number Diff line number Diff line change 1+ require 'common'
2+ require 'timeout'
3+
4+ class TestSSLBER < Test ::Unit ::TestCase
5+ # Transmits str to @to and reads it back from @from.
6+ #
7+ def transmit ( str )
8+ Timeout ::timeout ( 1 ) do
9+ @to . write ( str )
10+ @to . close
11+
12+ @from . read
13+ end
14+ end
15+
16+ def setup
17+ @from , @to = IO . pipe
18+
19+ # The production code operates on sockets, which do need #connect called
20+ # on them to work. Pipes are more robust for this test, so we'll skip
21+ # the #connect call since it fails.
22+ flexmock ( OpenSSL ::SSL ::SSLSocket ) .
23+ new_instances . should_receive ( :connect => nil )
24+
25+ @to = Net ::LDAP ::Connection . wrap_with_ssl ( @to )
26+ @from = Net ::LDAP ::Connection . wrap_with_ssl ( @from )
27+ end
28+
29+ def test_transmit_strings
30+ assert_equal "foo" , transmit ( "foo" )
31+ end
32+
33+ def test_transmit_ber_encoded_numbers
34+ @to . write 1234 . to_ber
35+ assert_equal 1234 , @from . read_ber
36+ end
37+ end
You can’t perform that action at this time.
0 commit comments