Commit f0c8f016 authored by Arnaud Fontaine's avatar Arnaud Fontaine

erp5_ldap_catalog: Moved to erp5-archive.git.

parent f03be863
<catalog_method>
<item key="sql_clear_catalog" type="int">
<value>1</value>
</item>
</catalog_method>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="LDIFMethod" module="Products.ZLDAPMethods.LM"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_arg</string> </key>
<value>
<object>
<klass>
<global name="Args" module="Shared.DC.ZRDB.Aqueduct"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_data</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>_keys</string> </key>
<value>
<list/>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>arguments</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>arguments_src</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>basedn</string> </key>
<value> <string>ou=persons,dc=erp5,dc=org</string> </value>
</item>
<item>
<key> <string>connection_id</string> </key>
<value> <string>erp5_ldap_connection</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>z0_ldif_drop_person_branch</string> </value>
</item>
<item>
<key> <string>ldif</string> </key>
<value> <string encoding="cdata"><![CDATA[
<dtml-in prefix="loop" expr="getPortalObject().z_ldap_search_person_list()">\n
<dtml-ldifline attr="dn" expr="\'uidNumber=%s,%s\' % (loop_item.uidNumber, basedn)" type="string">\n
changetype: delete\n
\n
</dtml-in>\n
\n
<dtml-ldifline attr="dn" expr="basedn" type="string">\n
changetype: delete
]]></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<catalog_method>
<item key="sql_uncatalog_object" type="int">
<value>1</value>
</item>
</catalog_method>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="LDIFMethod" module="Products.ZLDAPMethods.LM"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_arg</string> </key>
<value>
<object>
<klass>
<global name="Args" module="Shared.DC.ZRDB.Aqueduct"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_data</string> </key>
<value>
<dictionary>
<item>
<key> <string>uid</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>_keys</string> </key>
<value>
<list>
<string>uid</string>
</list>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>arguments</string> </key>
<value> <string>uid</string> </value>
</item>
<item>
<key> <string>arguments_src</string> </key>
<value> <string>uid</string> </value>
</item>
<item>
<key> <string>basedn</string> </key>
<value> <string>ou=persons,dc=erp5,dc=org</string> </value>
</item>
<item>
<key> <string>connection_id</string> </key>
<value> <string>erp5_ldap_connection</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>z0_ldif_uncatalog_person_list</string> </value>
</item>
<item>
<key> <string>ldif</string> </key>
<value> <string encoding="cdata"><![CDATA[
<dtml-in expr="getPortalObject().z_ldap_search_person_by_uid(uid=uid)">\n
dn: <dtml-var dn>\n
changetype: delete\n
\n
</dtml-in>\n
]]></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<catalog_method>
<item key="sql_catalog_object_list" type="int">
<value>1</value>
</item>
</catalog_method>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="LDIFMethod" module="Products.ZLDAPMethods.LM"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_arg</string> </key>
<value>
<object>
<klass>
<global name="Args" module="Shared.DC.ZRDB.Aqueduct"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_data</string> </key>
<value>
<dictionary>
<item>
<key> <string>Person_isLdapIndexable</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>getDefaultEmailText</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>getDestinationReference</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>getFirstName</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>getLastName</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>getPassword</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>getReference</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>uid</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>_keys</string> </key>
<value>
<list>
<string>uid</string>
<string>Person_isLdapIndexable</string>
<string>getFirstName</string>
<string>getLastName</string>
<string>getDefaultEmailText</string>
<string>getPassword</string>
<string>getReference</string>
<string>getDestinationReference</string>
</list>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>arguments</string> </key>
<value> <string>uid\n
Person_isLdapIndexable\n
getFirstName\n
getLastName\n
getDefaultEmailText\n
getPassword\n
getReference\n
getDestinationReference</string> </value>
</item>
<item>
<key> <string>arguments_src</string> </key>
<value> <string>uid\n
Person_isLdapIndexable\n
getFirstName\n
getLastName\n
getDefaultEmailText\n
getPassword\n
getReference\n
getDestinationReference</string> </value>
</item>
<item>
<key> <string>basedn</string> </key>
<value> <string>ou=persons,dc=erp5,dc=org</string> </value>
</item>
<item>
<key> <string>connection_id</string> </key>
<value> <string>erp5_ldap_connection</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>z_ldif_catalog_person_list</string> </value>
</item>
<item>
<key> <string>ldif</string> </key>
<value> <string encoding="cdata"><![CDATA[
<dtml-in prefix="loop" expr="_.range(_.len(uid))">\n
<dtml-if "Person_isLdapIndexable[loop_item]">\n
<dtml-ldifline attr="dn" expr="\'uidNumber=%s,%s\' % (uid[loop_item], basedn)" type="string">\n
changetype: delete\n
\n
<dtml-ldifline attr="dn" expr="\'uidNumber=%s,%s\' % (uid[loop_item], basedn)" type="string">\n
objectClass: top\n
objectClass: person\n
objectClass: posixAccount\n
objectClass: inetOrgPerson\n
<dtml-ldifline attr="uidNumber" expr="uid[loop_item]" type="string">\n
gidNumber: 9000\n
<dtml-ldifline attr="uid" expr="getReference[loop_item]" type="string">\n
<dtml-ldifline attr="homeDirectory" expr="\'/home/%s\' % (getReference[loop_item])" type="string">\n
<dtml-ldifline attr="cn" expr="\'%s %s\' % (getFirstName[loop_item], getLastName[loop_item])" type="string">\n
<dtml-ldifline attr="sn" expr="getLastName[loop_item]" type="string">\n
<dtml-ldifline attr="givenName" expr="getFirstName[loop_item]" type="string">\n
<dtml-ldifline attr="mail" expr="getDefaultEmailText[loop_item]" type="string">\n
<dtml-ldifline attr="userPassword" expr="getPassword[loop_item]" type="string">\n
\n
</dtml-if>\n
</dtml-in>\n
]]></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<catalog_method>
<item key="sql_clear_catalog" type="int">
<value>1</value>
</item>
</catalog_method>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="LDIFMethod" module="Products.ZLDAPMethods.LM"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_arg</string> </key>
<value>
<object>
<klass>
<global name="Args" module="Shared.DC.ZRDB.Aqueduct"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_data</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>_keys</string> </key>
<value>
<list/>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>arguments</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>arguments_src</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>basedn</string> </key>
<value> <string>ou=persons,dc=erp5,dc=org</string> </value>
</item>
<item>
<key> <string>connection_id</string> </key>
<value> <string>erp5_ldap_connection</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>z_ldif_create_person_branch</string> </value>
</item>
<item>
<key> <string>ldif</string> </key>
<value> <string encoding="cdata"><![CDATA[
<dtml-ldifline attr="dn" expr="basedn" type="string">\n
objectclass: top\n
objectclass: organizationalUnit\n
ou: persons\n
description: Person Branch
]]></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="ZLDAPConnection" module="Products.ZLDAPConnection.ZLDAP"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_canBrowse</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>_isCommitting</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>bind_as</string> </key>
<value> <string>cn=test,dc=erp5,dc=org</string> </value>
</item>
<item>
<key> <string>dn</string> </key>
<value> <string>dc=erp5,dc=org</string> </value>
</item>
<item>
<key> <string>host</string> </key>
<value> <string>localhost</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>erp5_ldap_connection</string> </value>
</item>
<item>
<key> <string>isTransactional</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>openc</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>port</string> </key>
<value> <int>389</int> </value>
</item>
<item>
<key> <string>pw</string> </key>
<value> <string>test</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>ERP5 LDAP Connection</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="Folder" module="OFS.Folder"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>erp5_ldap</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
return context.getPortalType() == 'Person' \
and context.getReference() is not None \
and context.getPassword() is not None \
and context.getFirstName() is not None \
and context.getLastName() is not None \
and context.getDefaultEmailText() is not None
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Person_isLdapIndexable</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="LDAPMethod" module="Products.ZLDAPMethods.LM"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_arg</string> </key>
<value>
<object>
<klass>
<global name="Args" module="Shared.DC.ZRDB.Aqueduct"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_data</string> </key>
<value>
<dictionary>
<item>
<key> <string>uid</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>_keys</string> </key>
<value>
<list>
<string>uid</string>
</list>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_scope</string> </key>
<value> <int>2</int> </value>
</item>
<item>
<key> <string>arguments</string> </key>
<value> <string>uid</string> </value>
</item>
<item>
<key> <string>arguments_src</string> </key>
<value> <string>uid</string> </value>
</item>
<item>
<key> <string>basedn</string> </key>
<value> <string>ou=persons,dc=erp5,dc=org</string> </value>
</item>
<item>
<key> <string>connection_id</string> </key>
<value> <string>erp5_ldap_connection</string> </value>
</item>
<item>
<key> <string>filters</string> </key>
<value> <string encoding="cdata"><![CDATA[
uidNumber=<dtml-var uid>
]]></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>z_ldap_search_person_by_uid</string> </value>
</item>
<item>
<key> <string>scope</string> </key>
<value> <string>SUBTREE</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="LDAPMethod" module="Products.ZLDAPMethods.LM"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_arg</string> </key>
<value>
<object>
<klass>
<global name="Args" module="Shared.DC.ZRDB.Aqueduct"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_data</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>_keys</string> </key>
<value>
<list/>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_scope</string> </key>
<value> <int>2</int> </value>
</item>
<item>
<key> <string>arguments</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>arguments_src</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>basedn</string> </key>
<value> <string>ou=persons,dc=erp5,dc=org</string> </value>
</item>
<item>
<key> <string>connection_id</string> </key>
<value> <string>erp5_ldap_connection</string> </value>
</item>
<item>
<key> <string>filters</string> </key>
<value> <string>objectclass=person\n
</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>z_ldap_search_person_list</string> </value>
</item>
<item>
<key> <string>scope</string> </key>
<value> <string>SUBTREE</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
2008-02-18 Nicolas
* First Build
\ No newline at end of file
erp5_base
\ No newline at end of file
Publish Person's data in LDAP database
\ No newline at end of file
nicolas
\ No newline at end of file
erp5_mysql_innodb/z0_ldif_drop_person_branch
erp5_mysql_innodb/z0_ldif_uncatalog_person_list
erp5_mysql_innodb/z_ldif_catalog_person_list
erp5_mysql_innodb/z_ldif_create_person_branch
\ No newline at end of file
erp5_ldap_connection
\ No newline at end of file
erp5_ldap_catalog
\ No newline at end of file
dn: dc=erp5,dc=org
dc: erp5
objectClass: top
objectClass: domain
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2008 Nexedi SA and Contributors. All Rights Reserved.
# Nicolas Delaby <nicolas@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import unittest
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
class TestERP5LdapCatalog(ERP5TypeTestCase):
"""
Tests for ERP5 Ldap Catalog.
To setup LDAP server (on Mandriva):
1. install openldap-clients, openldap-servers
2. change following options in /etc/openldap/slapd.conf:
suffix "dc=erp5,dc=org"
rootdn "cn=test,dc=erp5,dc=org"
rootpw test
3. (re)start ldap
4. bootstrap with the following command from this directory :
ldapadd -c -x -h localhost -D "cn=test,dc=erp5,dc=org" -W -f \
bootstrap_erp5_ldap_catalog_test.ldif
"""
def getTitle(self):
return "ERP5 Ldap Catalog"
def getBusinessTemplateList(self):
return ('erp5_base', 'erp5_ldap_catalog',)
# Different variables used for this test
hostport = 'localhost:389'
basedn = 'dc=erp5,dc=org'
bind_as = 'cn=test,dc=erp5,dc=org'
password = 'test'
def getLdapConnection(self):
return self.getPortal().erp5_ldap_connection
def afterSetUp(self):
self.login()
self.getLdapConnection().manage_close()
self.getLdapConnection().manage_edit(
'ERP5 LDAP Test Connection',
self.hostport,
self.basedn,
self.bind_as,
self.password,
1)
self.commit()
# make sure there is no message any more
self.tic()
def beforeTearDown(self):
for module in [ self.getPersonModule(),
self.getOrganisationModule(),
self.getCategoryTool().region,
self.getCategoryTool().group ]:
module.manage_delObjects(list(module.objectIds()))
self.tic()
def test_01_HasEverything(self):
"""Test has everything
"""
self.assertTrue(self.getCategoryTool() is not None)
self.assertTrue(self.getTypeTool() is not None)
self.assertTrue(self.getLdapConnection() is not None)
self.assertTrue(self.getCatalogTool() is not None)
def test_02_person_ldap_cataloging(self):
"""
Test Ldap Indexation
"""
#Create 3 Persons
for i in xrange(3):
self.getPersonModule().newContent(portal_type='Person',
first_name='Foo%s' % i,
last_name='Bar%s' % i,
reference='foobar%s' % i,
password='secret%s' % i,
default_email_text='foo%s@bar.com' % i)
self.tic()
#Check Indexation
for p in self.getPersonModule().contentValues():
uid = p.getUid()
result_ldap = self.getPortal().z_ldap_search_person_by_uid(uid=uid)[0]
self.assertEqual(str(uid), result_ldap.uidNumber[0])
self.assertEqual(p.getReference(), result_ldap.uid[0])
#Arbitrary value needed by posixAccount Schema
self.assertEqual('9000', result_ldap.gidNumber[0])
self.assertEqual(p.getFirstName(), result_ldap.givenName[0])
self.assertEqual('/home/%s' % (p.getReference()), result_ldap.homeDirectory[0])
self.assertEqual(p.getDefaultEmailText(), result_ldap.mail[0])
self.assertEqual(p.getLastName(), result_ldap.sn[0])
self.assertEqual(p.getPassword(), result_ldap.userPassword[0])
#Clear Catalog
self.getPortal().portal_catalog.erp5_mysql_innodb.manage_catalogClear()
self.tic()
#Check Catalog is cleared
self.assertEqual(len(self.getPortal().z_ldap_search_person_list()), 0)
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestERP5LdapCatalog))
return suite
......@@ -76,9 +76,7 @@ class ERP5(_ERP5):
or full_test_case)
# skip some tests
if test_case.find('Performance') > 0 \
or test_case in ('testERP5LdapCatalog', # XXX (Ivan), until LDAP server is available this test will alway fail
):
if test_case.find('Performance') > 0:
continue
test_list.append(full_test_case)
return test_list
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment