diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml index 8017aad8f8c..c31dd05e048 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yaml +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -34,6 +34,7 @@ body: - K3S - K6 - Kafka + - LDAP - LocalStack - MariaDB - Milvus diff --git a/.github/ISSUE_TEMPLATE/enhancement.yaml b/.github/ISSUE_TEMPLATE/enhancement.yaml index f0545bed3e3..9b9a06ecf6a 100644 --- a/.github/ISSUE_TEMPLATE/enhancement.yaml +++ b/.github/ISSUE_TEMPLATE/enhancement.yaml @@ -34,6 +34,7 @@ body: - K3S - K6 - Kafka + - LDAP - LocalStack - MariaDB - Milvus diff --git a/.github/ISSUE_TEMPLATE/feature.yaml b/.github/ISSUE_TEMPLATE/feature.yaml index cf3a2ac0620..b655b4ac505 100644 --- a/.github/ISSUE_TEMPLATE/feature.yaml +++ b/.github/ISSUE_TEMPLATE/feature.yaml @@ -34,6 +34,7 @@ body: - K3S - K6 - Kafka + - LDAP - LocalStack - MariaDB - Milvus diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 11ccc33e3de..bffc5623611 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -178,6 +178,11 @@ updates: schedule: interval: "weekly" open-pull-requests-limit: 10 + - package-ecosystem: "gradle" + directory: "/modules/ldap" + schedule: + interval: "weekly" + open-pull-requests-limit: 10 - package-ecosystem: "gradle" directory: "/modules/localstack" schedule: diff --git a/.github/labeler.yml b/.github/labeler.yml index 3c8eace8229..f4649bd7f99 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -107,6 +107,10 @@ - changed-files: - any-glob-to-any-file: - modules/kafka/**/* +"modules/ldap": + - changed-files: + - any-glob-to-any-file: + - modules/ldap/**/* "modules/localstack": - changed-files: - any-glob-to-any-file: diff --git a/.github/settings.yml b/.github/settings.yml index 35266397a60..63c8afacb90 100644 --- a/.github/settings.yml +++ b/.github/settings.yml @@ -169,6 +169,9 @@ labels: - name: modules/kafka color: '#006b75' + - name: modules/ldap + color: '#006b75' + - name: modules/localstack color: '#006b75' diff --git a/docs/modules/ldap.md b/docs/modules/ldap.md new file mode 100644 index 00000000000..771975d6346 --- /dev/null +++ b/docs/modules/ldap.md @@ -0,0 +1,30 @@ +# LDAP + +Testcontainers module for [LLDAP](https://hub.docker.com/r/lldap/lldap). + +## LLdapContainer's usage examples + +You can start a LLDAP container instance from any Java application by using: + + +[LLDAP container](../../modules/ldap/src/test/java/org/testcontainers/ldap/LLdapContainerTest.java) inside_block:container + + +## Adding this module to your project dependencies + +Add the following dependency to your `pom.xml`/`build.gradle` file: + +=== "Gradle" + ```groovy + testImplementation "org.testcontainers:ldap:{{latest_version}}" + ``` + +=== "Maven" + ```xml + + org.testcontainers + ldap + {{latest_version}} + test + + ``` diff --git a/mkdocs.yml b/mkdocs.yml index f1b894a158a..0245c2f1419 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -89,6 +89,7 @@ nav: - modules/k3s.md - modules/k6.md - modules/kafka.md + - modules/ldap.md - modules/localstack.md - modules/milvus.md - modules/minio.md diff --git a/modules/ldap/build.gradle b/modules/ldap/build.gradle new file mode 100644 index 00000000000..52366d06737 --- /dev/null +++ b/modules/ldap/build.gradle @@ -0,0 +1,8 @@ +description = "Testcontainers :: LDAP" + +dependencies { + api project(':testcontainers') + + testImplementation 'org.assertj:assertj-core:3.26.3' + testImplementation 'com.unboundid:unboundid-ldapsdk:7.0.2' +} diff --git a/modules/ldap/src/main/java/org/testcontainers/ldap/LLdapContainer.java b/modules/ldap/src/main/java/org/testcontainers/ldap/LLdapContainer.java new file mode 100644 index 00000000000..a70a51e215b --- /dev/null +++ b/modules/ldap/src/main/java/org/testcontainers/ldap/LLdapContainer.java @@ -0,0 +1,51 @@ +package org.testcontainers.ldap; + +import com.github.dockerjava.api.command.InspectContainerResponse; +import lombok.extern.slf4j.Slf4j; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.containers.wait.strategy.Wait; +import org.testcontainers.utility.DockerImageName; + +/** + * Testcontainers implementation for LLDAP. + *

+ * Supported image: {@code lldap/lldap} + *

+ * Exposed ports: + *

+ */ +@Slf4j +public class LLdapContainer extends GenericContainer { + + private static final String IMAGE_VERSION = "lldap/lldap"; + + private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse(IMAGE_VERSION); + + private static final int LDAP_PORT = 3890; + + private static final int UI_PORT = 17170; + + public LLdapContainer(String image) { + this(DockerImageName.parse(image)); + } + + public LLdapContainer(DockerImageName image) { + super(image); + image.assertCompatibleWith(DEFAULT_IMAGE_NAME); + addExposedPorts(LDAP_PORT, UI_PORT); + + waitingFor(Wait.forHttp("/health").forPort(UI_PORT).forStatusCode(200)); + } + + @Override + protected void containerIsStarted(InspectContainerResponse containerInfo) { + log.info("LLDAP container is ready! UI available at http://{}:{}", getHost(), getMappedPort(UI_PORT)); + } + + public int getLdapPort() { + return getMappedPort(LDAP_PORT); + } +} diff --git a/modules/ldap/src/test/java/org/testcontainers/ldap/LLdapContainerTest.java b/modules/ldap/src/test/java/org/testcontainers/ldap/LLdapContainerTest.java new file mode 100644 index 00000000000..c6d490219fd --- /dev/null +++ b/modules/ldap/src/test/java/org/testcontainers/ldap/LLdapContainerTest.java @@ -0,0 +1,24 @@ +package org.testcontainers.ldap; + +import com.unboundid.ldap.sdk.BindResult; +import com.unboundid.ldap.sdk.LDAPConnection; +import com.unboundid.ldap.sdk.LDAPException; +import org.junit.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +public class LLdapContainerTest { + + @Test + public void test() throws LDAPException { + try ( // container { + LLdapContainer lldap = new LLdapContainer("lldap/lldap:v0.6.1-alpine") + // } + ) { + lldap.start(); + LDAPConnection connection = new LDAPConnection(lldap.getHost(), lldap.getLdapPort()); + BindResult result = connection.bind("cn=admin,ou=people,dc=example,dc=com", "password"); + assertThat(result).isNotNull(); + } + } +} diff --git a/modules/ldap/src/test/resources/logback-test.xml b/modules/ldap/src/test/resources/logback-test.xml new file mode 100644 index 00000000000..83ef7a1a3ef --- /dev/null +++ b/modules/ldap/src/test/resources/logback-test.xml @@ -0,0 +1,16 @@ + + + + + + %d{HH:mm:ss.SSS} %-5level %logger - %msg%n + + + + + + + + +