Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/net/ldap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ def bind(auth = @auth)
end
end

@result.success?
@result.result_code == ResultCodeSuccess
end
end

Expand Down
5 changes: 2 additions & 3 deletions test/integration/test_bind.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions test/test_ldap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
Loading