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