Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

[39121] Also find users with non matching case

Oliver Günther3edc5b9e42a3
diff --git a/modules/ldap_groups/app/services/ldap_groups/synchronize_groups_service.rb b/modules/ldap_groups/app/services/ldap_groups/synchronize_groups_service.rb
index 0a9c817219a..8ae6642932d 100644
--- a/modules/ldap_groups/app/services/ldap_groups/synchronize_groups_service.rb
+++ b/modules/ldap_groups/app/services/ldap_groups/synchronize_groups_service.rb
@@ -43,7 +43,7 @@ module LdapGroups
def map_to_users(sync_group, entries)
create_missing!(entries) if sync_group.sync_users
- User.where(login: entries.keys)
+ User.where('LOWER(login) IN (?)', entries.keys.map(&:downcase))
end
##
diff --git a/modules/ldap_groups/spec/services/synchronization_spec.rb b/modules/ldap_groups/spec/services/synchronization_spec.rb
index df6ca3a1e45..5d0202a7399 100644
--- a/modules/ldap_groups/spec/services/synchronization_spec.rb
+++ b/modules/ldap_groups/spec/services/synchronization_spec.rb
@@ -188,7 +188,6 @@ describe LdapGroups::SynchronizeGroupsService, with_ee: %i[ldap_groups] do
let(:user_aa729) { User.find_by login: 'aa729' }
let(:user_bb459) { User.find_by login: 'bb459' }
-
context 'and users sync in the groups enabled' do
let(:sync_users) { true }
@@ -221,7 +220,6 @@ describe LdapGroups::SynchronizeGroupsService, with_ee: %i[ldap_groups] do
let(:user_aa729) { User.find_by login: 'aa729' }
let(:user_bb459) { User.find_by login: 'bb459' }
-
context 'and users sync in the groups enabled' do
let(:sync_users) { true }
@@ -309,7 +307,7 @@ describe LdapGroups::SynchronizeGroupsService, with_ee: %i[ldap_groups] do
describe 'removing memberships' do
context 'with a user in a group thats not in ldap' do
let(:group_foo) { FactoryBot.create :group, lastname: 'foo_internal', members: [user_cc414, user_aa729] }
- let(:manager) { FactoryBot.create :role, name: 'Manager' }
+ let(:manager) { FactoryBot.create :role, name: 'Manager' }
let(:project) { FactoryBot.create :project, name: 'Project 1', identifier: 'project1', members: { group_foo => [manager] } }
before do
@@ -374,4 +372,18 @@ describe LdapGroups::SynchronizeGroupsService, with_ee: %i[ldap_groups] do
end
end
end
+
+ context 'when one user does not match case' do
+ before do
+ group_foo
+ synced_foo
+ user_aa729.update_attribute(:login, 'Aa729')
+ end
+
+ it 'synchronized the membership of aa729 to foo' do
+ subject
+ expect(synced_foo.users.count).to eq(1)
+ expect(group_foo.users).to eq([user_aa729])
+ end
+ end
end