Skip to content
Snippets Groups Projects
Commit 5ee6bada authored by Gabriel Mazetto's avatar Gabriel Mazetto :spy_tone1:
Browse files

Unblocks user when active_directory is disabled and it can be found

parent 4a01b5e2
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -33,7 +33,10 @@ module Gitlab
 
def allowed?
if ldap_user
return true unless ldap_config.active_directory
unless ldap_config.active_directory
user.activate if user.ldap_blocked?
return true
end
 
# Block user in GitLab if he/she was blocked in AD
if Gitlab::LDAP::Person.disabled_via_active_directory?(user.ldap_identity.extern_uid, adapter)
Loading
Loading
Loading
Loading
@@ -33,7 +33,7 @@ describe Gitlab::LDAP::Access, lib: true do
 
it { is_expected.to be_falsey }
 
it 'should block user in GitLab' do
it 'blocks user in GitLab' do
access.allowed?
expect(user).to be_blocked
expect(user).to be_ldap_blocked
Loading
Loading
@@ -78,6 +78,31 @@ describe Gitlab::LDAP::Access, lib: true do
end
 
it { is_expected.to be_truthy }
context 'when user cannot be found' do
before do
allow(Gitlab::LDAP::Person).to receive(:find_by_dn).and_return(nil)
end
it { is_expected.to be_falsey }
it 'blocks user in GitLab' do
access.allowed?
expect(user).to be_blocked
expect(user).to be_ldap_blocked
end
end
context 'when user was previously ldap_blocked' do
before do
user.ldap_block
end
it 'unblocks the user if it exists' do
access.allowed?
expect(user).not_to be_blocked
end
end
end
end
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment