File tree 2 files changed +19
-0
lines changed 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -1243,5 +1243,11 @@ def new_connection
1243
1243
:hosts => @hosts ,
1244
1244
:encryption => @encryption ,
1245
1245
: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
1246
1252
end
1247
1253
end # 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
47
47
end
48
48
end
49
49
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
+
50
63
def test_unresponsive_host
51
64
assert_raise Net ::LDAP ::Error do
52
65
Net ::LDAP ::Connection . new ( :host => 'test.mocked.com' , :port => 636 )
You can’t perform that action at this time.
0 commit comments