Commit 925bbe34 authored by Bob Van Landuyt's avatar Bob Van Landuyt Committed by Bob Van Landuyt

Return `nil` when user is not found by email.

Otherwise the sync would crash, causing all later users not being synced.
parent 377f34bf
---
title: Fix crash in LDAP sync when user was removed.
merge_request: 2289
author:
......@@ -12,6 +12,8 @@ module EE
found_user = adapter.user(possible_attribute, email)
return found_user if found_user
end
nil
end
end
......
......@@ -10,15 +10,23 @@ describe Gitlab::LDAP::Person do
end
describe '.find_by_email' do
it 'tries finding for each configured email attribute' do
adapter = ldap_adapter
let(:adapter) { ldap_adapter }
it 'tries finding for each configured email attribute' do
expect(adapter).to receive(:user).with('mail', 'jane@gitlab.com')
expect(adapter).to receive(:user).with('email', 'jane@gitlab.com')
expect(adapter).to receive(:user).with('userPrincipalName', 'jane@gitlab.com')
described_class.find_by_email('jane@gitlab.com', adapter)
end
it 'returns nil when no user was found' do
allow(adapter).to receive(:user)
found_user = described_class.find_by_email('jane@gitlab.com', adapter)
expect(found_user).to eq(nil)
end
end
describe '#kerberos_principal' do
......
......@@ -37,6 +37,12 @@ describe Gitlab::LDAP::Access, lib: true do
access.allowed?
end
context 'when looking for a user by email' do
let(:user) { create(:omniauth_user, external_email: true) }
it { is_expected.to be_falsey }
end
end
context 'when the user is found' do
......
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