File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -1243,5 +1243,11 @@ def new_connection
12431243 :hosts => @hosts ,
12441244 :encryption => @encryption ,
12451245 :instrumentation_service => @instrumentation_service
1246+ rescue Errno ::ECONNREFUSED , Net ::LDAP ::ConnectionRefusedError => e
1247+ @result = {
1248+ :resultCode => 52 ,
1249+ :errorMessage => ResultStrings [ ResultCodeUnavailable ]
1250+ }
1251+ raise e
12461252 end
12471253end # class LDAP
Original file line number Diff line number Diff line change @@ -47,6 +47,19 @@ def test_list_of_hosts_with_all_hosts_failure
4747 end
4848 end
4949
50+ def test_result_for_connection_failed_is_set
51+ flexmock ( TCPSocket ) . should_receive ( :new ) . and_raise ( Errno ::ECONNREFUSED )
52+
53+ ldap_client = Net ::LDAP . new ( host : '127.0.0.1' , port : 12345 )
54+
55+ assert_raise Net ::LDAP ::ConnectionRefusedError do
56+ ldap_client . bind ( method : :simple , username : 'asdf' , password : 'asdf' )
57+ end
58+
59+ assert_equal ( ldap_client . get_operation_result . code , 52 )
60+ assert_equal ( ldap_client . get_operation_result . message , 'Unavailable' )
61+ end
62+
5063 def test_unresponsive_host
5164 assert_raise Net ::LDAP ::Error do
5265 Net ::LDAP ::Connection . new ( :host => 'test.mocked.com' , :port => 636 )
You can’t perform that action at this time.
0 commit comments