Crates.io | ldap-test-server |
lib.rs | ldap-test-server |
version | 0.1.2 |
source | src |
created_at | 2023-03-26 20:29:07.173551 |
updated_at | 2024-11-10 20:28:30.639763 |
description | Running isolated OpenLDAP servers in integration tests |
homepage | |
repository | https://gitlab.com/mateuszkj/ldap-test-server |
max_upload_size | |
id | 821512 |
size | 45,478 |
This crate allow starting isolated OpenLDAP (slapd) server in integration tests.
OpenLDAP server is created in temporary directory and uses random free port.
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;
}
This crate depends on system commands that has to be available from $PATH
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
Licensed under either of: