254 source.authenticate, cnx, 'toto', 'toto') |
254 source.authenticate, cnx, 'toto', 'toto') |
255 self.assertRaises(AuthenticationError, |
255 self.assertRaises(AuthenticationError, |
256 source.authenticate, cnx, 'syt', 'toto') |
256 source.authenticate, cnx, 'syt', 'toto') |
257 self.assertTrue(source.authenticate(cnx, 'syt', 'syt')) |
257 self.assertTrue(source.authenticate(cnx, 'syt', 'syt')) |
258 |
258 |
|
259 def test_ldapfeed_insert_collision(self): |
|
260 """ |
|
261 when a user computed login from ldapfeed collides with a CWUser |
|
262 login the user MUST not be inserted, and message MUST be present |
|
263 at error level regarding the collision for troubleshooting purpose. |
|
264 We also check that in case the CWUser is skipped, the entity EmailAddress |
|
265 is not modified. |
|
266 If EmailAddress are not modified, CWGroup are not. |
|
267 """ |
|
268 with self.admin_access.cnx() as cnx: |
|
269 user = cnx.find('CWUser', login=u'syt').one() |
|
270 user.cw_set(cw_source=cnx.find('CWSource', name=u'system').one()) |
|
271 with cnx.security_enabled(write=False): |
|
272 user.cw_set(cwuri=u'http://testing.fr/cubicweb/{}'.format(user.eid)) |
|
273 for mail in user.use_email: |
|
274 mail.cw_set(address=mail.address[:-3] + u".net") |
|
275 cnx.commit() |
|
276 with self.assertLogs('cubicweb.appobject', level='ERROR') as cm: |
|
277 self.pull(cnx) |
|
278 self.assertEqual( |
|
279 cm.output, |
|
280 ['ERROR:cubicweb.appobject:not synchronizing user syt.' |
|
281 ' User already exist in source system'] |
|
282 ) |
|
283 for mail in user.use_email: |
|
284 self.assertTrue(mail.address.endswith(".net")) |
|
285 |
259 def test_base(self): |
286 def test_base(self): |
260 with self.admin_access.repo_cnx() as cnx: |
287 with self.admin_access.repo_cnx() as cnx: |
261 # check a known one |
288 # check a known one |
262 rset = cnx.execute('CWUser X WHERE X login %(login)s', {'login': 'syt'}) |
289 rset = cnx.execute('CWUser X WHERE X login %(login)s', {'login': 'syt'}) |
263 e = rset.get_entity(0, 0) |
290 e = rset.get_entity(0, 0) |