Real-LDAP Docker Integration
Relevant source files
The following files were used as context for generating this wiki page:
Real-LDAP Docker Integration provides a comprehensive environment for validating LDIF processing library capabilities against live LDAP server instances. This system ensures that the library's parsing, writing, and transformation logic remains compatible with actual directory server behaviors, moving beyond static unit tests to verify network-level interaction and protocol compliance.
The integration utilizes Docker-based containers to spin up ephemeral LDAP servers (such as OpenLDAP) during the test lifecycle. This infrastructure supports a wide range of operational tests including full CRUD (Create, Read, Update, Delete) cycles, complex data roundtrips, and batch processing of hierarchical structures.
Sources: tests/integration/README.md:31-41, tests/README.md:144-162
Infrastructure and Lifecycle
The integration environment relies on Pytest fixtures and Docker containers to provide a clean state for every test session. The ldap_server fixture manages the container lifecycle, ensuring the server is ready before tests execute and is removed afterward.
Docker Environment Configuration
The standard testing container uses the osixia/openldap image. It is configured with specific environment variables to define the organization and domain, mapping internal LDAP ports to host ports for connectivity.
| Parameter | Default Value | Description |
|---|---|---|
| Image | osixia/openldap:1.5.0 | The base Docker image used for the LDAP server. |
| LDAP_ORGANISATION | Example Corp | The organization name in the directory. |
| LDAP_DOMAIN | example.com | The base domain for the LDAP suffix. |
| Port Mapping | 389/tcp -> 1389 | Maps standard LDAP port to host port 1389. |
Sources: tests/README.md:144-162, tests/integration/README.md:275-285
Connection and Setup Flow
The following diagram illustrates the sequence of establishing a connection between the test suite and the Docker-based LDAP server.
The system uses wait_for_ldap_ready to prevent race conditions during container startup.
Sources: tests/README.md:144-162
CRUD Operations and Data Integrity
The integration suite validates the ability to perform standard directory operations via the ldif API and ldap3 library adapters.
Complete CRUD Cycle
Tests verify a full lifecycle for directory entries:
- Create: Generating a
m.Ldif.Entryand adding it to the server. - Read: Searching for the entry via
(objectClass=*)filters. - Update: Modifying attributes using
MODIFY_REPLACEoperations. - Delete: Removing the entry and confirming its absence.
Sources: tests/integration/test_real_ldap_crud.py:48-84
Data Roundtrip Validation
Roundtrip testing ensures that data remains consistent when moved between the live server and LDIF format. This validates the preservation of:
- Multi-valued attributes (e.g.,
telephoneNumber). - Multi-line descriptions.
- Binary data (e.g.,
jpegPhotoencoded in base64). - Attribute types and case sensitivity.
Sources: tests/integration/test_real_ldap_roundtrip.py:46-103, tests/integration/test_real_ldap_import.py:80-111
Import and Export Pipelines
The integration supports both single entry and batch operations for moving data between files and the directory.
Export Logic
The export process utilizes the FlextLdapEntryAdapter to convert live ldap3 entries into the library's internal m.Ldif.Entry models before writing them to disk.
This pipeline supports hierarchical structures, ensuring that parent OUs (e.g., ou=People) and their child objects are exported with correct DN relationships.
Sources: tests/integration/test_real_ldap_export.py:45-132
Batch Import and Binary Data
Imports are tested using both raw LDIF strings and physical files via flext_api.parse_ldif. The system handles:
- Binary Attributes: Base64-encoded LDIF values are decoded and stored as raw bytes in the LDAP server (e.g.,
jpegPhoto::). - Batching: Simultaneous creation of multiple entries (e.g., 20+ users) to verify performance and connection stability.
Sources: tests/integration/test_real_ldap_import.py:45-144, tests/integration/test_real_ldap_crud.py:88-125
Summary of Integration Tests
| Test Category | File Reference | Primary Objective |
|---|---|---|
| CRUD | test_real_ldap_crud.py | Validates Create, Read, Update, and Delete entry life-cycles. |
| Roundtrip | test_real_ldap_roundtrip.py | Ensures data integrity across LDAP → LDIF → LDAP cycles. |
| Import | test_real_ldap_import.py | Validates processing of LDIF files, strings, and binary data into the server. |
| Export | test_real_ldap_export.py | Tests directory hierarchy extraction to LDIF format. |
Sources: tests/integration/README.md:121-147
Conclusion
The Real-LDAP Docker Integration serves as the final quality gate for the flext-ldif library. By using real containers and live directory protocols, the system confirms that LDIF parsing and writing logic adheres to the expectations of standard-compliant servers like OpenLDAP, OID, and OUD. This approach provides developers with high confidence in the library's readiness for enterprise migration and directory management workflows.