intoolswetrust / ldap-server

Simple in-memory LDAP server for testing purposes - single JAR based on ApacheDS
Apache License 2.0
160 stars 59 forks source link

Support LDIF files containing more than one entry and at least one modification #61

Closed matthiasblaesing closed 1 year ago

matthiasblaesing commented 1 year ago

Currently ldap-server requires multiple LDIF files if an entry contains a changetype entry and does not properly apply modifications.

One use-case is: Enable a build-in schema, add attribute types and sample data.

It was tested with ldapadd, which happily accepted this case and applied the changes, while ldap-server rejected them:

[main] ERROR org.apache.directory.api.ldap.model.ldif.LdifReader - ERR_12004_CHANGE_NOT_ALLOWED We cannot have changes when reading a file which already contains entries, at line 6 [main] ERROR org.apache.directory.api.ldap.model.ldif.LdifReader - ERR_12005_NO_CHANGE No changes within entries Exception in thread "main" java.lang.NullPointerException: Cannot invoke "org.apache.directory.api.ldap.model.ldif.LdifEntry.getDn()" because "ldifEntry" is null
        at com.github.kwart.ldap.LdapServer.checkPartition(LdapServer.java:184)
        at com.github.kwart.ldap.LdapServer.importLdif(LdapServer.java:173)
        at com.github.kwart.ldap.LdapServer.importLdif(LdapServer.java:165)
        at com.github.kwart.ldap.LdapServer.<init>(LdapServer.java:97)
        at com.github.kwart.ldap.LdapServer.main(LdapServer.java:76)
matthiasblaesing commented 1 year ago

I pushed an update, that should fix the unittest run. The ldap server started in LdapServer2Test needs to be stopped.

kwart commented 1 year ago

Thanks for the improvement, Matthias. LGTM :+1: