@@ -95,6 +95,22 @@ def test_bind_tls_with_bad_hostname_ca_default_opt_merge_fails
9595 )
9696 end
9797
98+ def test_bind_tls_with_bad_hostname_ca_no_opt_merge_fails
99+ @ldap . host = '127.0.0.1'
100+ @ldap . encryption (
101+ method : :start_tls ,
102+ tls_options : { ca_file : CA_FILE } ,
103+ )
104+ error = assert_raise Net ::LDAP ::Error ,
105+ Net ::LDAP ::ConnectionRefusedError do
106+ @ldap . bind BIND_CREDS
107+ end
108+ assert_equal (
109+ "hostname \" #{ @ldap . host } \" does not match the server certificate" ,
110+ error . message ,
111+ )
112+ end
113+
98114 def test_bind_tls_with_valid_hostname_default_opts_passes
99115 @ldap . host = 'localhost'
100116 @ldap . encryption (
@@ -164,7 +180,7 @@ def test_bind_tls_with_multiple_bogus_hosts_no_verification
164180 @ldap . get_operation_result . inspect
165181 end
166182
167- def test_bind_tls_with_multiple_bogus_hosts_ca_check_only
183+ def test_bind_tls_with_multiple_bogus_hosts_ca_check_only_fails
168184 omit_unless ENV [ 'TRAVIS' ] == 'true'
169185
170186 @ldap . host = nil
@@ -173,7 +189,11 @@ def test_bind_tls_with_multiple_bogus_hosts_ca_check_only
173189 method : :start_tls ,
174190 tls_options : { ca_file : CA_FILE } ,
175191 )
176- assert @ldap . bind ( BIND_CREDS ) ,
177- @ldap . get_operation_result . inspect
192+ error = assert_raise Net ::LDAP ::Error ,
193+ Net ::LDAP ::ConnectionError do
194+ @ldap . bind BIND_CREDS
195+ end
196+ assert_equal ( "Unable to connect to any given server: " ,
197+ error . message . split ( "\n " ) . shift )
178198 end
179199end
0 commit comments