Working on issue #1008 - Improved trace- and debugability for skipped LDAP User import entries.
This commit is contained in:
parent
bb230519be
commit
e3891ebeed
2 changed files with 52 additions and 21 deletions
|
@ -30,9 +30,14 @@ module Import
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_or_update(resource, *args)
|
def create_or_update(resource, *args)
|
||||||
return if skip?(resource)
|
|
||||||
|
|
||||||
result = nil
|
result = nil
|
||||||
|
if skip?(resource)
|
||||||
|
ldap_log(
|
||||||
|
action: "skipped -> #{@remote_id}",
|
||||||
|
status: 'success',
|
||||||
|
request: resource,
|
||||||
|
)
|
||||||
|
else
|
||||||
catch(:no_roles_assigned) do
|
catch(:no_roles_assigned) do
|
||||||
determine_role_ids(resource)
|
determine_role_ids(resource)
|
||||||
|
|
||||||
|
@ -44,6 +49,7 @@ module Import
|
||||||
request: resource,
|
request: resource,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
|
@ -67,19 +67,6 @@ RSpec.describe Import::Ldap::User do
|
||||||
expect(HttpLog.last.status).to eq('success')
|
expect(HttpLog.last.status).to eq('success')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'skips User entries without attributes' do
|
|
||||||
|
|
||||||
skip_entry = build(:ldap_entry)
|
|
||||||
|
|
||||||
skip_entry['uid'] = [uid]
|
|
||||||
|
|
||||||
expect do
|
|
||||||
described_class.new(skip_entry, ldap_config, user_roles, signup_role_ids)
|
|
||||||
end.to not_change {
|
|
||||||
User.count
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'logs failures to HTTP Log' do
|
it 'logs failures to HTTP Log' do
|
||||||
expect_any_instance_of(User).to receive(:save!).and_raise('SOME ERROR')
|
expect_any_instance_of(User).to receive(:save!).and_raise('SOME ERROR')
|
||||||
described_class.new(user_entry, ldap_config, user_roles, signup_role_ids)
|
described_class.new(user_entry, ldap_config, user_roles, signup_role_ids)
|
||||||
|
@ -265,4 +252,42 @@ RSpec.describe Import::Ldap::User do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'skipped' do
|
||||||
|
|
||||||
|
it 'skips entries without login' do
|
||||||
|
skip_entry = build(:ldap_entry)
|
||||||
|
instance = nil
|
||||||
|
|
||||||
|
expect do
|
||||||
|
instance = described_class.new(skip_entry, ldap_config, user_roles, signup_role_ids)
|
||||||
|
end.to not_change {
|
||||||
|
User.count
|
||||||
|
}
|
||||||
|
expect(instance.action).to eq(:skipped)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'skips entries without attributes' do
|
||||||
|
skip_entry = build(:ldap_entry)
|
||||||
|
skip_entry['uid'] = [uid]
|
||||||
|
instance = nil
|
||||||
|
|
||||||
|
expect do
|
||||||
|
instance = described_class.new(skip_entry, ldap_config, user_roles, signup_role_ids)
|
||||||
|
end.to not_change {
|
||||||
|
User.count
|
||||||
|
}
|
||||||
|
expect(instance.action).to eq(:skipped)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'logs skips to HTTP Log' do
|
||||||
|
skip_entry = build(:ldap_entry)
|
||||||
|
described_class.new(skip_entry, ldap_config, user_roles, signup_role_ids)
|
||||||
|
|
||||||
|
expect(HttpLog.last.status).to eq('success')
|
||||||
|
expect(HttpLog.last.url).to start_with('skipped')
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue