| | |
| | | import java.util.concurrent.TimeoutException; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.config.server.ConfigurationChangeListener; |
| | | import org.forgerock.opendj.io.ASN1; |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.forgerock.opendj.config.server.ConfigurationChangeListener; |
| | | import org.forgerock.opendj.server.config.meta.LDAPPassThroughAuthenticationPolicyCfgDefn.MappingPolicy; |
| | | import org.forgerock.opendj.server.config.server.AuthenticationPolicyCfg; |
| | | import org.forgerock.opendj.server.config.server.LDAPPassThroughAuthenticationPolicyCfg; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.api.AuthenticationPolicy; |
| | | import org.opends.server.api.AuthenticationPolicyState; |
| | | import org.opends.server.core.DirectoryServer; |
| | |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * Test LDAP authentication mappingPolicy implementation. |
| | | */ |
| | | /** Test LDAP authentication mappingPolicy implementation. */ |
| | | public class LDAPPassThroughAuthenticationPolicyTestCase extends |
| | | ExtensionsTestCase |
| | | { |
| | | |
| | | static class CloseEvent extends Event<Void> |
| | | { |
| | | private final GetConnectionEvent getConnectionEvent; |
| | |
| | | this.getConnectionEvent = getConnectionEvent; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | boolean matchesEvent(final Event<?> event) |
| | | { |
| | |
| | | return false; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | StringBuilder toString(final StringBuilder builder) |
| | | { |
| | |
| | | builder.append(')'); |
| | | return builder; |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | static abstract class Event<T> |
| | | { |
| | | |
| | | @Override |
| | | public final boolean equals(final Object obj) |
| | | { |
| | |
| | | return false; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public final String toString() |
| | | { |
| | |
| | | return toString(builder).toString(); |
| | | } |
| | | |
| | | |
| | | |
| | | T getResult() |
| | | { |
| | | return null; |
| | |
| | | abstract StringBuilder toString(StringBuilder builder); |
| | | } |
| | | |
| | | |
| | | |
| | | static class GetConnectionEvent extends Event<DirectoryException> |
| | | { |
| | | private final GetLDAPConnectionFactoryEvent fevent; |
| | |
| | | this.resultCode = resultCode; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | DirectoryException getResult() |
| | | { |
| | |
| | | return null; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | boolean matchesEvent(final Event<?> event) |
| | | { |
| | |
| | | return false; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | StringBuilder toString(final StringBuilder builder) |
| | | { |
| | |
| | | builder.append(')'); |
| | | return builder; |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | static class GetLDAPConnectionFactoryEvent extends Event<Void> |
| | | { |
| | | private final String hostPort; |
| | | private final LDAPPassThroughAuthenticationPolicyCfg options; |
| | | |
| | | |
| | | |
| | | GetLDAPConnectionFactoryEvent(final String hostPort, |
| | | final LDAPPassThroughAuthenticationPolicyCfg options) |
| | | { |
| | |
| | | this.options = options; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | boolean matchesEvent(final Event<?> event) |
| | | { |
| | |
| | | return false; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | StringBuilder toString(final StringBuilder builder) |
| | | { |
| | |
| | | builder.append(')'); |
| | | return builder; |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | static final class MockConnection implements |
| | | LDAPPassThroughAuthenticationPolicyFactory.Connection |
| | | { |
| | | |
| | | private final GetConnectionEvent getConnectionEvent; |
| | | private final MockProvider mockProvider; |
| | | |
| | | |
| | | |
| | | MockConnection(final MockProvider mockProvider, |
| | | final GetConnectionEvent getConnectionEvent) |
| | | { |
| | |
| | | this.getConnectionEvent = getConnectionEvent; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void close() |
| | | { |
| | |
| | | mockProvider.assertExpectedEventWasReceived(event); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ByteString search(final DN baseDN, final SearchScope scope, |
| | | final SearchFilter filter) throws DirectoryException |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void simpleBind(final ByteString username, final ByteString password) |
| | | throws DirectoryException |
| | |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | static final class MockFactory implements |
| | | LDAPPassThroughAuthenticationPolicyFactory.ConnectionFactory |
| | | { |
| | | private final GetLDAPConnectionFactoryEvent getLDAPConnectionFactoryEvent; |
| | | private final MockProvider mockProvider; |
| | | |
| | | |
| | | |
| | | MockFactory(final MockProvider mockProvider, |
| | | final GetLDAPConnectionFactoryEvent providerEvent) |
| | | { |
| | |
| | | this.getLDAPConnectionFactoryEvent = providerEvent; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void close() |
| | | { |
| | | // Nothing to do. |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Connection getConnection() throws DirectoryException |
| | | { |
| | |
| | | { |
| | | throw e; |
| | | } |
| | | else |
| | | { |
| | | return new MockConnection(mockProvider, event); |
| | | } |
| | | return new MockConnection(mockProvider, event); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | final class MockPolicyCfg implements LDAPPassThroughAuthenticationPolicyCfg |
| | | { |
| | | private final SortedSet<DN> baseDNs = new TreeSet<>(); |
| | |
| | | private String mappedSearchBindPasswordProperty; |
| | | private boolean usePasswordCaching; |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public void addChangeListener( |
| | | final ConfigurationChangeListener<AuthenticationPolicyCfg> listener) |
| | |
| | | // Do nothing. |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public void addLDAPPassThroughChangeListener( |
| | | final ConfigurationChangeListener<LDAPPassThroughAuthenticationPolicyCfg> listener) |
| | |
| | | // Do nothing. |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public Class<? extends LDAPPassThroughAuthenticationPolicyCfg> configurationClass() |
| | | { |
| | | return LDAPPassThroughAuthenticationPolicyCfg.class; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public DN dn() |
| | | { |
| | | return policyDN; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public long getConnectionTimeout() |
| | | { |
| | | return timeoutMS; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public InetAddress getSourceAddress() { return null; } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public String getJavaClass() |
| | | { |
| | | return LDAPPassThroughAuthenticationPolicyFactory.class.getName(); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public SortedSet<AttributeType> getMappedAttribute() |
| | | { |
| | | return mappedAttributes; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public SortedSet<DN> getMappedSearchBaseDN() |
| | | { |
| | | return baseDNs; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public DN getMappedSearchBindDN() |
| | | { |
| | | return mappedSearchBindDN; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public String getMappedSearchBindPassword() |
| | | { |
| | | return mappedSearchBindPassword; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public MappingPolicy getMappingPolicy() |
| | | { |
| | | return mappingPolicy; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public SortedSet<String> getPrimaryRemoteLDAPServer() |
| | | { |
| | | return primaryServers; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public SortedSet<String> getSecondaryRemoteLDAPServer() |
| | | { |
| | | return secondaryServers; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public SortedSet<String> getSSLCipherSuite() |
| | | { |
| | | return new TreeSet<>(); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public SortedSet<String> getSSLProtocol() |
| | | { |
| | | return new TreeSet<>(); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public String getTrustManagerProvider() |
| | | { |
| | | return "ignored"; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public DN getTrustManagerProviderDN() |
| | | { |
| | | return trustManagerDN; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public boolean isUseSSL() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public boolean isUseTCPKeepAlive() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public boolean isUseTCPNoDelay() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public void removeChangeListener( |
| | | final ConfigurationChangeListener<AuthenticationPolicyCfg> listener) |
| | |
| | | // Do nothing. |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public void removeLDAPPassThroughChangeListener( |
| | | final ConfigurationChangeListener<LDAPPassThroughAuthenticationPolicyCfg> listener) |
| | |
| | | // Do nothing. |
| | | } |
| | | |
| | | |
| | | |
| | | MockPolicyCfg withBaseDN(final String baseDN) |
| | | { |
| | | baseDNs.add(DN.valueOf(baseDN)); |
| | | return this; |
| | | } |
| | | |
| | | |
| | | |
| | | MockPolicyCfg withConnectionTimeout(final int timeoutMS) |
| | | { |
| | | this.timeoutMS = timeoutMS; |
| | | return this; |
| | | } |
| | | |
| | | |
| | | |
| | | MockPolicyCfg withMappedAttribute(final String attrName) |
| | | { |
| | | mappedAttributes.add(DirectoryServer.getAttributeType(attrName)); |
| | | return this; |
| | | } |
| | | |
| | | |
| | | |
| | | MockPolicyCfg withMappingPolicy(final MappingPolicy policy) |
| | | { |
| | | this.mappingPolicy = policy; |
| | | return this; |
| | | } |
| | | |
| | | |
| | | |
| | | MockPolicyCfg withPrimaryServer(final String hostPort) |
| | | { |
| | | primaryServers.add(hostPort); |
| | | return this; |
| | | } |
| | | |
| | | |
| | | |
| | | MockPolicyCfg withSecondaryServer(final String hostPort) |
| | | { |
| | | secondaryServers.add(hostPort); |
| | | return this; |
| | | } |
| | | |
| | | |
| | | |
| | | MockPolicyCfg withMappedSearchBindDN(final DN value) |
| | | { |
| | | this.mappedSearchBindDN = value; |
| | | return this; |
| | | } |
| | | |
| | | |
| | | |
| | | MockPolicyCfg withMappedSearchBindPassword(final String value) |
| | | { |
| | | this.mappedSearchBindPassword = value; |
| | | return this; |
| | | } |
| | | |
| | | |
| | | |
| | | MockPolicyCfg withMappedSearchBindPasswordEnvironmentVariable(final String value) |
| | | { |
| | | this.mappedSearchBindPasswordEnvVar = value; |
| | | return this; |
| | | } |
| | | |
| | | |
| | | |
| | | MockPolicyCfg withMappedSearchBindPasswordFile(final String value) |
| | | { |
| | | this.mappedSearchBindPasswordFile = value; |
| | | return this; |
| | | } |
| | | |
| | | |
| | | |
| | | MockPolicyCfg withMappedSearchBindPasswordProperty(final String value) |
| | | { |
| | | this.mappedSearchBindPasswordProperty = value; |
| | | return this; |
| | | } |
| | | |
| | | |
| | | |
| | | MockPolicyCfg withUsePasswordCaching(final boolean usePasswordCaching) |
| | | { |
| | | this.usePasswordCaching = usePasswordCaching; |
| | | return this; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getMappedSearchBindPasswordEnvironmentVariable() |
| | | { |
| | | return mappedSearchBindPasswordEnvVar; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getMappedSearchBindPasswordFile() |
| | | { |
| | | return mappedSearchBindPasswordFile; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getMappedSearchBindPasswordProperty() |
| | | { |
| | | return mappedSearchBindPasswordProperty; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public long getCachedPasswordTTL() |
| | | { |
| | | return 86400; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getCachedPasswordStorageScheme() |
| | | { |
| | |
| | | return DN.valueOf("cn=Salted SHA-1,cn=Password Storage Schemes,cn=config"); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isUsePasswordCaching() |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | static final class MockProvider implements |
| | | LDAPPassThroughAuthenticationPolicyFactory.Provider |
| | | { |
| | | |
| | | private final class MockScheduledFuture implements ScheduledFuture<Void> |
| | | { |
| | | private final Runnable runnable; |
| | | |
| | | |
| | | |
| | | MockScheduledFuture(final Runnable runnable) |
| | | { |
| | | this.runnable = runnable; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public boolean cancel(final boolean mayInterruptIfRunning) |
| | | { |
| | |
| | | return true; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public int compareTo(final Delayed o) |
| | | { |
| | | return 0; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public Void get() throws InterruptedException, ExecutionException |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public Void get(final long timeout, final TimeUnit unit) |
| | | throws InterruptedException, ExecutionException, TimeoutException |
| | |
| | | return null; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public long getDelay(final TimeUnit unit) |
| | | { |
| | | return 0; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public boolean isCancelled() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public boolean isDone() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | |
| | | |
| | | Runnable getRunnable() |
| | | { |
| | | return runnable; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | private final Queue<Event<?>> expectedEvents = new LinkedList<>(); |
| | | private final List<MockScheduledFuture> monitorRunnables = new LinkedList<>(); |
| | | private String currentTime = TimeThread.getGMTTime(); |
| | |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public void execute(final Runnable command) |
| | | { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public <T> List<Future<T>> invokeAll( |
| | | final Collection<? extends Callable<T>> tasks) |
| | |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public <T> List<Future<T>> invokeAll( |
| | | final Collection<? extends Callable<T>> tasks, final long timeout, |
| | |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public <T> T invokeAny(final Collection<? extends Callable<T>> tasks) |
| | | throws InterruptedException, ExecutionException |
| | |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public <T> T invokeAny(final Collection<? extends Callable<T>> tasks, |
| | | final long timeout, final TimeUnit unit) throws InterruptedException, |
| | |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public boolean isShutdown() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public boolean isTerminated() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public <V> ScheduledFuture<V> schedule(final Callable<V> callable, |
| | | final long delay, final TimeUnit unit) |
| | |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public ScheduledFuture<?> schedule(final Runnable command, |
| | | final long delay, final TimeUnit unit) |
| | |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public ScheduledFuture<?> scheduleAtFixedRate(final Runnable command, |
| | | final long initialDelay, final long period, final TimeUnit unit) |
| | |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public ScheduledFuture<?> scheduleWithFixedDelay(final Runnable command, |
| | | final long initialDelay, final long delay, final TimeUnit unit) |
| | |
| | | return future; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public void shutdown() |
| | | { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public List<Runnable> shutdownNow() |
| | | { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public <T> Future<T> submit(final Callable<T> task) |
| | | { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public Future<?> submit(final Runnable task) |
| | | { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public <T> Future<T> submit(final Runnable task, final T result) |
| | | { |
| | |
| | | } |
| | | }; |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConnectionFactory getLDAPConnectionFactory(final String host, |
| | | final int port, final LDAPPassThroughAuthenticationPolicyCfg options) |
| | |
| | | return new MockFactory(this, event); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ScheduledExecutorService getScheduledExecutorService() |
| | | { |
| | | return mockScheduler; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getCurrentTime() |
| | | { |
| | | return currentTime; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public long getCurrentTimeMS() |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | void assertAllExpectedEventsReceived() |
| | | { |
| | | assertTrue(expectedEvents.isEmpty()); |
| | | } |
| | | |
| | | |
| | | |
| | | @SuppressWarnings("unchecked") |
| | | <T> T assertExpectedEventWasReceived(final Event<T> actualEvent) |
| | | { |
| | | final Event<?> expectedEvent = expectedEvents.poll(); |
| | | if (expectedEvent == null) |
| | | { |
| | | fail("Unexpected event: " + actualEvent); |
| | | } |
| | | else |
| | | { |
| | | assertEquals(actualEvent, expectedEvent); |
| | | } |
| | | assertNotNull(expectedEvent, "Unexpected event: " + actualEvent); |
| | | assertEquals(actualEvent, expectedEvent); |
| | | return ((Event<T>) expectedEvent).getResult(); |
| | | } |
| | | |
| | | |
| | | |
| | | MockProvider expectEvent(final Event<?> expectedEvent) |
| | | { |
| | | expectedEvents.add(expectedEvent); |
| | | return this; |
| | | } |
| | | |
| | | |
| | | |
| | | MockProvider withCurrentTime(final String currentTime) |
| | | { |
| | | this.currentTime = currentTime; |
| | | return this; |
| | | } |
| | | |
| | | |
| | | |
| | | void runMonitorTasks() |
| | | { |
| | | for (final MockScheduledFuture task : monitorRunnables) |
| | |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | final class MockServer |
| | | { |
| | | /** Waits for an incoming client connection. */ |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | abstract class Action |
| | | { |
| | | abstract void run() throws Exception; |
| | | } |
| | | |
| | | |
| | | |
| | | /** Blocks the server until it is released. */ |
| | | class BlockAction extends Action |
| | | { |
| | | private final CountDownLatch latch = new CountDownLatch(1); |
| | | |
| | | |
| | | |
| | | void release() |
| | | { |
| | | latch.countDown(); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | void run() throws Exception |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** Close the client socket. */ |
| | | class CloseAction extends Action |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** Read the next message and check it matches the expected message. */ |
| | | class ReceiveAction extends Action |
| | | { |
| | | private final int messageID; |
| | | private final ProtocolOp expectedOp; |
| | | |
| | | |
| | | |
| | | ReceiveAction(final int messageID, final ProtocolOp expectedOp) |
| | | { |
| | | this.messageID = messageID; |
| | | this.expectedOp = expectedOp; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | void run() throws Exception |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** Sends a message. */ |
| | | class SendAction extends Action |
| | | { |
| | | private final int messageID; |
| | | private final ProtocolOp op; |
| | | |
| | | |
| | | |
| | | SendAction(final int messageID, final ProtocolOp op) |
| | | { |
| | | this.messageID = messageID; |
| | | this.op = op; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | void run() throws Exception |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | private final ServerSocket serverSocket; |
| | | private final List<Action> actions = new LinkedList<>(); |
| | | private Socket socket; |
| | |
| | | private final CountDownLatch stopLatch = new CountDownLatch(1); |
| | | private final Queue<BlockAction> blockers = new LinkedList<>(); |
| | | |
| | | |
| | | |
| | | MockServer(final ServerSocket serverSocket) |
| | | { |
| | | this.serverSocket = serverSocket; |
| | | } |
| | | |
| | | |
| | | |
| | | void assertNoExceptions() throws Exception |
| | | { |
| | | if (e != null) |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | int getPort() |
| | | { |
| | | return serverSocket.getLocalPort(); |
| | | } |
| | | |
| | | |
| | | |
| | | MockServer start() |
| | | { |
| | | serverThread = new Thread(new Runnable() |
| | | { |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void run() |
| | | { |
| | |
| | | return this; |
| | | } |
| | | |
| | | |
| | | |
| | | void stop() throws Exception |
| | | { |
| | | stopLatch.await(10, TimeUnit.SECONDS); |
| | |
| | | assertNoExceptions(); |
| | | } |
| | | |
| | | |
| | | |
| | | MockServer thenAccept() |
| | | { |
| | | actions.add(new AcceptAction()); |
| | | return this; |
| | | } |
| | | |
| | | |
| | | |
| | | MockServer thenBlock() |
| | | { |
| | | final BlockAction action = new BlockAction(); |
| | |
| | | return this; |
| | | } |
| | | |
| | | |
| | | |
| | | MockServer thenClose() |
| | | { |
| | | actions.add(new CloseAction()); |
| | | return this; |
| | | } |
| | | |
| | | |
| | | |
| | | MockServer thenReceive(final int messageID, final ProtocolOp op) |
| | | { |
| | | actions.add(new ReceiveAction(messageID, op)); |
| | | return this; |
| | | } |
| | | |
| | | |
| | | |
| | | MockServer thenSend(final int messageID, final ProtocolOp op) |
| | | { |
| | | actions.add(new SendAction(messageID, op)); |
| | | return this; |
| | | } |
| | | |
| | | |
| | | |
| | | void unblock() throws Exception |
| | | { |
| | | final BlockAction action = blockers.poll(); |
| | |
| | | action.release(); |
| | | } |
| | | |
| | | |
| | | |
| | | private Socket accept() throws IOException |
| | | { |
| | | socket = serverSocket.accept(); |
| | | return socket; |
| | | } |
| | | |
| | | |
| | | |
| | | private Socket getSocket() |
| | | { |
| | | return socket; |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | static class SearchEvent extends Event<Object> |
| | | { |
| | | private final String baseDN; |
| | |
| | | private final SearchScope scope; |
| | | private final String username; |
| | | |
| | | |
| | | |
| | | SearchEvent(final GetConnectionEvent cevent, final String baseDN, |
| | | final SearchScope scope, final String filter) |
| | | { |
| | | this(cevent, baseDN, scope, filter, null, ResultCode.SUCCESS); |
| | | } |
| | | |
| | | |
| | | |
| | | SearchEvent(final GetConnectionEvent cevent, final String baseDN, |
| | | final SearchScope scope, final String filter, |
| | | final ResultCode resultCode) |
| | |
| | | this(cevent, baseDN, scope, filter, null, resultCode); |
| | | } |
| | | |
| | | |
| | | |
| | | SearchEvent(final GetConnectionEvent cevent, final String baseDN, |
| | | final SearchScope scope, final String filter, final String username) |
| | | { |
| | | this(cevent, baseDN, scope, filter, username, ResultCode.SUCCESS); |
| | | } |
| | | |
| | | |
| | | |
| | | private SearchEvent(final GetConnectionEvent cevent, final String baseDN, |
| | | final SearchScope scope, final String filter, final String username, |
| | | final ResultCode resultCode) |
| | |
| | | this.resultCode = resultCode; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | Object getResult() |
| | | { |
| | |
| | | : new DirectoryException(resultCode, resultCode.getName()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | boolean matchesEvent(final Event<?> event) |
| | | { |
| | |
| | | return false; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | StringBuilder toString(final StringBuilder builder) |
| | | { |
| | |
| | | builder.append(')'); |
| | | return builder; |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | static class SimpleBindEvent extends Event<DirectoryException> |
| | | { |
| | | private final GetConnectionEvent cevent; |
| | |
| | | private final ResultCode resultCode; |
| | | private final String username; |
| | | |
| | | |
| | | |
| | | SimpleBindEvent(final GetConnectionEvent cevent, final String username, |
| | | final String password) |
| | | { |
| | | this(cevent, username, password, ResultCode.SUCCESS); |
| | | } |
| | | |
| | | |
| | | |
| | | SimpleBindEvent(final GetConnectionEvent cevent, final String username, |
| | | final String password, final ResultCode resultCode) |
| | | { |
| | |
| | | this.resultCode = resultCode; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | DirectoryException getResult() |
| | | { |
| | |
| | | return null; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | boolean matchesEvent(final Event<?> event) |
| | | { |
| | |
| | | return false; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | StringBuilder toString(final StringBuilder builder) |
| | | { |
| | |
| | | builder.append(')'); |
| | | return builder; |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | private final String phost1 = "phost1:11"; |
| | | private final String phost2 = "phost2:22"; |
| | | private final String phost3 = "phost3:33"; |
| | |
| | | private Entry userEntry; |
| | | private final String userPassword = "password"; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Ensures that the Directory Server is running and creates a test backend |
| | | * containing a single test user. |
| | |
| | | ); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests that failures during the search are handled properly. |
| | | * <p> |
| | |
| | | * @throws Exception |
| | | * If an unexpected exception occurred. |
| | | */ |
| | | @Test(enabled = true, dataProvider = "testConnectionFailureDuringSearchData") |
| | | @Test(dataProvider = "testConnectionFailureDuringSearchData") |
| | | public void testConnectionFailureDuringSearch( |
| | | final ResultCode searchResultCode) throws Exception |
| | | { |
| | |
| | | provider.assertAllExpectedEventsReceived(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests that failures to authenticate a search connection are handled |
| | | * properly. |
| | |
| | | * @throws Exception |
| | | * If an unexpected exception occurred. |
| | | */ |
| | | @Test(enabled = true, dataProvider = "testConnectionFailureDuringSearchBindData") |
| | | @Test(dataProvider = "testConnectionFailureDuringSearchBindData") |
| | | public void testConnectionFailureDuringSearchBind( |
| | | final ResultCode bindResultCode) throws Exception |
| | | { |
| | |
| | | policy.finalizeAuthenticationPolicy(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns test data for {@link #testConnectionFailureDuringSearchBind}. |
| | | * |
| | |
| | | // @formatter:on |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns test data for {@link #testConnectionFailureDuringSearch}. |
| | | * |
| | |
| | | // @formatter:on |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests that failures to obtain a search connection are handled properly. |
| | | * |
| | |
| | | * @throws Exception |
| | | * If an unexpected exception occurred. |
| | | */ |
| | | @Test(enabled = true, dataProvider = "testConnectionFailureDuringSearchGetConnectionData") |
| | | @Test(dataProvider = "testConnectionFailureDuringSearchGetConnectionData") |
| | | public void testConnectionFailureDuringSearchGetConnection( |
| | | final ResultCode connectResultCode) throws Exception |
| | | { |
| | |
| | | policy.finalizeAuthenticationPolicy(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns test data for |
| | | * {@link #testConnectionFailureDuringSearchGetConnection}. |
| | |
| | | // @formatter:on |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests fail-over between 2 primary servers then to the secondary data |
| | | * center. |
| | |
| | | * @throws Exception |
| | | * If an unexpected exception occurred. |
| | | */ |
| | | @Test(enabled = true) |
| | | @Test |
| | | public void testFailOverOnConnect() throws Exception |
| | | { |
| | | // Mock configuration. |
| | |
| | | provider.assertAllExpectedEventsReceived(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests that searches which fail in one LB pool are automatically retried in |
| | | * the secondary LB pool. |
| | |
| | | * @throws Exception |
| | | * If an unexpected exception occurred. |
| | | */ |
| | | @Test(enabled = true) |
| | | @Test |
| | | public void testFBRetrySearchOnFailure() throws Exception |
| | | { |
| | | // Mock configuration. |
| | |
| | | provider.assertAllExpectedEventsReceived(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests configuration validation. |
| | | * |
| | |
| | | * @throws Exception |
| | | * If an unexpected exception occurred. |
| | | */ |
| | | @Test(enabled = true, dataProvider = "testIsConfigurationAcceptableData") |
| | | @Test(dataProvider = "testIsConfigurationAcceptableData") |
| | | public void testIsConfigurationAcceptable( |
| | | final LDAPPassThroughAuthenticationPolicyCfg cfg, final boolean isValid) |
| | | throws Exception |
| | |
| | | isValid); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns test data for {@link #testIsConfigurationAcceptable}. |
| | | * |
| | |
| | | // @formatter:on |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests that searches which fail on one server are automatically retried on |
| | | * another within the same LB. |
| | |
| | | * @throws Exception |
| | | * If an unexpected exception occurred. |
| | | */ |
| | | @Test(enabled = true) |
| | | @Test |
| | | public void testLBRetrySearchOnFailure() throws Exception |
| | | { |
| | | // Mock configuration. |
| | |
| | | provider.assertAllExpectedEventsReceived(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests valid bind which times out at the client. These should trigger a |
| | | * CLIENT_SIDE_TIMEOUT result code. |
| | |
| | | * @throws Exception |
| | | * If an unexpected exception occurred. |
| | | */ |
| | | @Test(enabled = true) |
| | | @Test |
| | | public void testLDAPConnectionFactoryBindClientTimeout() throws Exception |
| | | { |
| | | // Mock configuration. |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests valid bind which never receives a response because the server |
| | | * abruptly closes the connection. |
| | |
| | | * @throws Exception |
| | | * If an unexpected exception occurred. |
| | | */ |
| | | @Test(enabled = true) |
| | | @Test |
| | | public void testLDAPConnectionFactoryBindConnectionClosed() throws Exception |
| | | { |
| | | // Mock configuration. |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests bind which receives a disconnect notification. The error result code |
| | | * should be passed back to the called. |
| | |
| | | * @throws Exception |
| | | * If an unexpected exception occurred. |
| | | */ |
| | | @Test(enabled = true) |
| | | @Test |
| | | public void testLDAPConnectionFactoryBindDisconnectNotification() |
| | | throws Exception |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests bind with invalid credentials which should return a |
| | | * INVALID_CREDENTIALS result code. |
| | |
| | | * @throws Exception |
| | | * If an unexpected exception occurred. |
| | | */ |
| | | @Test(enabled = true) |
| | | @Test |
| | | public void testLDAPConnectionFactoryBindInvalidCredentials() |
| | | throws Exception |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests bind which returns an error result. The error result code should be |
| | | * passed back to the caller. |
| | |
| | | * @throws Exception |
| | | * If an unexpected exception occurred. |
| | | */ |
| | | @Test(enabled = true) |
| | | @Test |
| | | public void testLDAPConnectionFactoryBindOtherError() throws Exception |
| | | { |
| | | // Mock configuration. |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests valid bind returning success. |
| | | * |
| | | * @throws Exception |
| | | * If an unexpected exception occurred. |
| | | */ |
| | | @Test(enabled = true) |
| | | @Test |
| | | public void testLDAPConnectionFactoryBindSuccess() throws Exception |
| | | { |
| | | // Mock configuration. |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests successful connect/unbind. |
| | | * |
| | | * @throws Exception |
| | | * If an unexpected exception occurred. |
| | | */ |
| | | @Test(enabled = true) |
| | | @Test |
| | | public void testLDAPConnectionFactoryConnectAndUnbind() throws Exception |
| | | { |
| | | // Mock configuration. |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests that invalid ports are handled properly. These should trigger a |
| | | * CLIENT_SIDE_CONNECT_ERROR result code. |
| | |
| | | * @throws Exception |
| | | * If an unexpected exception occurred. |
| | | */ |
| | | @Test(enabled = true) |
| | | @Test |
| | | public void testLDAPConnectionFactoryConnectPortNotInUse() throws Exception |
| | | { |
| | | final int port = TestCaseUtils.findFreePort(); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests that unknown hosts are handled properly. These should trigger a |
| | | * CLIENT_SIDE_CONNECT_ERROR result code. |
| | |
| | | * @throws Exception |
| | | * If an unexpected exception occurred. |
| | | */ |
| | | @Test(enabled = true) |
| | | @Test |
| | | public void testLDAPConnectionFactoryConnectUnknownHost() throws Exception |
| | | { |
| | | // Mock configuration. |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests valid search which times out at the client. These should trigger a |
| | | * CLIENT_SIDE_TIMEOUT result code. |
| | |
| | | * @throws Exception |
| | | * If an unexpected exception occurred. |
| | | */ |
| | | @Test(enabled = true) |
| | | @Test |
| | | public void testLDAPConnectionFactorySearchClientTimeout() throws Exception |
| | | { |
| | | // Mock configuration. |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests valid search which never receives a response because the server |
| | | * abruptly closes the connection. |
| | |
| | | * @throws Exception |
| | | * If an unexpected exception occurred. |
| | | */ |
| | | @Test(enabled = true) |
| | | @Test |
| | | public void testLDAPConnectionFactorySearchConnectionClosed() |
| | | throws Exception |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests valid search which receives a disconnect notification. The error |
| | | * result code should be passed back to the called. |
| | |
| | | * @throws Exception |
| | | * If an unexpected exception occurred. |
| | | */ |
| | | @Test(enabled = true) |
| | | @Test |
| | | public void testLDAPConnectionFactorySearchDisconnectNotification() |
| | | throws Exception |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests valid search returning no results are handled properly. These should |
| | | * trigger a CLIENT_SIDE_NO_RESULTS_RETURNED result code. |
| | |
| | | * @throws Exception |
| | | * If an unexpected exception occurred. |
| | | */ |
| | | @Test(enabled = true) |
| | | @Test |
| | | public void testLDAPConnectionFactorySearchNoResults() throws Exception |
| | | { |
| | | // Mock configuration. |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests search returning no entries and an error result. The error result |
| | | * code should be passed back to the caller. |
| | |
| | | * @throws Exception |
| | | * If an unexpected exception occurred. |
| | | */ |
| | | @Test(enabled = true) |
| | | @Test |
| | | public void testLDAPConnectionFactorySearchOtherError() throws Exception |
| | | { |
| | | // Mock configuration. |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests valid search returning a single entry followed by a size limit |
| | | * exceeded error are handled properly. These should trigger a |
| | |
| | | * @throws Exception |
| | | * If an unexpected exception occurred. |
| | | */ |
| | | @Test(enabled = true) |
| | | @Test |
| | | public void testLDAPConnectionFactorySearchSizeLimit() throws Exception |
| | | { |
| | | // Mock configuration. |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests valid search returning a single entry works properly. |
| | | * |
| | | * @throws Exception |
| | | * If an unexpected exception occurred. |
| | | */ |
| | | @Test(enabled = true) |
| | | @Test |
| | | public void testLDAPConnectionFactorySearchSuccess() throws Exception |
| | | { |
| | | // Mock configuration. |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests valid search returning a single entry followed by a time limit |
| | | * exceeded error are handled properly. These should trigger a |
| | |
| | | * @throws Exception |
| | | * If an unexpected exception occurred. |
| | | */ |
| | | @Test(enabled = true) |
| | | @Test |
| | | public void testLDAPConnectionFactorySearchTimeLimit() throws Exception |
| | | { |
| | | // Mock configuration. |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests valid search returning many results are handled properly. These |
| | | * should trigger a CLIENT_SIDE_MORE_RESULTS_TO_RETURN result code. |
| | |
| | | * @throws Exception |
| | | * If an unexpected exception occurred. |
| | | */ |
| | | @Test(enabled = true) |
| | | @Test |
| | | public void testLDAPConnectionFactorySearchTooManyResults() throws Exception |
| | | { |
| | | // Mock configuration. |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests load balancing across 3 servers. |
| | | * |
| | | * @throws Exception |
| | | * If an unexpected exception occurred. |
| | | */ |
| | | @Test(enabled = true) |
| | | @Test |
| | | public void testLoadBalancing() throws Exception |
| | | { |
| | | // Mock configuration. |
| | |
| | | provider.assertAllExpectedEventsReceived(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the different mapping policies: connection attempts will succeed, as |
| | | * will any searches, but the final user bind may or may not succeed depending |
| | |
| | | * @throws Exception |
| | | * If an unexpected exception occurred. |
| | | */ |
| | | @Test(enabled = true, dataProvider = "testMappingPolicyAuthenticationData") |
| | | @Test(dataProvider = "testMappingPolicyAuthenticationData") |
| | | public void testMappingPolicyAuthentication( |
| | | final MappingPolicy mappingPolicy, final ResultCode bindResultCode) |
| | | throws Exception |
| | |
| | | provider.assertAllExpectedEventsReceived(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns test data for {@link #testMappingPolicyAuthentication}. |
| | | * |
| | |
| | | // @formatter:on |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests that mapped PTA fails when no match attribute values are found. |
| | | * |
| | | * @throws Exception |
| | | * If an unexpected exception occurred. |
| | | */ |
| | | @Test(enabled = true) |
| | | @Test |
| | | public void testMissingMappingAttributes() throws Exception |
| | | { |
| | | // Mock configuration. |
| | |
| | | provider.assertAllExpectedEventsReceived(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests that mapped PTA uses an appropriate filter when multiple match |
| | | * attributes are defined. |
| | |
| | | * @throws Exception |
| | | * If an unexpected exception occurred. |
| | | */ |
| | | @Test(enabled = true) |
| | | @Test |
| | | public void testMultipleMappingAttributes() throws Exception |
| | | { |
| | | // Mock configuration. |
| | |
| | | provider.assertAllExpectedEventsReceived(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests that mapped PTA uses an appropriate filter when multiple match |
| | | * attribute values are found. |
| | |
| | | * @throws Exception |
| | | * If an unexpected exception occurred. |
| | | */ |
| | | @Test(enabled = true) |
| | | @Test |
| | | public void testMultipleMappingAttributeValues() throws Exception |
| | | { |
| | | // Mock configuration. |
| | |
| | | provider.assertAllExpectedEventsReceived(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests that mapped PTA performs searches across multiple base DNs if |
| | | * configured. |
| | |
| | | * @throws Exception |
| | | * If an unexpected exception occurred. |
| | | */ |
| | | @Test(enabled = true) |
| | | @Test |
| | | public void testMultipleSearchBaseDNs() throws Exception |
| | | { |
| | | // Mock configuration. |
| | |
| | | provider.assertAllExpectedEventsReceived(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Test for issue OPENDJ-292 |
| | | * (https://bugster.forgerock.org/jira/browse/OPENDJ-292). This test checks |
| | |
| | | * @throws Exception |
| | | * If an unexpected exception occurred. |
| | | */ |
| | | @Test(enabled = true) |
| | | @Test |
| | | public void testIssueOPENDJ292_1() throws Exception |
| | | { |
| | | // Mock configuration. |
| | |
| | | provider.assertAllExpectedEventsReceived(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Test for issue OPENDJ-292 |
| | | * (https://bugster.forgerock.org/jira/browse/OPENDJ-292). This test checks |
| | |
| | | * @throws Exception |
| | | * If an unexpected exception occurred. |
| | | */ |
| | | @Test(enabled = true) |
| | | @Test |
| | | public void testIssueOPENDJ292_2() throws Exception |
| | | { |
| | | // Mock configuration. |
| | |
| | | provider.assertAllExpectedEventsReceived(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Test for issue OPENDJ-294 |
| | | * (https://bugster.forgerock.org/jira/browse/OPENDJ-294). Password |
| | |
| | | * If an unexpected exception occurred. |
| | | */ |
| | | @SuppressWarnings("unchecked") |
| | | @Test(enabled = true) |
| | | @Test |
| | | public void testIssueOPENDJ294() throws Exception |
| | | { |
| | | // Mock configurations. |
| | |
| | | provider.assertAllExpectedEventsReceived(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Test for issue OPENDJ-290 |
| | | * (https://bugster.forgerock.org/jira/browse/OPENDJ-290). |
| | |
| | | * @throws Exception |
| | | * If an unexpected exception occurred. |
| | | */ |
| | | @Test(enabled = true) |
| | | @Test |
| | | public void testIssueOPENDJ290() throws Exception |
| | | { |
| | | // Mock configuration. |
| | |
| | | provider.assertAllExpectedEventsReceived(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns test data for {@link #testPasswordCaching}. |
| | | * |
| | |
| | | // @formatter:on |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests password caching functionality. |
| | | * |
| | |
| | | * @throws Exception |
| | | * If an unexpected exception occurred. |
| | | */ |
| | | @Test(enabled = true, dataProvider = "testPasswordCachingData") |
| | | @Test(dataProvider = "testPasswordCachingData") |
| | | public void testPasswordCaching(String cacheState, boolean matchesCache, |
| | | boolean matchesReal) throws Exception |
| | | { |
| | |
| | | provider.assertAllExpectedEventsReceived(); |
| | | } |
| | | |
| | | |
| | | |
| | | MockPolicyCfg mockCfg() |
| | | { |
| | | return new MockPolicyCfg(); |
| | | } |
| | | |
| | | |
| | | |
| | | MockServer mockServer() throws IOException |
| | | { |
| | | final ServerSocket serverSocket = TestCaseUtils.bindFreePort(); |
| | | return new MockServer(serverSocket); |
| | | } |
| | | |
| | | |
| | | |
| | | BindRequestProtocolOp newBindRequest(final String dn, final String password) |
| | | throws LDAPException |
| | | { |
| | |
| | | ByteString.valueOfUtf8(password)); |
| | | } |
| | | |
| | | |
| | | |
| | | BindResponseProtocolOp newBindResult(final ResultCode resultCode) |
| | | { |
| | | return new BindResponseProtocolOp(resultCode.intValue()); |
| | | } |
| | | |
| | | |
| | | |
| | | ExtendedResponseProtocolOp newDisconnectNotification( |
| | | final ResultCode resultCode) |
| | | { |
| | |
| | | null, OID_NOTICE_OF_DISCONNECTION, null); |
| | | } |
| | | |
| | | |
| | | |
| | | SearchResultEntryProtocolOp newSearchEntry(final String dn) |
| | | throws DirectoryException |
| | | { |
| | | return new SearchResultEntryProtocolOp(DN.valueOf(dn)); |
| | | } |
| | | |
| | | |
| | | |
| | | SearchRequestProtocolOp newSearchRequest(final String dn, |
| | | final String filter, final LDAPPassThroughAuthenticationPolicyCfg cfg) |
| | | throws LDAPException |
| | |
| | | LDAPPassThroughAuthenticationPolicyFactory.NO_ATTRIBUTES); |
| | | } |
| | | |
| | | |
| | | |
| | | SearchResultDoneProtocolOp newSearchResult(final ResultCode resultCode) |
| | | { |
| | | return new SearchResultDoneProtocolOp(resultCode.intValue()); |