Skip to content

Commit 5b22480

Browse files
author
Jerry Cheung
committed
translate spec/integration/ssl_ber_spec to minitest
1 parent 1b7bba9 commit 5b22480

File tree

3 files changed

+38
-39
lines changed

3 files changed

+38
-39
lines changed

spec/integration/ssl_ber_spec.rb

Lines changed: 0 additions & 39 deletions
This file was deleted.

test/common.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# Add 'lib' to load path.
22
require 'test/unit'
33
require 'net/ldap'
4+
require 'flexmock/test_unit'

test/test_ssl_ber.rb

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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

0 commit comments

Comments
 (0)