From 0f67c2e23907b5973342f013d4d9c53d34b7c8da Mon Sep 17 00:00:00 2001 From: Kevin McCormack Date: Fri, 9 Oct 2026 19:05:38 -0400 Subject: [PATCH 1/2] Patch bind success Use the specific success code. --- lib/net/ldap.rb | 2 +- test/test_ldap.rb | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/net/ldap.rb b/lib/net/ldap.rb index 8dca73c0..a38da759 100644 --- a/lib/net/ldap.rb +++ b/lib/net/ldap.rb @@ -874,7 +874,7 @@ def bind(auth = @auth) end end - @result.success? + @result.result_code == ResultCodeSuccess end end diff --git a/test/test_ldap.rb b/test/test_ldap.rb index 6c061475..47b139ca 100644 --- a/test/test_ldap.rb +++ b/test/test_ldap.rb @@ -48,6 +48,24 @@ def test_instrument_bind assert_equal bind_result, payload[:bind] end + def test_bind_requires_success_result_code + [Net::LDAP::ResultCodeSuccess, + Net::LDAP::ResultCodeReferral, + Net::LDAP::ResultCodeCompareFalse, + Net::LDAP::ResultCodeCompareTrue, + Net::LDAP::ResultCodeSaslBindInProgress, + Net::LDAP::ResultCodeInvalidCredentials].each do |code| + ber = Net::BER::BerIdentifiedArray.new([code, "", ""]) + ber.ber_identifier = Net::LDAP::PDU::BindResult + result = Net::LDAP::PDU.new([1, ber]) + @subject.connection = flexmock(:bind => result) + + assert_equal code == Net::LDAP::ResultCodeSuccess, @subject.bind, + "unexpected bind result for code #{code}" + assert_equal code, @subject.get_operation_result.code + end + end + def test_instrument_search events = @service.subscribe "search.net_ldap" From 683f95ba53e5dff24070ffb20000b831d32d7b68 Mon Sep 17 00:00:00 2001 From: Kevin McCormack Date: Fri, 9 Oct 2026 19:51:07 -0400 Subject: [PATCH 2/2] Fix timeout message assertion for Ruby 3.4 --- test/integration/test_bind.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/integration/test_bind.rb b/test/integration/test_bind.rb index 4a1a0194..f9cf8537 100644 --- a/test/integration/test_bind.rb +++ b/test/integration/test_bind.rb @@ -14,9 +14,8 @@ def test_bind_timeout error = assert_raise Net::LDAP::Error do @ldap.bind BIND_CREDS end - msgs = ['Operation timed out - user specified timeout', - 'Connection timed out - user specified timeout'] - assert_send([msgs, :include?, error.message]) + # Ruby 3.4+ appends " for host:port" to the message + assert_match(/\A(Operation|Connection) timed out - user specified timeout/, error.message) end def test_bind_anonymous_fail