From 8d4b4a01526f29c6fd2b0b4d1e227262554b5dbb Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Thu, 26 Apr 2018 09:07:30 +0200 Subject: [PATCH] Fixed issue #1891: Missing identifier attribute on LDAP entry causes Sync to fail. --- lib/sequencer/unit/import/common/mapping/flat_keys.rb | 4 ++++ .../unit/import/common/model/associations/extract.rb | 3 +++ .../unit/import/common/model/lookup/attributes.rb | 2 +- .../unit/import/common/user/attributes/downcase.rb | 2 +- .../unit/import/common/user/email/check_validity.rb | 2 +- lib/sequencer/unit/import/ldap/user/remote_id/unhex.rb | 7 +++++++ lib/sequencer/unit/import/ldap/user/statistics/diff.rb | 1 + 7 files changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/sequencer/unit/import/common/mapping/flat_keys.rb b/lib/sequencer/unit/import/common/mapping/flat_keys.rb index bad50a92c..4caa06bda 100644 --- a/lib/sequencer/unit/import/common/mapping/flat_keys.rb +++ b/lib/sequencer/unit/import/common/mapping/flat_keys.rb @@ -5,8 +5,12 @@ class Sequencer module Mapping class FlatKeys < Sequencer::Unit::Base include ::Sequencer::Unit::Import::Common::Mapping::Mixin::ProvideMapped + prepend ::Sequencer::Unit::Import::Common::Model::Mixin::Skip::Action + + skip_any_action uses :resource + provides :mapped def process provide_mapped do diff --git a/lib/sequencer/unit/import/common/model/associations/extract.rb b/lib/sequencer/unit/import/common/model/associations/extract.rb index 6dd8057ef..8aa08eb49 100644 --- a/lib/sequencer/unit/import/common/model/associations/extract.rb +++ b/lib/sequencer/unit/import/common/model/associations/extract.rb @@ -5,6 +5,9 @@ class Sequencer module Model module Associations class Extract < Sequencer::Unit::Base + prepend ::Sequencer::Unit::Import::Common::Model::Mixin::Skip::Action + + skip_any_action uses :model_class, :mapped provides :associations diff --git a/lib/sequencer/unit/import/common/model/lookup/attributes.rb b/lib/sequencer/unit/import/common/model/lookup/attributes.rb index 4f61952c7..8a097b010 100644 --- a/lib/sequencer/unit/import/common/model/lookup/attributes.rb +++ b/lib/sequencer/unit/import/common/model/lookup/attributes.rb @@ -8,7 +8,7 @@ class Sequencer include ::Sequencer::Unit::Import::Common::Model::Mixin::HandleFailure prepend ::Sequencer::Unit::Import::Common::Model::Mixin::Skip::Action - skip_action :skipped + skip_action :skipped, :failed uses :mapped, :model_class provides :instance diff --git a/lib/sequencer/unit/import/common/user/attributes/downcase.rb b/lib/sequencer/unit/import/common/user/attributes/downcase.rb index 5c5ef092e..22dfa5625 100644 --- a/lib/sequencer/unit/import/common/user/attributes/downcase.rb +++ b/lib/sequencer/unit/import/common/user/attributes/downcase.rb @@ -7,7 +7,7 @@ class Sequencer class Downcase < Sequencer::Unit::Base prepend ::Sequencer::Unit::Import::Common::Model::Mixin::Skip::Action - skip_action :skipped + skip_action :skipped, :failed uses :mapped diff --git a/lib/sequencer/unit/import/common/user/email/check_validity.rb b/lib/sequencer/unit/import/common/user/email/check_validity.rb index 5e6a9651d..e99de6c27 100644 --- a/lib/sequencer/unit/import/common/user/email/check_validity.rb +++ b/lib/sequencer/unit/import/common/user/email/check_validity.rb @@ -7,7 +7,7 @@ class Sequencer class CheckValidity < Sequencer::Unit::Base prepend ::Sequencer::Unit::Import::Common::Model::Mixin::Skip::Action - skip_action :skipped + skip_action :skipped, :failed uses :mapped diff --git a/lib/sequencer/unit/import/ldap/user/remote_id/unhex.rb b/lib/sequencer/unit/import/ldap/user/remote_id/unhex.rb index 9e66fbb1e..3fcd7a04e 100644 --- a/lib/sequencer/unit/import/ldap/user/remote_id/unhex.rb +++ b/lib/sequencer/unit/import/ldap/user/remote_id/unhex.rb @@ -5,11 +5,18 @@ class Sequencer module User module RemoteId class Unhex < Sequencer::Unit::Base + prepend ::Sequencer::Unit::Import::Common::Model::Mixin::Skip::Action + + skip_action :skipped, :failed uses :remote_id provides :remote_id def process + # check if a remote_id is given and + # prefer .nil? over .blank? etc. because + # the HEX values cause errors otherwise + return if remote_id.nil? return if remote_id.ascii_only? state.provide(:remote_id, unhexed) end diff --git a/lib/sequencer/unit/import/ldap/user/statistics/diff.rb b/lib/sequencer/unit/import/ldap/user/statistics/diff.rb index 9f07ab09c..3113acad4 100644 --- a/lib/sequencer/unit/import/ldap/user/statistics/diff.rb +++ b/lib/sequencer/unit/import/ldap/user/statistics/diff.rb @@ -21,6 +21,7 @@ class Sequencer def add_role_ids(statistics) return statistics if instance.blank? + return statistics if associations.blank? # add the parent role_ids hash # so we can fill it