Skip to content
Snippets Groups Projects
Commit ada2c455 authored by Drew Blessing's avatar Drew Blessing Committed by Robert Speicher
Browse files

Fix ldap email downcasing bug

parent 567403b4
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -35,7 +35,7 @@ def find_by_uid_and_provider
end
 
def find_by_email
::User.find_by(email: auth_hash.email)
::User.find_by(email: auth_hash.email.downcase)
end
 
def update_user_attributes
Loading
Loading
Loading
Loading
@@ -13,6 +13,17 @@
let(:auth_hash) do
OmniAuth::AuthHash.new(uid: 'my-uid', provider: 'ldapmain', info: info)
end
let(:ldap_user_upper_case) { Gitlab::LDAP::User.new(auth_hash_upper_case) }
let(:info_upper_case) do
{
name: 'John',
email: 'John@Example.com', # Email address has upper case chars
nickname: 'john'
}
end
let(:auth_hash_upper_case) do
OmniAuth::AuthHash.new(uid: 'my-uid', provider: 'ldapmain', info: info_upper_case)
end
 
describe :changed? do
it "marks existing ldap user as changed" do
Loading
Loading
@@ -57,6 +68,16 @@
expect(existing_user.id).to eql ldap_user.gl_user.id
end
 
it 'connects to existing ldap user if the extern_uid changes and email address has upper case characters' do
existing_user = create(:omniauth_user, email: 'john@example.com', extern_uid: 'old-uid', provider: 'ldapmain')
expect{ ldap_user_upper_case.save }.not_to change{ User.count }
existing_user.reload
expect(existing_user.ldap_identity.extern_uid).to eql 'my-uid'
expect(existing_user.ldap_identity.provider).to eql 'ldapmain'
expect(existing_user.id).to eql ldap_user.gl_user.id
end
it 'maintains an identity per provider' do
existing_user = create(:omniauth_user, email: 'john@example.com', provider: 'twitter')
expect(existing_user.identities.count).to eql(1)
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