Sign inSign up

thoteam/slapd-server-mock

By thoteam

Updated over 1 year ago

OpenLDAP docker image with configurable mock data for testing

Image
2

100K+

thoteam/slapd-server-mock repository overview

OpenLDAP docker image with configurable mock data for testing

Docker Stars Docker Pulls

This image provides an OpenLDAP Server for testing LDAP applications, i.e. unit tests. By default, the server is initialized with the example domain ldapmock.local with set of posix users/groups.

The starting point is based on docker-test-ldap by @rroemhild

This image is not built automatically. The source is avaible on the relevant git repository

As the title suggests, this is for testing only and you should not try to use this on any kind of production. Slapd configuration is minimal and the container does not store any data in persistent volumes. The mock data is bootstrapped each time the container is created and lost everytime you remove it.

Features

  • Support for TLS (snake oil cert on build)
  • Initialized on container start with default mock data or your own configured data (see below)
  • ~110MB images size (~30MB bzip compressed)

Usage

You first need to get the image locally

docker pull thoteam/slapd-server-mock
Launching with default data

You can quickly launch a container which will be initialize with the default mock data

# Use access from other container on a docker network
docker run -d --name my_slapd_mock --network my-network thoteam/slapd-server-mock
# Access the slapd container from localhost or other host on your network
docker run -d -p 389:389 -p 636:636 --name my_slapd_mock thoteam/slapd-server-mock
Customizing the container.

You can easilly customize the data used to initialize this mock instance through variables and custom volume mounts for specific files.

Environment variables

You can set the following environment variables in your container

variabledefault valueUsage
LDAP_SECRETadminpassPassword for slapdadmin
LDAP_DOMAINldapmock.localUsed as the configured domain for slapd and to create the snakeoil ssl cert
LDAP_ORGANISATIONLDAP Mock, Inc.Used as the configured organisation for slapd
LDAP_DEBUG_LEVEL256Slapd debug level (see man slapd)
BOOTSTRAP_DIR/bootstrapDirectory holding boostrap files where config.ldif and data.ldif reside

Other variables are calculated from the above (will be overwritten if set)

variabledefault valueusagecalulation
LDAP_BASEDNdc=ldapmock,dc=localdynamic basedn replacement (templates...)Infered from LDAP_DOMAIN
LDAP_BINDDNcn=admin,dc=ldapmock,dc=localadmin binddn for slapadminInfered from LDAP_BASEDN
Bootstrap config and data.

The run.sh docker container command will launch slapd-init.sh

slapd-init.sh is expecting 2 ldif template files in $BOOTSTRAP_DIR:

Those file can actually contain bash variable expressions which will get replaced by their env vars values (with envsubst command from gettext package). The default template for data allow to configure the LDAP_BASEDN for all entries depending on the chosen domain name.

To override these files, simply bind mount your custom files from your local filesystem to the container. If needed you can change the default /bootstrap directory location on the container by setting $BOOTSTRAP_DIR

# override data only
docker run -d --name my_slapd_mock -v /path/to/my/data.ldif:/bootstrap/data.ldif.TEMPLATE thoteam/slapd-server-mock

# override both data and config
docker run -d --name my_slapd_mock -v /path/to/my/bootstrap_dir:/bootstrap thoteam/slapd-server-mock

# override both on a custom location
docker run -d --name my_slapd_mock -v /path/to/my/bootstrap_dir:/customdir -e BOOTSTRAP_DIR=/customdir thoteam/slapd-server-mock

Exposed ports

  • 389 (ldap://)
  • 636 (ldaps://)

default LDAP structure

See the ldap objects definitions in bootstrap/data.ldif for details. All users have the same password: password

dc=ldapmock,dc=local
|    cn=admin,dc=ldapmock,dc=local
|
└─── ou=people,dc=ldapmock,dc=local
|    |    uid=adminuser1,ou=people,dc=ldapmock,dc=local
|    |    uid=adminuser2,ou=people,dc=ldapmock,dc=local
|    |    uid=developper1,ou=people,dc=ldapmock,dc=local
|    |    uid=developper2,ou=people,dc=ldapmock,dc=local
|    |    uid=developper3,ou=people,dc=ldapmock,dc=local
|    |    uid=developper4,ou=people,dc=ldapmock,dc=local
|
└─── ou=groups,dc=ldapmock,dc=local
     |
     └─── cn=admin,ou=groups,dc=ldapmock,dc=local
     |    |    memberUID:adminuser1
     |    |    memberUID:adminuser2
     |
     └─── cn=admin,ou=groups,dc=ldapmock,dc=local
          |    memberUID:developper1
          |    memberUID:developper2
          |    memberUID:developper3
          |    memberUID:developper4

Tag summary

Content type

Image

Digest

sha256:f1f976cab

Size

44.6 MB

Last updated

over 1 year ago

docker pull thoteam/slapd-server-mock