327 def test_a_filter_inactivate(self): |
327 def test_a_filter_inactivate(self): |
328 """ filtered out people should be deactivated, unable to authenticate """ |
328 """ filtered out people should be deactivated, unable to authenticate """ |
329 repo_source = self.repo.sources_by_uri['ldap'] |
329 repo_source = self.repo.sources_by_uri['ldap'] |
330 with self.admin_access.repo_cnx() as cnx: |
330 with self.admin_access.repo_cnx() as cnx: |
331 source = cnx.execute('CWSource S WHERE S type="ldapfeed"').get_entity(0, 0) |
331 source = cnx.execute('CWSource S WHERE S type="ldapfeed"').get_entity(0, 0) |
332 config = source.repo_source.check_config(source) |
332 config = repo_source.check_config(source) |
333 # filter with adim's phone number |
333 # filter with adim's phone number |
334 config['user-filter'] = u'(%s=%s)' % ('telephoneNumber', '109') |
334 config['user-filter'] = u'(%s=%s)' % ('telephoneNumber', '109') |
335 source.repo_source.update_config(source, config) |
335 repo_source.update_config(source, config) |
336 cnx.commit() |
336 cnx.commit() |
337 with self.repo.internal_cnx() as cnx: |
337 with self.repo.internal_cnx() as cnx: |
338 self.pull(cnx) |
338 self.pull(cnx) |
339 self.assertRaises(AuthenticationError, |
339 self.assertRaises(AuthenticationError, |
340 repo_source.authenticate, cnx, 'syt', 'syt') |
340 repo_source.authenticate, cnx, 'syt', 'syt') |
345 self.assertEqual(cnx.execute('Any N WHERE U login "adim", ' |
345 self.assertEqual(cnx.execute('Any N WHERE U login "adim", ' |
346 'U in_state S, S name N').rows[0][0], |
346 'U in_state S, S name N').rows[0][0], |
347 'activated') |
347 'activated') |
348 # unfilter, syt should be activated again |
348 # unfilter, syt should be activated again |
349 config['user-filter'] = u'' |
349 config['user-filter'] = u'' |
350 source.repo_source.update_config(source, config) |
350 repo_source.update_config(source, config) |
351 cnx.commit() |
351 cnx.commit() |
352 with self.repo.internal_cnx() as cnx: |
352 with self.repo.internal_cnx() as cnx: |
353 self.pull(cnx) |
353 self.pull(cnx) |
354 with self.admin_access.repo_cnx() as cnx: |
354 with self.admin_access.repo_cnx() as cnx: |
355 self.assertEqual(cnx.execute('Any N WHERE U login "syt", ' |
355 self.assertEqual(cnx.execute('Any N WHERE U login "syt", ' |