equal
deleted
inserted
replaced
1 # copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
1 # copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
3 # |
3 # |
4 # This file is part of CubicWeb. |
4 # This file is part of CubicWeb. |
5 # |
5 # |
6 # CubicWeb is free software: you can redistribute it and/or modify it under the |
6 # CubicWeb is free software: you can redistribute it and/or modify it under the |
49 confstream.close() |
49 confstream.close() |
50 # fill ldap server with some data |
50 # fill ldap server with some data |
51 ldiffile = join(config.apphome, "ldap_test.ldif") |
51 ldiffile = join(config.apphome, "ldap_test.ldif") |
52 config.info('Initing ldap database') |
52 config.info('Initing ldap database') |
53 cmdline = "/usr/sbin/slapadd -f %s -l %s -c" % (slapdconf, ldiffile) |
53 cmdline = "/usr/sbin/slapadd -f %s -l %s -c" % (slapdconf, ldiffile) |
54 subprocess.check_call(cmdline, shell=True) == 0 |
54 subprocess.call(cmdline, shell=True) |
55 |
55 |
56 #ldapuri = 'ldapi://' + join(basedir, "ldapi").replace('/', '%2f') |
56 #ldapuri = 'ldapi://' + join(basedir, "ldapi").replace('/', '%2f') |
57 port = get_available_port(xrange(9000, 9100)) |
57 port = get_available_port(xrange(9000, 9100)) |
58 host = 'localhost:%s' % port |
58 host = 'localhost:%s' % port |
59 ldapuri = 'ldap://%s' % host |
59 ldapuri = 'ldap://%s' % host |
112 source.repo_source.update_config(source, config) |
112 source.repo_source.update_config(source, config) |
113 session.commit(free_cnxset=False) |
113 session.commit(free_cnxset=False) |
114 # here we emitted an error log entry |
114 # here we emitted an error log entry |
115 stats = source.repo_source.pull_data(session, force=True, raise_on_error=True) |
115 stats = source.repo_source.pull_data(session, force=True, raise_on_error=True) |
116 session.commit() |
116 session.commit() |
117 |
|
118 def setUp(self): |
|
119 super(LDAPTestBase, self).setUp() |
|
120 # ldap source url in the database may use a different port as the one |
|
121 # just attributed |
|
122 lfsource = self.repo.sources_by_uri['ldapuser'] |
|
123 lfsource.urls = [URL] |
|
124 |
|
125 |
117 |
126 class DeleteStuffFromLDAPFeedSourceTC(LDAPTestBase): |
118 class DeleteStuffFromLDAPFeedSourceTC(LDAPTestBase): |
127 test_db_id = 'ldap-feed' |
119 test_db_id = 'ldap-feed' |
128 |
120 |
129 @classmethod |
121 @classmethod |
198 user = self.execute('CWUser U WHERE U login "syt"').get_entity(0, 0) |
190 user = self.execute('CWUser U WHERE U login "syt"').get_entity(0, 0) |
199 user.cw_adapt_to('IWorkflowable').fire_transition('activate') |
191 user.cw_adapt_to('IWorkflowable').fire_transition('activate') |
200 self.commit() |
192 self.commit() |
201 self.assertRaises(AuthenticationError, self.repo.connect, 'syt', password='syt') |
193 self.assertRaises(AuthenticationError, self.repo.connect, 'syt', password='syt') |
202 |
194 |
203 |
|
204 class LDAPFeedSourceTC(LDAPTestBase): |
195 class LDAPFeedSourceTC(LDAPTestBase): |
205 test_db_id = 'ldap-feed' |
196 test_db_id = 'ldap-feed' |
206 |
197 |
207 @classmethod |
198 @classmethod |
208 def pre_setup_database(cls, session, config): |
199 def pre_setup_database(cls, session, config): |
210 url=URL, config=CONFIG) |
201 url=URL, config=CONFIG) |
211 session.commit() |
202 session.commit() |
212 isession = session.repo.internal_session(safe=True) |
203 isession = session.repo.internal_session(safe=True) |
213 lfsource = isession.repo.sources_by_uri['ldapuser'] |
204 lfsource = isession.repo.sources_by_uri['ldapuser'] |
214 stats = lfsource.pull_data(isession, force=True, raise_on_error=True) |
205 stats = lfsource.pull_data(isession, force=True, raise_on_error=True) |
|
206 |
|
207 def setUp(self): |
|
208 super(LDAPFeedSourceTC, self).setUp() |
|
209 # ldap source url in the database may use a different port as the one |
|
210 # just attributed |
|
211 lfsource = self.repo.sources_by_uri['ldapuser'] |
|
212 lfsource.urls = [URL] |
215 |
213 |
216 def assertMetadata(self, entity): |
214 def assertMetadata(self, entity): |
217 self.assertTrue(entity.creation_date) |
215 self.assertTrue(entity.creation_date) |
218 self.assertTrue(entity.modification_date) |
216 self.assertTrue(entity.modification_date) |
219 |
217 |