Changes between Initial Version and Version 1 of LdapPluginTests


Ignore:
Timestamp:
Nov 4, 2005, 9:30:58 PM (19 years ago)
Author:
Emmanuel Blot
Comment:

Creation (from original anciens.enib.fr page)

Legend:

Unmodified
Added
Removed
Modified
  • LdapPluginTests

    v1 v1  
     1= Testing LDAP extensions =
     2
     3This page gives some hints about how to test the LdapPlugin extension, and provides some examples about deploying [http://www.openldap.org OpenLDAP] to perform the [http://anciens.enib.fr/trac/public/browser/tasks/trac/ldap-task/extensions/ldapperm/tests tests].
     4
     5== Prerequistes ==
     6
     7The examples in this page assumes that you are working with a Linux server (Debian), with OpenLDAP 2.2 or greater.[[BR]]
     8The `slapd` server should have been installed, and you should also have access to the Ldap utils (which usually comes within a separate package), namely:
     9 * server tools: `slapadd`, `slapcat`
     10 * client tools: `ldapsearch`, `ldapadd`, `ldapmodify`, `ldapdelete`
     11
     12All the commands are run using the superuser (root) account.
     13
     14== Create the directory config file ==
     15
     16The following config file is somewhat more complex that it could be, as it used ACL, etc.[[BR]]
     17However, this is a good base to elaborate a more complex LDAP setup, and ... that's the file I use to test the extension ;-)
     18
     19{{{
     20# BDB backend in this example
     21database        bdb
     22
     23# Maximum entries returned in a search
     24sizelimit       100
     25
     26# Log connections, operations, results
     27# Do not forget to reduce the debug level once everything is up and running !
     28loglevel        768
     29
     30suffix          "dc=example,dc=org"
     31rootdn          "uid=root,dc=example,dc=org"
     32
     33# Cleartext password: Trac
     34rootpw          {SSHA}yGq6aHM4w3Hf94hl4j+1rgO3HSGmmbVq
     35lastmod         on
     36
     37# Path to the database files
     38directory       /var/local/db/tracldap
     39
     40# 1.3.6.1.4.1.15527 is reserved. Do not hijack it
     41# Please see http://www.iana.org/cgi-bin/enterprise.pl
     42
     43# Attribute type definitions
     44attributetype ( 1.3.6.1.4.1.15527.143
     45                NAME 'tracperm'
     46                DESC 'Trac Permission'
     47                EQUALITY caseIgnoreMatch
     48                SUBSTR caseIgnoreSubstringsMatch
     49                SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{32} )
     50
     51# Class definitions
     52objectclass ( 1.3.6.1.4.1.15527.8
     53              NAME 'tracuser'
     54              DESC 'Regular user with Trac permission'
     55              SUP top
     56              STRUCTURAL
     57              MUST ( uid $ cn $ userpassword )
     58              MAY  ( tracperm $ sn $ description ) )
     59objectclass ( 1.3.6.1.4.1.15527.9
     60              NAME 'tracgroup'
     61              DESC 'Trac permission for groupofnames'
     62              SUP top
     63              AUXILIARY
     64              MAY  ( tracperm ) )
     65
     66# ACLs
     67access to dn.base="" by * read
     68access to dn.base="cn=subschema" by * read
     69access to filter=(|(objectclass=groupOfNames)(objectclass=tracuser)) dn.one="dc=example,dc=org"
     70       by group="cn=managers,dc=example,dc=org" write
     71       by * read
     72access to attr=tracperm
     73       by group="cn=managers,dc=example,dc=org" write
     74       by self read
     75       by users read
     76       by anonymous read
     77access to attr=entry dn.subtree="dc=example,dc=org"
     78       by * read
     79
     80# Search indexing
     81index  objectClass,uid eq
     82index  cn,sn           eq,sub,pres,approx
     83index  member          eq
     84
     85}}}
     86
     87You should include this file from the main OpenLDAP configuration file, usually located here: `/etc/ldap/slapd.conf`.
     88You need to include these definitions at the bottom of the file.
     89
     90== Configure your system logger ==
     91
     92OpenLDAP errors are somewhat cryptic. You can find useful information from the log produced by the server.
     93
     94It is very useful to compare requests made by standard utilities such as `ldapsearch` and the requests made by the extension:[[BR]]
     95If a ldapsearch request fails, blame your server configuration (or your directory content), not the Trac Ldap Extension ;-)
     96
     97 1. Add the following entry in `/etc/syslog.conf`
     98{{{
     99# Log OpenLDAP
     100local4.*                       -/var/log/openldap.all
     101}}}
     102 1. Reload the syslog configuration
     103{{{
     104/etc/init.d/sysklogd reload
     105}}}
     106 1. You probably want to open a console and keep dumping the log messages:
     107{{{
     108tail -f /var/log/openldap.all
     109}}}
     110
     111== Start up the LDAP server ==
     112
     113 1. Create the directory where the LDAP directory files will reside
     114{{{
     115mkdir /var/local/db/tracldap
     116}}}
     117 1. Start up the server
     118{{{
     119/etc/init.d/slapd start
     120}}}
     121
     122You should not get any error. If you get an error message (carefully check the log file), please fix up your LDAP configuration before resuming installation.
     123
     124If everything is ok, shut down the server right now, 'cose we need to initialize the LDAP directory
     125
     126== Initializing the directory ==
     127
     128We need to create the top-most entry (the local root) of the LDAP hierarchical directory.
     129
     130 1. Copy the following LDIF data in a file, `init.ldif` for example:
     131{{{
     132dn: dc=example,dc=org
     133dc: example
     134o: Trac
     135description: Test directory for Trac
     136objectClass: dcObject
     137objectClass: organization
     138}}}
     139 1. Then, inject this LDIF data into the LDAP directory, using the server tool. '''Yes''', the server should be down at this very moment
     140{{{
     141/usr/sbin/slapadd -b "dc=example,dc=org" -l init.ldif
     142}}}
     143 1. At this point, you can restart the LDAP server
     144{{{
     145/etc/init.d/slapd start
     146}}}
     147
     148Now that the server is up and running, we can inject the initial directory entries that are expected by the extension unit tests.
     149
     150 1. Copy the following LDIF data in another file, `dirtest.ldif`
     151{{{
     152# Group definition
     153# Managers is a group that has permission to add and revoke Trac permissions
     154dn: cn=managers,dc=example,dc=org
     155cn: managers
     156objectClass: groupOfNames
     157objectClass: tracgroup
     158member: uid=trac,dc=example,dc=org
     159
     160# Group definition
     161# Users is a group of regular users
     162dn: cn=users,dc=example,dc=org
     163cn: users
     164objectClass: groupOfNames
     165objectClass: tracgroup
     166member: uid=joeuser,dc=example,dc=org
     167
     168# User definition
     169# Trac is the 'software user' that manages the Trac permissions
     170dn: uid=trac,dc=example,dc=org
     171uid: trac
     172cn: Trac Manager
     173userPassword: Trac
     174objectClass: tracuser
     175
     176# Special 'user': anonymous
     177# joker entry for non authenticated access
     178dn: uid=anonymous,dc=example,dc=org
     179uid: anonymous
     180cn: Trac Anonymous
     181sn: Anonymous
     182userPassword: no_use
     183objectClass: tracuser
     184
     185# Special 'user': authenticated
     186# joker entry for any authenticated access
     187dn: uid=authenticated,dc=example,dc=org
     188uid: authenticated
     189cn: Trac Authenticated
     190sn: Authenticated
     191userPassword: no_use
     192objectClass: tracuser
     193
     194# User definition
     195# Joe User is just a regular user
     196dn: uid=joeuser,dc=example,dc=org
     197uid: joeuser
     198cn: Joe User
     199sn: User
     200userPassword: anypasswd
     201objectClass: tracuser
     202}}}
     203 1. Add those entries to the directory, using the client tool. This won't work if the LDAP server is down
     204{{{
     205ldapadd -D "uid=root,dc=example,dc=org" -x -W -f direst.ldif
     206}}}
     207You'll be prompted for the user password, ''i.e.'' the password for user `uid=root`. This password is defined in the LDAP directory config file, here: "Trac"
     208
     209At this point, you should be able to fully use the directory:
     210 1. Search entries using an anonymous bind:
     211{{{
     212ldapsearch -b "dc=example,dc=org" -x objectclass=*
     213}}}
     214
     215 1. Search entries using an authenticated bind (password for trac is "Trac" too):
     216{{{
     217ldapsearch -b "dc=example,dc=org" -D "uid=trac,dc=example,dc=org" -x -W objectclass=*
     218}}}
     219
     220 1. You can also add new entries, and removes them if you like. But do not forget that the Ldap Extension unit tests expect the directory to be set up as described up to now
     221
     222== Clean up ==
     223
     224If the test fails, or some part of the installation procedure fails, you want to clean up the LDAP directory, to restart from a clean environment.
     225
     226 1. Shut down the OpenLDAP server
     227{{{
     228/etc/init.d/slapd stop
     229}}}
     230 1. Remove the LDAP database files
     231{{{
     232rm /var/local/db/tracldap/*
     233}}}
     234 1. Reinitialize the directory (see above)
     235
     236
     237[[TagIt(eblot)]]