Skip to content

Commit 4e5a8e7

Browse files
author
Tom Maher
committed
improve system store tests
1 parent 3aebc3d commit 4e5a8e7

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

Diff for: test/integration/test_bind.rb

+23-1
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,30 @@ def test_bind_tls_with_multiple_bogus_hosts_ca_check_only_fails
215215
def test_bind_tls_valid_hostname_system_ca_on_travis_passes
216216
omit_unless ENV['TRAVIS'] == 'true'
217217

218-
@ldap.encryption(method: :start_tls, tls_options: {})
218+
@ldap.encryption(
219+
method: :start_tls,
220+
tls_options: { verify_mode: OpenSSL::SSL::VERIFY_PEER },
221+
)
219222
assert @ldap.bind(BIND_CREDS),
220223
@ldap.get_operation_result.inspect
221224
end
225+
226+
# Inverse of the above! Don't run this on Travis, only on Vagrant.
227+
# Since Vagrant's hypervisor *won't* have the CA in the system
228+
# x509 store, we can assume validation will fail
229+
def test_bind_tls_valid_hostname_system_on_vagrant_fails
230+
omit_if ENV['TRAVIS'] == 'true'
231+
232+
@ldap.encryption(
233+
method: :start_tls,
234+
tls_options: { verify_mode: OpenSSL::SSL::VERIFY_PEER },
235+
)
236+
error = assert_raise Net::LDAP::Error do
237+
@ldap.bind BIND_CREDS
238+
end
239+
assert_equal(
240+
"SSL_connect returned=1 errno=0 state=error: certificate verify failed",
241+
error.message,
242+
)
243+
end
222244
end

0 commit comments

Comments
 (0)