Working on issue #981 - Improved LDAP user sync performance by skipping the lookup for avatars via the webservice.

This commit is contained in:
Thorsten Eckel 2017-05-03 15:32:20 +02:00
parent 36acac38c3
commit d13bf09fa8
2 changed files with 22 additions and 3 deletions

View file

@ -89,7 +89,10 @@ module Import
update_roles = role_ids(resource) update_roles = role_ids(resource)
resource[:role_ids] = update_roles if update_roles resource[:role_ids] = update_roles if update_roles
user_found = false
import_class.without_callback(:update, :after, :avatar_for_email_check) do
user_found = super user_found = super
end
# in case a User was found and we had no roles # in case a User was found and we had no roles
# to set/update we have to note the currently # to set/update we have to note the currently
@ -156,12 +159,14 @@ module Import
end end
def create(resource, *_args) def create(resource, *_args)
# this is needed for the special case described in the role_ids method # this is needed for the special case described in the role_ids method
# #
# in case we have no role IDs yet we have to fall back to the signup roles # in case we have no role IDs yet we have to fall back to the signup roles
resource[:role_ids] ||= @signup_role_ids resource[:role_ids] ||= @signup_role_ids
import_class.without_callback(:create, :after, :avatar_for_email_check) do
super super
end
rescue => e rescue => e
ldap_log( ldap_log(
action: "create -> #{resource[:login]}", action: "create -> #{resource[:login]}",

View file

@ -48,6 +48,13 @@ RSpec.describe Import::Ldap::User do
}.by(1) }.by(1)
end end
it "doesn't contact avatar webservice" do
# sadly we can't ensure that there are no
# outgoing HTTP calls with WebMock
expect(Avatar).not_to receive(:auto_detection)
described_class.new(user_entry, ldap_config, user_roles, signup_role_ids)
end
it 'creates an HTTP Log entry' do it 'creates an HTTP Log entry' do
expect do expect do
described_class.new(user_entry, ldap_config, user_roles, signup_role_ids) described_class.new(user_entry, ldap_config, user_roles, signup_role_ids)
@ -124,6 +131,13 @@ RSpec.describe Import::Ldap::User do
} }
end end
it "doesn't contact avatar webservice" do
# sadly we can't ensure that there are no
# outgoing HTTP calls with WebMock
expect(Avatar).not_to receive(:auto_detection)
described_class.new(user_entry, ldap_config, user_roles, signup_role_ids)
end
it "doesn't change roles if no role mapping is configured" do it "doesn't change roles if no role mapping is configured" do
expect do expect do
described_class.new(user_entry, ldap_config, {}, signup_role_ids) described_class.new(user_entry, ldap_config, {}, signup_role_ids)