@@ -21,6 +21,10 @@ def test_binds_with_open
21
21
assert_equal 1 , events . size
22
22
end
23
23
24
+ # NOTE: query for two or more entries so that the socket must be read
25
+ # multiple times.
26
+ # See The Problem: https://github.com/ruby-ldap/ruby-net-ldap/issues/136
27
+
24
28
def test_nested_search_without_open
25
29
entries = [ ]
26
30
nested_entry = nil
@@ -48,4 +52,37 @@ def test_nested_search_with_open
48
52
assert_equal "user3" , nested_entry . uid . first
49
53
assert_equal %w( user1 user2 ) , entries
50
54
end
55
+
56
+ def test_nested_add_with_open
57
+ entries = [ ]
58
+ nested_entry = nil
59
+
60
+ dn = "uid=nested-open-added-user1,ou=People,dc=rubyldap,dc=com"
61
+ attrs = {
62
+ objectclass : %w( top inetOrgPerson organizationalPerson person ) ,
63
+ uid : "nested-open-added-user1" ,
64
+ cn : "nested-open-added-user1" ,
65
+ sn : "nested-open-added-user1" ,
66
+
67
+ }
68
+
69
+ @ldap . authenticate "cn=admin,dc=rubyldap,dc=com" , "passworD1"
70
+ @ldap . delete dn : dn
71
+
72
+ @ldap . open do
73
+ @ldap . search ( filter : "(|(uid=user1)(uid=user2))" , base : "ou=People,dc=rubyldap,dc=com" ) do |entry |
74
+ entries << entry . uid . first
75
+
76
+ nested_entry ||= begin
77
+ assert @ldap . add ( dn : dn , attributes : attrs ) , @ldap . get_operation_result . inspect
78
+ @ldap . search ( base : dn , scope : Net ::LDAP ::SearchScope_BaseObject ) . first
79
+ end
80
+ end
81
+ end
82
+
83
+ assert_equal %w( user1 user2 ) , entries
84
+ assert_equal "nested-open-added-user1" , nested_entry . uid . first
85
+ ensure
86
+ @ldap . delete dn : dn
87
+ end
51
88
end
0 commit comments