[ldapfeed] FIX: Unique Key violation when synchronizing with LDAPfeed
What was happening
==================
The bug appears when ldapfeed tries to insert a user while another user exists
exists with a different source.
Simple use case to reproduce:
- create a local user in cubicweb (source=system)
- sync with ldap
- ldapfeed will stop complaining user already exists.
Without next patch the test MUST fail with message:
cubicweb/server/sources/native.py:714: UniqueTogetherError
The ldapfeed is thus stopped ignoring any further ldap entries.
The proposal
============
Prior to this patch, the insertion was trying to create all CWUser with the
computed login from eeimporter.extid2eid (method process of DataFeedLDAPAdapter).
When a CWUser existed with a different cw_source ("system" for user created
with cubicweb for instance), it created a conflict.
To avoid collisions, in the extentities_generator method a bypass
was added at the insertion layer.
Prior to insertion the absence of the computed login is checked on a list of
all existing login from a different source.
If collision is detected, we skip the ldap record.
By short circuiting at the CWUser entity insertion level we also avoid to treat
CWGroup and EmailAddress related to this user.
Hence ensuring a behaviour that will not break existing instances.
(conservative approach: faced with ambiguity better do nothing than guess).
An error message is added stating explicitly the conflict.
include README
include COPYING
include COPYING.LESSER
include pylintrc
include jshintrc
include tox.ini
include flake8-ok-files.txt
include bin/cubicweb-*
include man/cubicweb-ctl.1
recursive-include extras *.bash_completion
include doc/*.rst
include doc/*.txt
include doc/Makefile
recursive-include doc/book *
recursive-include doc/tools *.py
recursive-include doc/tutorials *.rst *.py
recursive-include doc/api *.rst
recursive-include doc/_themes *
recursive-include doc/_static *
include doc/_templates/*.html
include doc/changes/*.rst
recursive-include doc/dev *.txt *.rst
recursive-include doc/images *.png *.svg
include doc/conf.py
include cubicweb/devtools/fix_po_encoding
recursive-include cubicweb/misc *.py *.png *.display
include cubicweb/web/views/*.pt
recursive-include cubicweb/web/data *.js *.css *.py *.png *.gif *.ico *.ttf *.svg *.woff *.eot
recursive-include cubicweb/web/wdoc *.rst *.png *.xml
recursive-include cubicweb/devtools/data *.js *.css *.sh
recursive-include cubicweb/i18n *.po
recursive-include cubicweb/schemas *.py *.sql
recursive-include requirements *.txt
recursive-include cubicweb/test *.py
recursive-include cubicweb/test/data bootstrap_cubes *.py *.sql
recursive-include cubicweb/test/data-rewrite bootstrap_cubes *.py
recursive-include cubicweb/test/data_schemareader *.py
recursive-include cubicweb/dataimport/test *.py
recursive-include cubicweb/dataimport/test/data *.py *.csv *.txt
recursive-include cubicweb/dataimport/test/data-massimport *.py
recursive-include cubicweb/devtools/test *.py
recursive-include cubicweb/devtools/test/data *.py *.txt *.js *.po.ref
recursive-include cubicweb/entities/test *.py
recursive-include cubicweb/entities/test/data *.py
recursive-include cubicweb/etwist/test *.py
recursive-include cubicweb/etwist/test/data *.py
recursive-include cubicweb/ext/test *.py
recursive-include cubicweb/ext/test/data *.py
recursive-include cubicweb/hooks/test *.py
recursive-include cubicweb/hooks/test/data-computed *.py
recursive-include cubicweb/hooks/test/data *.py
recursive-include cubicweb/sobjects/test *.py
recursive-include cubicweb/sobjects/test/data bootstrap_cubes *.py
recursive-include cubicweb/server/test *.py
recursive-include cubicweb/server/test/data bootstrap_cubes *.py source* *.conf.in *.ldif
recursive-include cubicweb/server/test/data-cwep002 *.py
recursive-include cubicweb/server/test/datacomputed *.py
recursive-include cubicweb/server/test/data-schema2sql toignore
recursive-include cubicweb/server/test/data-migractions bootstrap_cubes *.py
recursive-include cubicweb/server/test/data-schemaserial *.py
include cubicweb/web/test/testutils.js
recursive-include cubicweb/web/test *.py
recursive-include cubicweb/web/test/data bootstrap_cubes pouet.css *.py
recursive-include cubicweb/web/test/data/static/jstests *.js *.html *.json
recursive-include cubicweb/wsgi/test *.py
include cubicweb/pyramid/development.ini.tmpl
include cubicweb/web/data/jquery-treeview/*.md
recursive-include cubicweb/skeleton *.py *.css *.js *.po compat *.tmpl rules
prune cubicweb/misc/cwfs