Add Docker Compose service connection support for OpenLDAP

See gh-39258
This commit is contained in:
PhilKes
2024-01-21 15:07:37 +01:00
committed by Scott Frederick
parent a0a804cfdf
commit eb940c3907
16 changed files with 592 additions and 5 deletions

View File

@@ -0,0 +1,48 @@
/*
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.docker.compose.service.connection.ldap;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.ldap.LdapConnectionDetails;
import org.springframework.boot.docker.compose.service.connection.test.AbstractDockerComposeIntegrationTests;
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Integration tests for {@link LdapDockerComposeConnectionDetailsFactory}.
*
* @author Philipp Kessler
*/
class LdapDockerComposeConnectionDetailsFactoryIntegrationTests extends AbstractDockerComposeIntegrationTests {
LdapDockerComposeConnectionDetailsFactoryIntegrationTests() {
super("ldap-compose.yaml", DockerImageNames.ldap());
}
@Test
void runCreatesConnectionDetails() {
LdapConnectionDetails connectionDetails = run(LdapConnectionDetails.class);
assertThat(connectionDetails.getUsername()).isEqualTo("cn=admin,dc=ldap,dc=example,dc=org");
assertThat(connectionDetails.getPassword()).isEqualTo("somepassword");
assertThat(connectionDetails.getBase()).isEqualTo("dc=ldap,dc=example,dc=org");
assertThat(connectionDetails.getUrls()).hasSize(1);
assertThat(connectionDetails.getUrls()[0]).startsWith("ldaps://");
}
}

View File

@@ -0,0 +1,11 @@
services:
ldap:
image: '{imageName}'
environment:
- 'LDAP_DOMAIN=ldap.example.org'
- 'LDAP_ADMIN_PASSWORD=somepassword'
- 'LDAP_TLS=true'
hostname: ldap
ports:
- "389"
- "636"