@@ -210,6 +210,27 @@ def test_queued_read_setup_encryption_with_start_tls
210
210
assert result = conn . setup_encryption ( method : :start_tls )
211
211
assert_equal mock , result
212
212
end
213
+
214
+ def test_queued_read_bind_simple
215
+ result1 = make_message ( 1 , app_tag : Net ::LDAP ::PDU ::SearchResult )
216
+ result2 = make_message ( 2 , app_tag : Net ::LDAP ::PDU ::BindResult )
217
+
218
+ mock = flexmock ( "socket" )
219
+ mock . should_receive ( :read_ber ) .
220
+ and_return ( result1 ) .
221
+ and_return ( result2 )
222
+ mock . should_receive ( :write )
223
+ conn = Net ::LDAP ::Connection . new ( :socket => mock )
224
+
225
+ conn . next_msgid # simulates ongoing query
226
+
227
+ assert result = conn . bind (
228
+ method : :simple ,
229
+ username : "uid=user1,ou=People,dc=rubyldap,dc=com" ,
230
+ password : "passworD1" )
231
+ assert result . success?
232
+ assert_equal 2 , result . message_id
233
+ end
213
234
end
214
235
215
236
class TestLDAPConnectionErrors < Test ::Unit ::TestCase
@@ -257,7 +278,7 @@ def setup
257
278
def test_write_net_ldap_connection_event
258
279
ber = Net ::BER ::BerIdentifiedArray . new ( [ Net ::LDAP ::ResultCodeSuccess , "" , "" ] )
259
280
ber . ber_identifier = Net ::LDAP ::PDU ::BindResult
260
- read_result = [ 2 , ber ]
281
+ read_result = [ 1 , ber ]
261
282
@tcp_socket . should_receive ( :read_ber ) . and_return ( read_result )
262
283
263
284
events = @service . subscribe "write.net_ldap_connection"
@@ -274,7 +295,7 @@ def test_write_net_ldap_connection_event
274
295
def test_read_net_ldap_connection_event
275
296
ber = Net ::BER ::BerIdentifiedArray . new ( [ Net ::LDAP ::ResultCodeSuccess , "" , "" ] )
276
297
ber . ber_identifier = Net ::LDAP ::PDU ::BindResult
277
- read_result = [ 2 , ber ]
298
+ read_result = [ 1 , ber ]
278
299
@tcp_socket . should_receive ( :read_ber ) . and_return ( read_result )
279
300
280
301
events = @service . subscribe "read.net_ldap_connection"
@@ -291,7 +312,7 @@ def test_read_net_ldap_connection_event
291
312
def test_parse_pdu_net_ldap_connection_event
292
313
ber = Net ::BER ::BerIdentifiedArray . new ( [ Net ::LDAP ::ResultCodeSuccess , "" , "" ] )
293
314
ber . ber_identifier = Net ::LDAP ::PDU ::BindResult
294
- read_result = [ 2 , ber ]
315
+ read_result = [ 1 , ber ]
295
316
@tcp_socket . should_receive ( :read_ber ) . and_return ( read_result )
296
317
297
318
events = @service . subscribe "parse_pdu.net_ldap_connection"
@@ -305,15 +326,15 @@ def test_parse_pdu_net_ldap_connection_event
305
326
assert payload . has_key? ( :app_tag )
306
327
assert payload . has_key? ( :message_id )
307
328
assert_equal Net ::LDAP ::PDU ::BindResult , payload [ :app_tag ]
308
- assert_equal 2 , payload [ :message_id ]
329
+ assert_equal 1 , payload [ :message_id ]
309
330
pdu = payload [ :pdu ]
310
331
assert_equal Net ::LDAP ::ResultCodeSuccess , pdu . result_code
311
332
end
312
333
313
334
def test_bind_net_ldap_connection_event
314
335
ber = Net ::BER ::BerIdentifiedArray . new ( [ Net ::LDAP ::ResultCodeSuccess , "" , "" ] )
315
336
ber . ber_identifier = Net ::LDAP ::PDU ::BindResult
316
- bind_result = [ 2 , ber ]
337
+ bind_result = [ 1 , ber ]
317
338
@tcp_socket . should_receive ( :read_ber ) . and_return ( bind_result )
318
339
319
340
events = @service . subscribe "bind.net_ldap_connection"
0 commit comments