@@ -18,22 +18,48 @@ public void test() throws LDAPException {
1818 ) {
1919 lldap .start ();
2020 LDAPConnection connection = new LDAPConnection (lldap .getHost (), lldap .getLdapPort ());
21- BindResult result = connection .bind ("cn=admin,ou=people,dc=example,dc=com" , "password" );
21+ BindResult result = connection .bind (lldap . getUser (), lldap . getUserPass () );
2222 assertThat (result ).isNotNull ();
2323 }
2424 }
2525
2626 @ Test
2727 public void testUsingLdapUrl () throws LDAPException {
28- try ( // container {
28+ try (LLdapContainer lldap = new LLdapContainer ("lldap/lldap:v0.6.1-alpine" )) {
29+ lldap .start ();
30+
31+ LDAPURL ldapUrl = new LDAPURL (lldap .getLdapUrl ());
32+ LDAPConnection connection = new LDAPConnection (ldapUrl .getHost (), ldapUrl .getPort ());
33+ BindResult result = connection .bind (lldap .getUser (), lldap .getUserPass ());
34+ assertThat (result ).isNotNull ();
35+ }
36+ }
37+
38+ @ Test
39+ public void testWithCustomBaseDn () throws LDAPException {
40+ try (
2941 LLdapContainer lldap = new LLdapContainer ("lldap/lldap:v0.6.1-alpine" )
30- // }
42+ . withBaseDn ( "dc=testcontainers,dc=org" )
3143 ) {
3244 lldap .start ();
3345
46+ assertThat (lldap .getBaseDn ()).isEqualTo ("dc=testcontainers,dc=org" );
47+
48+ LDAPURL ldapUrl = new LDAPURL (lldap .getLdapUrl ());
49+ LDAPConnection connection = new LDAPConnection (ldapUrl .getHost (), ldapUrl .getPort ());
50+ BindResult result = connection .bind (lldap .getUser (), lldap .getUserPass ());
51+ assertThat (result ).isNotNull ();
52+ }
53+ }
54+
55+ @ Test
56+ public void testWithCustomUserPass () throws LDAPException {
57+ try (LLdapContainer lldap = new LLdapContainer ("lldap/lldap:v0.6.1-alpine" ).withUserPass ("adminPas$word" )) {
58+ lldap .start ();
59+
3460 LDAPURL ldapUrl = new LDAPURL (lldap .getLdapUrl ());
3561 LDAPConnection connection = new LDAPConnection (ldapUrl .getHost (), ldapUrl .getPort ());
36- BindResult result = connection .bind ("cn=admin,ou=people,dc=example,dc=com" , "password" );
62+ BindResult result = connection .bind (lldap . getUser (), lldap . getUserPass () );
3763 assertThat (result ).isNotNull ();
3864 }
3965 }
0 commit comments