File tree Expand file tree Collapse file tree 4 files changed +8
-34
lines changed Expand file tree Collapse file tree 4 files changed +8
-34
lines changed Original file line number Diff line number Diff line change @@ -1328,7 +1328,7 @@ def new_connection
1328
1328
# Force connect to see if there's a connection error
1329
1329
connection . socket
1330
1330
connection
1331
- rescue Errno ::ECONNREFUSED , Errno ::ETIMEDOUT , Net :: LDAP :: ConnectionRefusedError => e
1331
+ rescue Errno ::ECONNREFUSED , Errno ::ETIMEDOUT => e
1332
1332
@result = {
1333
1333
:resultCode => 52 ,
1334
1334
:errorMessage => ResultStrings [ ResultCodeUnavailable ] ,
Original file line number Diff line number Diff line change 1
1
class Net ::LDAP
2
- class LdapError < StandardError
3
- def message
4
- "Deprecation warning: Net::LDAP::LdapError is no longer used. Use Net::LDAP::Error or rescue one of it's subclasses. \n " + super
5
- end
6
- end
7
-
8
2
class Error < StandardError ; end
9
3
10
4
class AlreadyOpenedError < Error ; end
11
5
class SocketError < Error ; end
12
- class ConnectionRefusedError < Error ;
13
- def initialize ( *args )
14
- warn_deprecation_message
15
- super
16
- end
17
-
18
- def message
19
- warn_deprecation_message
20
- super
21
- end
22
-
23
- private
24
-
25
- def warn_deprecation_message
26
- warn "Deprecation warning: Net::LDAP::ConnectionRefused will be deprecated. Use Errno::ECONNREFUSED instead."
27
- end
28
- end
29
6
class ConnectionError < Error
30
7
def self . new ( errors )
31
8
error = errors . first . first
32
9
if errors . size == 1
33
- if error . kind_of? Errno ::ECONNREFUSED
34
- return Net ::LDAP ::ConnectionRefusedError . new ( error . message )
35
- end
10
+ return error if error . is_a? Errno ::ECONNREFUSED
36
11
37
12
return Net ::LDAP ::Error . new ( error . message )
38
13
end
Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ def test_bind_tls_with_bad_hostname_verify_peer_ca_fails
74
74
ca_file : CA_FILE } ,
75
75
)
76
76
error = assert_raise Net ::LDAP ::Error ,
77
- Net :: LDAP :: ConnectionRefusedError do
77
+ Errno :: ECONNREFUSED do
78
78
@ldap . bind BIND_CREDS
79
79
end
80
80
assert_equal (
@@ -90,7 +90,7 @@ def test_bind_tls_with_bad_hostname_ca_default_opt_merge_fails
90
90
tls_options : TLS_OPTS . merge ( ca_file : CA_FILE ) ,
91
91
)
92
92
error = assert_raise Net ::LDAP ::Error ,
93
- Net :: LDAP :: ConnectionRefusedError do
93
+ Errno :: ECONNREFUSED do
94
94
@ldap . bind BIND_CREDS
95
95
end
96
96
assert_equal (
@@ -106,7 +106,7 @@ def test_bind_tls_with_bad_hostname_ca_no_opt_merge_fails
106
106
tls_options : { ca_file : CA_FILE } ,
107
107
)
108
108
error = assert_raise Net ::LDAP ::Error ,
109
- Net :: LDAP :: ConnectionRefusedError do
109
+ Errno :: ECONNREFUSED do
110
110
@ldap . bind BIND_CREDS
111
111
end
112
112
assert_equal (
@@ -141,7 +141,7 @@ def test_bind_tls_with_bogus_hostname_system_ca_fails
141
141
@ldap . host = 'cert.mismatch.example.org'
142
142
@ldap . encryption ( method : :start_tls , tls_options : { } )
143
143
error = assert_raise Net ::LDAP ::Error ,
144
- Net :: LDAP :: ConnectionRefusedError do
144
+ Errno :: ECONNREFUSED do
145
145
@ldap . bind BIND_CREDS
146
146
end
147
147
assert_equal (
Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ def test_result_for_connection_failed_is_set
61
61
62
62
ldap_client = Net ::LDAP . new ( host : '127.0.0.1' , port : 12345 )
63
63
64
- assert_raise Net :: LDAP :: ConnectionRefusedError do
64
+ assert_raise Errno :: ECONNREFUSED do
65
65
ldap_client . bind ( method : :simple , username : 'asdf' , password : 'asdf' )
66
66
end
67
67
@@ -86,11 +86,10 @@ def test_blocked_port
86
86
def test_connection_refused
87
87
connection = Net ::LDAP ::Connection . new ( :host => "fail.Errno::ECONNREFUSED" , :port => 636 , :socket_class => FakeTCPSocket )
88
88
stderr = capture_stderr do
89
- assert_raise Net :: LDAP :: ConnectionRefusedError do
89
+ assert_raise Errno :: ECONNREFUSED do
90
90
connection . socket
91
91
end
92
92
end
93
- assert_equal ( "Deprecation warning: Net::LDAP::ConnectionRefused will be deprecated. Use Errno::ECONNREFUSED instead.\n " , stderr )
94
93
end
95
94
96
95
def test_connection_timeout
You can’t perform that action at this time.
0 commit comments