Skip to content

Commit bb798c4

Browse files
committed
Add failing test for add nested in an open search
This is because Net::LDAP::Connection#add calls read without queueing, meaning it can read the wrong message off the socket.
1 parent f40c46e commit bb798c4

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

test/integration/test_open.rb

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ def test_binds_with_open
2121
assert_equal 1, events.size
2222
end
2323

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+
2428
def test_nested_search_without_open
2529
entries = []
2630
nested_entry = nil
@@ -48,4 +52,37 @@ def test_nested_search_with_open
4852
assert_equal "user3", nested_entry.uid.first
4953
assert_equal %w(user1 user2), entries
5054
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
5188
end

0 commit comments

Comments
 (0)