#ldap-server #ldap #integration-tests #test-server #test #temp-dir

ldap-test-server

Running isolated OpenLDAP servers in integration tests

5 releases

0.1.2 Nov 10, 2024
0.1.1 Nov 10, 2024
0.1.0 Mar 13, 2024
0.0.3 May 19, 2023
0.0.2 Mar 30, 2023

#408 in Testing

Download history 28/week @ 2024-09-23 56/week @ 2024-09-30 3/week @ 2024-10-14 86/week @ 2024-11-04 164/week @ 2024-11-11 14/week @ 2024-11-18 51/week @ 2024-12-09

73 downloads per month
Used in ldap-test-server-cli

MIT/Apache

29KB
507 lines

LDAP server for Rust integration testing

This crate allow starting isolated OpenLDAP (slapd) server in integration tests.

OpenLDAP server is created in temporary directory and uses random free port.

Example

use ldap_test_server::LdapServerBuilder;

#[tokio::main]
async fn main() {
    let server = LdapServerBuilder::new("dc=planetexpress,dc=com")
        // add LDIF to database before LDAP server is started
        .add(1, "dn: dc=planetexpress,dc=com
objectclass: dcObject
objectclass: organization
o: Planet Express
dc: planetexpress

dn: ou=people,dc=planetexpress,dc=com
objectClass: top
objectClass: organizationalUnit
description: Planet Express crew
ou: people")
        // init databases and started LDAP server
        .run()
        .await;

        // Add entity to running LDAP server
        server.add(r##"dn: cn=Turanga Leela,ou=people,dc=planetexpress,dc=com
objectClass: inetOrgPerson
objectClass: organizationalPerson
objectClass: person
objectClass: top
cn: Turanga Leela
sn: Turanga
givenName: Leela"##).await;
}

Dependencies

This crate depends on system commands that has to be available from $PATH

  • slapdd
  • slapd
  • ldapadd
  • ldapmodiy
  • ldapdelete

How to install slpad and ldap-utils on Ubuntu

DEBIAN_FRONTEND=noninteractive sudo apt-get install -y slapd ldap-utils openssl
sudo systemctl stop slapd
sudo systemctl disable slapd
sudo ln -s /etc/apparmor.d/usr.sbin.slapd /etc/apparmor.d/disable/
sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.slapd

License

Licensed under either of:

Dependencies

~15–26MB
~494K SLoC