summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Kozono <mkozono@gmail.com>2017-06-08 17:03:57 -0700
committerMichael Kozono <mkozono@gmail.com>2017-06-09 09:48:33 -0700
commite2935c77492a56168222e20fc93bcf4e27003dff (patch)
treeec8086f0786d922d1729212acd6916dbaffae801
parent60c5e2155f970f965002972c15b620590c421cb2 (diff)
downloadgitlab-ce-mk-add-ldap-ssl-certificate-verification.tar.gz
Set `Net::LDAP` `ssl_version` optionmk-add-ldap-ssl-certificate-verification
-rw-r--r--lib/gitlab/ldap/config.rb1
-rw-r--r--spec/lib/gitlab/ldap/config_spec.rb30
2 files changed, 31 insertions, 0 deletions
diff --git a/lib/gitlab/ldap/config.rb b/lib/gitlab/ldap/config.rb
index 983c79a6364..a48a485dffd 100644
--- a/lib/gitlab/ldap/config.rb
+++ b/lib/gitlab/ldap/config.rb
@@ -192,6 +192,7 @@ module Gitlab
end
opts[:ca_file] = options['ca_file'] if options['ca_file'].present?
+ opts[:ssl_version] = options['ssl_version'] if options['ssl_version'].present?
opts
end
diff --git a/spec/lib/gitlab/ldap/config_spec.rb b/spec/lib/gitlab/ldap/config_spec.rb
index 4544a38876c..e24c7d6b9a2 100644
--- a/spec/lib/gitlab/ldap/config_spec.rb
+++ b/spec/lib/gitlab/ldap/config_spec.rb
@@ -168,6 +168,36 @@ describe Gitlab::LDAP::Config, lib: true do
expect(config.adapter_options[:encryption][:tls_options]).not_to have_key(:ca_file)
end
end
+
+ context 'when ssl_version is specified' do
+ it 'passes it through in tls_options' do
+ stub_ldap_config(
+ options: {
+ 'host' => 'ldap.example.com',
+ 'port' => 686,
+ 'encryption' => 'simple_tls',
+ 'ssl_version' => 'TLSv1_2'
+ }
+ )
+
+ expect(config.adapter_options[:encryption][:tls_options]).to include({ ssl_version: 'TLSv1_2' })
+ end
+ end
+
+ context 'when ssl_version is a blank string' do
+ it 'does not add the ssl_version key to tls_options' do
+ stub_ldap_config(
+ options: {
+ 'host' => 'ldap.example.com',
+ 'port' => 686,
+ 'encryption' => 'simple_tls',
+ 'ssl_version' => ' '
+ }
+ )
+
+ expect(config.adapter_options[:encryption][:tls_options]).not_to have_key(:ssl_version)
+ end
+ end
end
describe '#omniauth_options' do