Make AD check for access work properly

This commit is contained in:
Jan-Willem van der Meer
2014-10-10 10:46:07 +02:00
parent adee309127
commit 8271fac0a9
3 changed files with 12 additions and 15 deletions
+2 -3
View File
@@ -36,9 +36,8 @@ module Gitlab
def allowed?
if Gitlab::LDAP::Person.find_by_dn(user.extern_uid, adapter)
if ldap_config.active_directory
!Gitlab::LDAP::Person.disabled_via_active_directory?(user.extern_uid, adapter)
end
return true unless ldap_config.active_directory
!Gitlab::LDAP::Person.disabled_via_active_directory?(user.extern_uid, adapter)
else
false
end
+4
View File
@@ -60,6 +60,10 @@ module Gitlab
options['admin_group']
end
def active_directory
options['active_directory']
end
protected
def base_config
Gitlab.config.ldap
+6 -12
View File
@@ -28,19 +28,13 @@ describe Gitlab::LDAP::Access do
it { should be_true }
end
context 'and has no disabled flag in active diretory' do
before {
Gitlab::LDAP::Person.stub(disabled_via_active_directory?: false)
Gitlab.config.ldap['enabled'] = true
Gitlab.config.ldap['active_directory'] = false
}
context 'withoud ActiveDirectory enabled' do
before do
Gitlab::LDAP::Config.stub(enabled?: true)
Gitlab::LDAP::Config.any_instance.stub(active_directory: false)
end
after {
Gitlab.config.ldap['enabled'] = false
Gitlab.config.ldap['active_directory'] = true
}
it { should be_false }
it { should be_true }
end
end
end