-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved most of the unit tests from embedded-ldap-junit to embedded-lda…
…p-core
- Loading branch information
Showing
24 changed files
with
2,339 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
...p-core/src/test/java/org/zapodot/junit/ldap/internal/AbstractEmbeddedLdapBuilderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package org.zapodot.junit.ldap.internal; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertNotNull; | ||
|
||
public class AbstractEmbeddedLdapBuilderTest { | ||
|
||
@Test | ||
public void bindingToLegalPort() { | ||
assertNotNull(FakeEmbeddedLdapBuilder.newInstance().bindingToPort(9999)); | ||
} | ||
|
||
@Test(expected = IllegalStateException.class) | ||
public void testPrematureLdapConnection() throws Exception { | ||
FakeEmbeddedLdapBuilder.newInstance().build().ldapConnection(); | ||
|
||
} | ||
|
||
@Test(expected = IllegalStateException.class) | ||
public void testPrematureContext() throws Exception { | ||
FakeEmbeddedLdapBuilder.newInstance().build().context(); | ||
|
||
} | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void testUnknownLDIF() { | ||
FakeEmbeddedLdapBuilder.newInstance().importingLdifs("nonExisting.ldif").build(); | ||
|
||
} | ||
|
||
@Test | ||
public void testNullLDIF() { | ||
assertNotNull(FakeEmbeddedLdapBuilder.newInstance().importingLdifs(null).build()); | ||
|
||
} | ||
|
||
@Test(expected = IllegalStateException.class) | ||
public void testIllegalDSN() { | ||
FakeEmbeddedLdapBuilder.newInstance().usingBindDSN("bindDsn").build(); | ||
|
||
} | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void testIllegalPort() { | ||
FakeEmbeddedLdapBuilder.newInstance().bindingToPort(Integer.MIN_VALUE).build(); | ||
|
||
} | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void testSchemaNotFound() { | ||
FakeEmbeddedLdapBuilder.newInstance().withSchema("non-existing-schema.ldif").build(); | ||
|
||
} | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void testSchemaIsNotAFile() { | ||
FakeEmbeddedLdapBuilder.newInstance().withSchema("folder").build(); | ||
|
||
} | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void testSchemaIsInvalid() { | ||
FakeEmbeddedLdapBuilder.newInstance().withSchema("invalid.ldif").build(); | ||
|
||
} | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void testSchemaFileUnsupportedIsInvalid() { | ||
FakeEmbeddedLdapBuilder.newInstance().withSchema("\"#%¤&&%/¤##¤¤").build(); | ||
|
||
} | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void testInvalidPort() { | ||
FakeEmbeddedLdapBuilder.newInstance().bindingToPort(Integer.MAX_VALUE); | ||
|
||
} | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void testInvalidBindAddress() { | ||
FakeEmbeddedLdapBuilder.newInstance().bindingToAddress("åpsldfåpl"); | ||
|
||
} | ||
|
||
|
||
} | ||
|
File renamed without changes.
35 changes: 35 additions & 0 deletions
35
...st/java/org/zapodot/junit/ldap/internal/EmbeddedLdapServerCustomSchemaDuplicatedTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package org.zapodot.junit.ldap.internal; | ||
|
||
import com.unboundid.ldap.sdk.LDAPException; | ||
import com.unboundid.ldap.sdk.schema.AttributeTypeDefinition; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.zapodot.junit.ldap.EmbeddedLdapServer; | ||
|
||
import static org.junit.Assert.assertNotNull; | ||
|
||
public class EmbeddedLdapServerCustomSchemaDuplicatedTest { | ||
|
||
private final EmbeddedLdapServer embeddedLdapRule = FakeEmbeddedLdapBuilder.newInstance() | ||
.withSchema("standard-schema.ldif") | ||
.build(); | ||
|
||
@Before | ||
public void setup() throws LDAPException { | ||
((EmbeddedLdapServerImpl) embeddedLdapRule).startEmbeddedLdapServer(); | ||
} | ||
|
||
@After | ||
public void teardown() throws LDAPException { | ||
((EmbeddedLdapServerImpl) embeddedLdapRule).takeDownEmbeddedLdapServer(); | ||
} | ||
|
||
@Test | ||
public void testFindCustomAttribute() throws Exception { | ||
final AttributeTypeDefinition changelogAttribute = | ||
embeddedLdapRule.ldapConnection().getSchema().getAttributeType("changelog"); | ||
assertNotNull(changelogAttribute); | ||
|
||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
.../org/zapodot/junit/ldap/internal/EmbeddedLdapServerCustomStandardAndCustomSchemaTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.zapodot.junit.ldap.internal; | ||
|
||
import com.unboundid.ldap.sdk.LDAPException; | ||
import com.unboundid.ldap.sdk.schema.AttributeTypeDefinition; | ||
import com.unboundid.ldap.sdk.schema.Schema; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.zapodot.junit.ldap.EmbeddedLdapServer; | ||
|
||
import static org.junit.Assert.assertNotNull; | ||
|
||
public class EmbeddedLdapServerCustomStandardAndCustomSchemaTest { | ||
|
||
private final EmbeddedLdapServer embeddedLdapRule = FakeEmbeddedLdapBuilder.newInstance() | ||
.withSchema("custom-schema.ldif") | ||
.build(); | ||
|
||
@Before | ||
public void setup() throws LDAPException { | ||
((EmbeddedLdapServerImpl) embeddedLdapRule).startEmbeddedLdapServer(); | ||
} | ||
|
||
@After | ||
public void teardown() throws LDAPException { | ||
((EmbeddedLdapServerImpl) embeddedLdapRule).takeDownEmbeddedLdapServer(); | ||
} | ||
|
||
@Test | ||
public void testFindCustomAttribute() throws Exception { | ||
final Schema currentSchema = embeddedLdapRule.ldapConnection().getSchema(); | ||
final AttributeTypeDefinition changelogAttribute = | ||
currentSchema.getAttributeType("attribute"); | ||
assertNotNull(changelogAttribute); | ||
assertNotNull(currentSchema.getObjectClass("type")); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
.../test/java/org/zapodot/junit/ldap/internal/EmbeddedLdapServerCustomWithoutSchemaTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package org.zapodot.junit.ldap.internal; | ||
|
||
import com.unboundid.ldap.sdk.LDAPException; | ||
import com.unboundid.ldap.sdk.schema.Schema; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.zapodot.junit.ldap.EmbeddedLdapServer; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
public class EmbeddedLdapServerCustomWithoutSchemaTest { | ||
|
||
private final EmbeddedLdapServer embeddedLdapRule = FakeEmbeddedLdapBuilder.newInstance() | ||
.withoutDefaultSchema() | ||
.build(); | ||
|
||
@Before | ||
public void setup() throws LDAPException { | ||
((EmbeddedLdapServerImpl) embeddedLdapRule).startEmbeddedLdapServer(); | ||
} | ||
|
||
@After | ||
public void teardown() throws LDAPException { | ||
((EmbeddedLdapServerImpl) embeddedLdapRule).takeDownEmbeddedLdapServer(); | ||
} | ||
|
||
@Test | ||
public void testEmptySchema() throws Exception { | ||
final Schema schema = | ||
embeddedLdapRule.ldapConnection().getSchema(); | ||
assertTrue(schema.getAttributeTypes().isEmpty()); | ||
|
||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...va/org/zapodot/junit/ldap/internal/EmbeddedLdapServerCustomWithoutStandardSchemaTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.zapodot.junit.ldap.internal; | ||
|
||
import com.unboundid.ldap.sdk.LDAPException; | ||
import com.unboundid.ldap.sdk.schema.AttributeTypeDefinition; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.zapodot.junit.ldap.EmbeddedLdapServer; | ||
|
||
import static org.junit.Assert.assertNotNull; | ||
|
||
public class EmbeddedLdapServerCustomWithoutStandardSchemaTest { | ||
|
||
private final EmbeddedLdapServer embeddedLdapRule = FakeEmbeddedLdapBuilder.newInstance() | ||
.withoutDefaultSchema() | ||
.withSchema("standard-schema.ldif") | ||
.build(); | ||
|
||
@Before | ||
public void setup() throws LDAPException { | ||
((EmbeddedLdapServerImpl) embeddedLdapRule).startEmbeddedLdapServer(); | ||
} | ||
|
||
@After | ||
public void teardown() throws LDAPException { | ||
((EmbeddedLdapServerImpl) embeddedLdapRule).takeDownEmbeddedLdapServer(); | ||
} | ||
|
||
@Test | ||
public void testFindCustomAttribute() throws Exception { | ||
final AttributeTypeDefinition changelogAttribute = | ||
embeddedLdapRule.ldapConnection().getSchema().getAttributeType("changelog"); | ||
assertNotNull(changelogAttribute); | ||
|
||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...ap-core/src/test/java/org/zapodot/junit/ldap/internal/EmbeddedLdapServerMultipleDSNs.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.zapodot.junit.ldap.internal; | ||
|
||
import com.unboundid.ldap.sdk.LDAPException; | ||
import com.unboundid.ldap.sdk.LDAPInterface; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.zapodot.junit.ldap.EmbeddedLdapServer; | ||
|
||
import static org.junit.Assert.assertArrayEquals; | ||
|
||
public class EmbeddedLdapServerMultipleDSNs { | ||
|
||
public static final String DSN_ROOT_ONE = "dc=zapodot,dc=com"; | ||
public static final String DSN_ROOT_TWO = "dc=zapodot,dc=org"; | ||
|
||
private final EmbeddedLdapServer embeddedLdapRule = FakeEmbeddedLdapBuilder.newInstance() | ||
.usingDomainDsn(DSN_ROOT_ONE) | ||
.usingDomainDsn(DSN_ROOT_TWO) | ||
.importingLdifs("example.ldif") | ||
.build(); | ||
|
||
@Before | ||
public void setup() throws LDAPException { | ||
((EmbeddedLdapServerImpl) embeddedLdapRule).startEmbeddedLdapServer(); | ||
} | ||
|
||
@After | ||
public void teardown() throws LDAPException { | ||
((EmbeddedLdapServerImpl) embeddedLdapRule).takeDownEmbeddedLdapServer(); | ||
} | ||
|
||
@Test | ||
public void testCheckNamingContexts() throws Exception { | ||
final LDAPInterface ldapConnection = embeddedLdapRule.ldapConnection(); | ||
final String[] namingContextDNs = ldapConnection.getRootDSE().getNamingContextDNs(); | ||
assertArrayEquals(new String[]{DSN_ROOT_ONE, DSN_ROOT_TWO}, namingContextDNs); | ||
|
||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...ldap-core/src/test/java/org/zapodot/junit/ldap/internal/EmbeddedLdapServerNoAuthTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package org.zapodot.junit.ldap.internal; | ||
|
||
import com.unboundid.ldap.sdk.LDAPException; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.zapodot.junit.ldap.EmbeddedLdapServer; | ||
|
||
import static org.junit.Assert.assertNotNull; | ||
|
||
public class EmbeddedLdapServerNoAuthTest { | ||
|
||
private final EmbeddedLdapServer embeddedLdapRule = FakeEmbeddedLdapBuilder | ||
.newInstance() | ||
.usingBindCredentials(null) | ||
.usingDomainDsn("dc=zapodot,dc=org") | ||
.importingLdifs("example.ldif") | ||
.build(); | ||
|
||
@Before | ||
public void setup() throws LDAPException { | ||
((EmbeddedLdapServerImpl) embeddedLdapRule).startEmbeddedLdapServer(); | ||
} | ||
|
||
@After | ||
public void teardown() throws LDAPException { | ||
((EmbeddedLdapServerImpl) embeddedLdapRule).takeDownEmbeddedLdapServer(); | ||
} | ||
|
||
@Test | ||
public void testConnect() throws Exception { | ||
assertNotNull(embeddedLdapRule.dirContext().search("cn=Sondre Eikanger Kvalo,ou=people,dc=zapodot,dc=org", null)); | ||
|
||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...core/src/test/java/org/zapodot/junit/ldap/internal/EmbeddedLdapServerStandardContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.zapodot.junit.ldap.internal; | ||
|
||
import com.unboundid.ldap.sdk.LDAPException; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.zapodot.junit.ldap.EmbeddedLdapServer; | ||
|
||
import static org.junit.Assert.assertArrayEquals; | ||
|
||
public class EmbeddedLdapServerStandardContext { | ||
|
||
private final EmbeddedLdapServer embeddedLdapRule = FakeEmbeddedLdapBuilder.newInstance() | ||
.build(); | ||
|
||
@Before | ||
public void setup() throws LDAPException { | ||
((EmbeddedLdapServerImpl) embeddedLdapRule).startEmbeddedLdapServer(); | ||
} | ||
|
||
@After | ||
public void teardown() throws LDAPException { | ||
((EmbeddedLdapServerImpl) embeddedLdapRule).takeDownEmbeddedLdapServer(); | ||
} | ||
|
||
@Test | ||
public void testUsingDefaultDomain() throws Exception { | ||
assertArrayEquals(new String[]{FakeEmbeddedLdapBuilder.DEFAULT_DOMAIN}, | ||
embeddedLdapRule.ldapConnection().getRootDSE().getNamingContextDNs()); | ||
|
||
|
||
} | ||
} |
Oops, something went wrong.