Commit 453ccf95 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'bvl-ldap-group-sync-deleted-user' into 'master'

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

Closes #2769

See merge request !2289
parents 768fe1ad 925bbe34
---
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