Commit 1c3a2bc3 authored by Michael Kozono's avatar Michael Kozono

Setup LDAP settings properly

parent f3203cbb
...@@ -139,6 +139,8 @@ if Settings.ldap['enabled'] || Rails.env.test? ...@@ -139,6 +139,8 @@ if Settings.ldap['enabled'] || Rails.env.test?
end end
Settings.ldap['servers'].each do |key, server| Settings.ldap['servers'].each do |key, server|
server = Settingslogic.new(server)
server['label'] ||= 'LDAP' server['label'] ||= 'LDAP'
server['timeout'] ||= 10.seconds server['timeout'] ||= 10.seconds
server['block_auto_created_users'] = false if server['block_auto_created_users'].nil? server['block_auto_created_users'] = false if server['block_auto_created_users'].nil?
...@@ -165,6 +167,8 @@ if Settings.ldap['enabled'] || Rails.env.test? ...@@ -165,6 +167,8 @@ if Settings.ldap['enabled'] || Rails.env.test?
MSG MSG
Rails.logger.warn(message) Rails.logger.warn(message)
end end
Settings.ldap['servers'][key] = server
end end
end end
......
...@@ -2,6 +2,22 @@ require 'spec_helper' ...@@ -2,6 +2,22 @@ require 'spec_helper'
require_relative '../../config/initializers/1_settings' require_relative '../../config/initializers/1_settings'
describe Settings do describe Settings do
describe '#ldap' do
it 'can be accessed with dot syntax all the way down' do
expect(Gitlab.config.ldap.servers.main.label).to eq('ldap')
end
# Specifically trying to cause this error discovered in EE when removing the
# reassignment of each server element with Settingslogic.
#
# `undefined method `label' for #<Hash:0x007fbd18b59c08>`
#
it 'can be accessed in a very specific way that breaks without reassigning each element with Settingslogic' do
server_settings = Gitlab.config.ldap.servers['main']
expect(server_settings.label).to eq('ldap')
end
end
describe '#repositories' do describe '#repositories' do
it 'assigns the default failure attributes' do it 'assigns the default failure attributes' do
repository_settings = Gitlab.config.repositories.storages['broken'] repository_settings = Gitlab.config.repositories.storages['broken']
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment