| | |
| | | */ |
| | | package org.opends.server.crypto; |
| | | |
| | | import java.io.InputStream; |
| | | import java.io.IOException; |
| | | import java.io.OutputStream; |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.io.OutputStream; |
| | | import java.io.PrintStream; |
| | | import java.security.*; |
| | | import java.security.cert.Certificate; |
| | |
| | | final Entry entry = new Entry(entryDN, null, null, null); |
| | | entry.addObjectClass(DirectoryServer.getTopObjectClass()); |
| | | entry.addObjectClass(ocCertRequest); |
| | | AddOperation addOperation = icc.processAdd(entry.getName(), |
| | | entry.getObjectClasses(), |
| | | entry.getUserAttributes(), |
| | | entry.getOperationalAttributes()); |
| | | AddOperation addOperation = icc.processAdd(entry); |
| | | if (ResultCode.SUCCESS != addOperation.getResultCode()) { |
| | | throw new DirectoryException( |
| | | addOperation.getResultCode(), |
| | |
| | | final Attribute certificateAttr = builder.toAttribute(); |
| | | entry.addAttribute(certificateAttr, new ArrayList<ByteString>(0)); |
| | | |
| | | AddOperation addOperation = icc.processAdd(entry.getName(), |
| | | entry.getObjectClasses(), |
| | | entry.getUserAttributes(), |
| | | entry.getOperationalAttributes()); |
| | | AddOperation addOperation = icc.processAdd(entry); |
| | | if (ResultCode.SUCCESS != addOperation.getResultCode()) { |
| | | throw new DirectoryException( |
| | | addOperation.getResultCode(), |
| | |
| | | import org.opends.server.tools.LDAPModify; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.FilePermission; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.LDIFImportConfig; |
| | | import org.opends.server.types.Schema; |
| | | import org.opends.server.util.BuildVersion; |
| | | import org.opends.server.util.EmbeddedUtils; |
| | | import org.opends.server.util.LDIFReader; |
| | | |
| | | import com.forgerock.opendj.util.OperatingSystem; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import static org.testng.Assert.*; |
| | | import com.forgerock.opendj.util.OperatingSystem; |
| | | |
| | | /** |
| | | * This class defines some utility functions which can be used by test cases. |
| | |
| | | ConfigurationFramework.getInstance() |
| | | .initialize(testInstallRoot.getAbsolutePath(), |
| | | testInstanceRoot.getAbsolutePath()); |
| | | |
| | | |
| | | AccessLogger.getInstance().addLogPublisher( |
| | | (AccessLogPublisher) TextAccessLogPublisher |
| | | .getStartupTextAccessPublisher(ACCESS_TEXT_WRITER, false)); |
| | |
| | | |
| | | public static <T> Set<T> newSet(T... elems) |
| | | { |
| | | return new HashSet<T>(Arrays.asList(elems)); |
| | | return newHashSet(elems); |
| | | } |
| | | |
| | | public static <T> SortedSet<T> newSortedSet(T... elems) |
| | | { |
| | | return new TreeSet<T>(Arrays.asList(elems)); |
| | | return newTreeSet(elems); |
| | | } |
| | | |
| | | public static <T> List<T> newList(T... elems) |
| | | { |
| | | return new ArrayList<T>(Arrays.asList(elems)); |
| | | return newArrayList(elems); |
| | | } |
| | | |
| | | public static HashSet<PluginType> getPluginTypes(Entry e) |
| | |
| | | */ |
| | | package org.opends.server.admin.server; |
| | | |
| | | |
| | | |
| | | import java.util.List; |
| | | |
| | | import javax.naming.OperationNotSupportedException; |
| | | import javax.naming.ldap.LdapName; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.admin.AdminTestCase; |
| | | import org.opends.server.admin.TestCfg; |
| | |
| | | import org.opends.server.admin.TestParentCfg; |
| | | import org.opends.server.admin.client.ldap.JNDIDirContextAdaptor; |
| | | import org.opends.server.admin.std.server.RootCfg; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.types.ConfigChangeResult; |
| | | import org.opends.server.types.Entry; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.testng.Assert; |
| | | import org.testng.annotations.AfterClass; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * Test cases for constraints on the server-side. |
| | | */ |
| | | public final class ConstraintTest extends AdminTestCase { |
| | | |
| | | // Child DN. |
| | | /** Child DN. */ |
| | | private static final String TEST_CHILD_1_DN = "cn=test child 1,cn=test children,cn=test parent 1,cn=test parents,cn=config"; |
| | | |
| | | |
| | |
| | | private static class AddListener implements |
| | | ConfigurationAddListener<TestChildCfg> { |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationAdd(TestChildCfg configuration) { |
| | | return new ConfigChangeResult(ResultCode.SUCCESS, false); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isConfigurationAddAcceptable(TestChildCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) { |
| | | return true; |
| | |
| | | private static class DeleteListener implements |
| | | ConfigurationDeleteListener<TestChildCfg> { |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationDelete( |
| | | TestChildCfg configuration) { |
| | | return new ConfigChangeResult(ResultCode.SUCCESS, false); |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isConfigurationDeleteAcceptable(TestChildCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) { |
| | | return true; |
| | |
| | | private static class ChangeListener implements |
| | | ConfigurationChangeListener<TestChildCfg> { |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | TestChildCfg configuration) { |
| | | return new ConfigChangeResult(ResultCode.SUCCESS, false); |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable(TestChildCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) { |
| | | return true; |
| | |
| | | |
| | | } |
| | | |
| | | // Test child 1 LDIF. |
| | | /** Test child 1 LDIF. */ |
| | | private static final String[] TEST_CHILD_1 = new String[] { |
| | | "dn: cn=test child 1,cn=test children,cn=test parent 1,cn=test parents,cn=config", |
| | | "objectclass: top", |
| | |
| | | "ds-cfg-conflict-behavior: virtual-overrides-real" |
| | | }; |
| | | |
| | | // Test LDIF. |
| | | /** Test LDIF. */ |
| | | private static final String[] TEST_LDIF = new String[] { |
| | | // Base entries. |
| | | "dn: cn=test parents,cn=config", |
| | |
| | | "", |
| | | }; |
| | | |
| | | // JNDI LDAP context. |
| | | private JNDIDirContextAdaptor adaptor = null; |
| | | /** JNDI LDAP context. */ |
| | | private JNDIDirContextAdaptor adaptor; |
| | | |
| | | |
| | | |
| | |
| | | parent.getTestChild("test child 1"); |
| | | } finally { |
| | | TestCfg.removeConstraint(constraint); |
| | | |
| | | try { |
| | | deleteSubtree(TEST_CHILD_1_DN); |
| | | } catch (Exception e) { |
| | | // Do nothing. |
| | | } |
| | | deleteSubtreeNoException(TEST_CHILD_1_DN); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | } finally { |
| | | TestCfg.removeConstraint(constraint); |
| | | |
| | | try { |
| | | deleteSubtree(TEST_CHILD_1_DN); |
| | | } catch (Exception e) { |
| | | // Do nothing. |
| | | } |
| | | deleteSubtreeNoException(TEST_CHILD_1_DN); |
| | | } |
| | | } |
| | | |
| | |
| | | // Add the entry. |
| | | addEntry(ResultCode.SUCCESS, TEST_CHILD_1); |
| | | } finally { |
| | | try { |
| | | deleteSubtree(TEST_CHILD_1_DN); |
| | | } catch (Exception e) { |
| | | // Do nothing. |
| | | } |
| | | deleteSubtreeNoException(TEST_CHILD_1_DN); |
| | | } |
| | | } finally { |
| | | TestCfg.removeConstraint(constraint); |
| | |
| | | // Add the entry. |
| | | addEntry(ResultCode.UNWILLING_TO_PERFORM, TEST_CHILD_1); |
| | | } finally { |
| | | try { |
| | | deleteSubtree(TEST_CHILD_1_DN); |
| | | } catch (Exception e) { |
| | | // Do nothing. |
| | | } |
| | | deleteSubtreeNoException(TEST_CHILD_1_DN); |
| | | } |
| | | } finally { |
| | | TestCfg.removeConstraint(constraint); |
| | |
| | | } finally { |
| | | TestCfg.removeConstraint(constraint); |
| | | parent.removeTestChildDeleteListener(listener); |
| | | |
| | | try { |
| | | // Clean up. |
| | | deleteSubtree(TEST_CHILD_1_DN); |
| | | } catch (Exception e) { |
| | | // Ignore. |
| | | } |
| | | deleteSubtreeNoException(TEST_CHILD_1_DN); |
| | | } |
| | | } |
| | | |
| | |
| | | } finally { |
| | | TestCfg.removeConstraint(constraint); |
| | | parent.removeTestChildDeleteListener(listener); |
| | | |
| | | try { |
| | | // Clean up. |
| | | deleteSubtree(TEST_CHILD_1_DN); |
| | | } catch (Exception e) { |
| | | // Ignore. |
| | | } |
| | | deleteSubtreeNoException(TEST_CHILD_1_DN); |
| | | } |
| | | } |
| | | |
| | |
| | | Assert.assertEquals(result, ResultCode.SUCCESS.intValue()); |
| | | } finally { |
| | | TestCfg.removeConstraint(constraint); |
| | | try { |
| | | deleteSubtree(TEST_CHILD_1_DN); |
| | | } catch (Exception e) { |
| | | // Ignore. |
| | | } |
| | | deleteSubtreeNoException(TEST_CHILD_1_DN); |
| | | } |
| | | } |
| | | |
| | |
| | | Assert.assertEquals(result, ResultCode.UNWILLING_TO_PERFORM.intValue()); |
| | | } finally { |
| | | TestCfg.removeConstraint(constraint); |
| | | try { |
| | | deleteSubtree(TEST_CHILD_1_DN); |
| | | } catch (Exception e) { |
| | | // Ignore. |
| | | } |
| | | deleteSubtreeNoException(TEST_CHILD_1_DN); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | // Add an entry and check its result. |
| | | /** Add an entry and check its result. */ |
| | | private void addEntry(ResultCode expected, String... lines) throws Exception { |
| | | Entry entry = TestCaseUtils.makeEntry(lines); |
| | | |
| | | InternalClientConnection conn = InternalClientConnection |
| | | .getRootConnection(); |
| | | |
| | | AddOperation add = conn.processAdd(entry.getName(), entry.getObjectClasses(), |
| | | entry.getUserAttributes(), entry.getOperationalAttributes()); |
| | | |
| | | Assert.assertEquals(add.getResultCode(), expected, add.getErrorMessage() |
| | | .toString()); |
| | | AddOperation add = getRootConnection().processAdd(entry); |
| | | assertEquals(add.getResultCode(), expected, add.getErrorMessage().toString()); |
| | | } |
| | | |
| | | private void deleteSubtreeNoException(String dn) |
| | | { |
| | | try |
| | | { |
| | | deleteSubtree(dn); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | // Ignore. |
| | | } |
| | | } |
| | | |
| | | |
| | | // Deletes the named sub-tree. |
| | | /** Deletes the named sub-tree. */ |
| | | private void deleteSubtree(String dn) throws Exception { |
| | | getAdaptor().deleteSubtree(new LdapName(dn)); |
| | | } |
| | | |
| | | |
| | | |
| | | // Gets the JNDI connection for the test server instance. |
| | | /** Gets the JNDI connection for the test server instance. */ |
| | | private synchronized JNDIDirContextAdaptor getAdaptor() throws Exception { |
| | | if (adaptor == null) { |
| | | adaptor = JNDIDirContextAdaptor.simpleSSLBind("127.0.0.1", TestCaseUtils |
| | |
| | | return adaptor; |
| | | } |
| | | |
| | | |
| | | |
| | | // Gets the named parent configuration. |
| | | private TestParentCfg getParent(String name) throws IllegalArgumentException, |
| | | ConfigException { |
| | | /** Gets the named parent configuration. */ |
| | | private TestParentCfg getParent(String name) throws Exception { |
| | | ServerManagementContext ctx = ServerManagementContext.getInstance(); |
| | | ServerManagedObject<RootCfg> root = ctx.getRootConfigurationManagedObject(); |
| | | TestParentCfg parent = root.getChild( |
| | | return root.getChild( |
| | | TestCfg.getTestOneToManyParentRelationDefinition(), name) |
| | | .getConfiguration(); |
| | | return parent; |
| | | } |
| | | } |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.Set; |
| | | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | import org.testng.annotations.AfterClass; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.extensions.TestPasswordValidator; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.ldap.BindRequestProtocolOp; |
| | | import org.opends.server.protocols.ldap.BindResponseProtocolOp; |
| | | import org.opends.server.protocols.ldap.LDAPAttribute; |
| | |
| | | import org.opends.server.protocols.ldap.ModifyResponseProtocolOp; |
| | | import org.opends.server.tools.LDAPPasswordModify; |
| | | import org.opends.server.tools.LDAPWriter; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.Entry; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.opends.server.types.RawModification; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.testng.annotations.AfterClass; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | |
| | | |
| | | /** |
| | | * A set of generic test cases for password validators. |
| | | */ |
| | |
| | | "userPassword: password"); |
| | | |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "userPassword: password"); |
| | | |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "ds-privilege-name: bypass-acl", |
| | | "userPassword: password"); |
| | | |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "userPassword: password"); |
| | | |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "cn=Password Policies,cn=config"); |
| | | |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "cn=Password Policies,cn=config"); |
| | | |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "userPassword: password"); |
| | | |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "userPassword: password"); |
| | | |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "userPassword: password"); |
| | | |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "cn=Password Policies,cn=config"); |
| | | |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "cn=Password Policies,cn=config"); |
| | | |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.plugins.DelayPreOpPlugin; |
| | |
| | | import org.opends.server.tools.LDAPReader; |
| | | import org.opends.server.tools.LDAPWriter; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.util.StaticUtils; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | "objectClass: top", |
| | | "objectClass: device", |
| | | "cn: test"); |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "objectClass: top", |
| | | "objectClass: device", |
| | | "cn: test"); |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | Map<AttributeType,List<Attribute>> userAttrs = entry.getUserAttributes(); |
| | | userAttrs.put(attrType, newArrayList(Attributes.empty(attrType))); |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | |
| | | AddOperation addOperation = |
| | | conn.processAdd(entry.getName(), entry.getObjectClasses(), userAttrs, |
| | | entry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(entry); |
| | | assertFalse(addOperation.getResultCode() == ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | | |
| | | |
| | | import java.util.ArrayList; |
| | | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.Modification; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.types.SearchFilter; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.testng.Assert.*; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * A set of generic test cases that cover adding, modifying, and removing |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @BeforeClass() |
| | | public void startServer() |
| | | throws Exception |
| | | @BeforeClass |
| | | public void startServer() throws Exception |
| | | { |
| | | TestCaseUtils.startServer(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests that the server will reject an attempt to register a base DN that is |
| | | * already defined in the server. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testRegisterBaseThatAlreadyExists() |
| | | throws Exception |
| | | @Test |
| | | public void testRegisterBaseThatAlreadyExists() throws Exception |
| | | { |
| | | TestCaseUtils.initializeTestBackend(false); |
| | | |
| | |
| | | String backendID = createBackendID(baseDN); |
| | | Entry backendEntry = createBackendEntry(backendID, false, baseDN); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(backendEntry.getName(), backendEntry.getObjectClasses(), |
| | | backendEntry.getUserAttributes(), |
| | | backendEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(backendEntry); |
| | | assertFalse(addOperation.getResultCode() == ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test(expectedExceptions = { DirectoryException.class }) |
| | | public void testDeregisterNonExistentBaseDN() |
| | | throws Exception |
| | | public void testDeregisterNonExistentBaseDN() throws Exception |
| | | { |
| | | DirectoryServer.deregisterBaseDN(DN.valueOf("o=unregistered")); |
| | | } |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testRegisterBackendIDThatAlreadyExists() |
| | | throws Exception |
| | | @Test |
| | | public void testRegisterBackendIDThatAlreadyExists() throws Exception |
| | | { |
| | | TestCaseUtils.initializeTestBackend(false); |
| | | |
| | |
| | | String backendID = "test"; |
| | | Entry backendEntry = createBackendEntry(backendID, false, baseDN); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(backendEntry.getName(), backendEntry.getObjectClasses(), |
| | | backendEntry.getUserAttributes(), |
| | | backendEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(backendEntry); |
| | | assertFalse(addOperation.getResultCode() == ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testAddAndRemoveDisabledBackend() |
| | | throws Exception |
| | | @Test |
| | | public void testAddAndRemoveDisabledBackend() throws Exception |
| | | { |
| | | DN baseDN = DN.valueOf("o=bcmtest"); |
| | | String backendID = createBackendID(baseDN); |
| | | Entry backendEntry = createBackendEntry(backendID, false, baseDN); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(backendEntry.getName(), backendEntry.getObjectClasses(), |
| | | backendEntry.getUserAttributes(), |
| | | backendEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(backendEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertNull(DirectoryServer.getBackend(backendID)); |
| | | assertNull(DirectoryServer.getBackendWithBaseDN(baseDN)); |
| | | |
| | | DeleteOperation deleteOperation = conn.processDelete(backendEntry.getName()); |
| | | DeleteOperation deleteOperation = getRootConnection().processDelete(backendEntry.getName()); |
| | | assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testAddAndRemoveEnabledBackend() |
| | | throws Exception |
| | | @Test |
| | | public void testAddAndRemoveEnabledBackend() throws Exception |
| | | { |
| | | DN baseDN = DN.valueOf("o=bcmtest"); |
| | | String backendID = createBackendID(baseDN); |
| | | Entry backendEntry = createBackendEntry(backendID, true, baseDN); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(backendEntry.getName(), backendEntry.getObjectClasses(), |
| | | backendEntry.getUserAttributes(), |
| | | backendEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(backendEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | Backend backend = DirectoryServer.getBackend(backendID); |
| | | Backend<?> backend = DirectoryServer.getBackend(backendID); |
| | | assertNotNull(backend); |
| | | assertEquals(backend, DirectoryServer.getBackendWithBaseDN(baseDN)); |
| | | assertNull(backend.getParentBackend()); |
| | |
| | | assertTrue(DirectoryServer.isNamingContext(baseDN)); |
| | | |
| | | Entry e = createEntry(baseDN); |
| | | addOperation = conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertTrue(backend.entryExists(baseDN)); |
| | | |
| | | DeleteOperation deleteOperation = conn.processDelete(backendEntry.getName()); |
| | | DeleteOperation deleteOperation = getRootConnection().processDelete(backendEntry.getName()); |
| | | assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertNull(DirectoryServer.getBackend(backendID)); |
| | | } |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testEnableAndDisableBackend() |
| | | throws Exception |
| | | @Test |
| | | public void testEnableAndDisableBackend() throws Exception |
| | | { |
| | | // Create the backend and make it disabled. |
| | | DN baseDN = DN.valueOf("o=bcmtest"); |
| | | String backendID = createBackendID(baseDN); |
| | | Entry backendEntry = createBackendEntry(backendID, false, baseDN); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(backendEntry.getName(), backendEntry.getObjectClasses(), |
| | | backendEntry.getUserAttributes(), |
| | | backendEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(backendEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertNull(DirectoryServer.getBackend(backendID)); |
| | | assertFalse(DirectoryServer.isNamingContext(baseDN)); |
| | | |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | // Modify the backend to enable it. |
| | | ArrayList<Modification> mods = new ArrayList<Modification>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | |
| | | conn.processModify(backendEntry.getName(), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | Backend backend = DirectoryServer.getBackend(backendID); |
| | | Backend<?> backend = DirectoryServer.getBackend(backendID); |
| | | assertNotNull(backend); |
| | | assertEquals(backend, DirectoryServer.getBackendWithBaseDN(baseDN)); |
| | | assertNull(backend.getParentBackend()); |
| | |
| | | assertTrue(DirectoryServer.isNamingContext(baseDN)); |
| | | |
| | | Entry e = createEntry(baseDN); |
| | | addOperation = conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertTrue(backend.entryExists(baseDN)); |
| | | |
| | |
| | | mods = new ArrayList<Modification>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create("ds-cfg-enabled", "false"))); |
| | | modifyOperation = |
| | | conn.processModify(backendEntry.getName(), mods); |
| | | modifyOperation = conn.processModify(backendEntry.getName(), mods); |
| | | assertNull(DirectoryServer.getBackend(backendID)); |
| | | assertFalse(DirectoryServer.entryExists(baseDN)); |
| | | assertFalse(DirectoryServer.isNamingContext(baseDN)); |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testAddNestedBackendParentFirst() |
| | | throws Exception |
| | | @Test |
| | | public void testAddNestedBackendParentFirst() throws Exception |
| | | { |
| | | // Create the parent backend and the corresponding base entry. |
| | | DN parentBaseDN = DN.valueOf("o=parent"); |
| | |
| | | Entry parentBackendEntry = createBackendEntry(parentBackendID, true, |
| | | parentBaseDN); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(parentBackendEntry.getName(), |
| | | parentBackendEntry.getObjectClasses(), |
| | | parentBackendEntry.getUserAttributes(), |
| | | parentBackendEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(parentBackendEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | Backend parentBackend = DirectoryServer.getBackend(parentBackendID); |
| | | Backend<?> parentBackend = DirectoryServer.getBackend(parentBackendID); |
| | | assertNotNull(parentBackend); |
| | | assertEquals(parentBackend, |
| | | DirectoryServer.getBackendWithBaseDN(parentBaseDN)); |
| | |
| | | assertTrue(DirectoryServer.isNamingContext(parentBaseDN)); |
| | | |
| | | Entry e = createEntry(parentBaseDN); |
| | | addOperation = conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertTrue(parentBackend.entryExists(parentBaseDN)); |
| | | |
| | |
| | | Entry childBackendEntry = createBackendEntry(childBackendID, true, |
| | | childBaseDN); |
| | | |
| | | addOperation = |
| | | conn.processAdd(childBackendEntry.getName(), |
| | | childBackendEntry.getObjectClasses(), |
| | | childBackendEntry.getUserAttributes(), |
| | | childBackendEntry.getOperationalAttributes()); |
| | | addOperation = getRootConnection().processAdd(childBackendEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | Backend childBackend = DirectoryServer.getBackend(childBackendID); |
| | | Backend<?> childBackend = DirectoryServer.getBackend(childBackendID); |
| | | assertNotNull(childBackend); |
| | | assertEquals(childBackend, |
| | | DirectoryServer.getBackendWithBaseDN(childBaseDN)); |
| | |
| | | assertFalse(DirectoryServer.isNamingContext(childBaseDN)); |
| | | |
| | | e = createEntry(childBaseDN); |
| | | addOperation = conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertTrue(childBackend.entryExists(childBaseDN)); |
| | | |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | // Make sure that both entries exist. |
| | | InternalSearchOperation internalSearch = |
| | | conn.processSearch(parentBaseDN, SearchScope.WHOLE_SUBTREE, |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testAddNestedBackendChildFirst() |
| | | throws Exception |
| | | @Test |
| | | public void testAddNestedBackendChildFirst() throws Exception |
| | | { |
| | | // Create the child backend and the corresponding base entry (at the time |
| | | // of the creation, it will be a naming context). |
| | |
| | | Entry childBackendEntry = createBackendEntry(childBackendID, true, |
| | | childBaseDN); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(childBackendEntry.getName(), |
| | | childBackendEntry.getObjectClasses(), |
| | | childBackendEntry.getUserAttributes(), |
| | | childBackendEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(childBackendEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | Backend childBackend = DirectoryServer.getBackend(childBackendID); |
| | | Backend<?> childBackend = DirectoryServer.getBackend(childBackendID); |
| | | assertNotNull(childBackend); |
| | | assertEquals(childBackend, |
| | | DirectoryServer.getBackendWithBaseDN(childBaseDN)); |
| | |
| | | assertFalse(childBackend.entryExists(childBaseDN)); |
| | | |
| | | Entry e = createEntry(childBaseDN); |
| | | addOperation = conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertTrue(childBackend.entryExists(childBaseDN)); |
| | | assertTrue(DirectoryServer.isNamingContext(childBaseDN)); |
| | |
| | | Entry parentBackendEntry = createBackendEntry(parentBackendID, true, |
| | | parentBaseDN); |
| | | |
| | | addOperation = |
| | | conn.processAdd(parentBackendEntry.getName(), |
| | | parentBackendEntry.getObjectClasses(), |
| | | parentBackendEntry.getUserAttributes(), |
| | | parentBackendEntry.getOperationalAttributes()); |
| | | addOperation = getRootConnection().processAdd(parentBackendEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | Backend parentBackend = DirectoryServer.getBackend(parentBackendID); |
| | | Backend<?> parentBackend = DirectoryServer.getBackend(parentBackendID); |
| | | assertNotNull(parentBackend); |
| | | assertEquals(parentBackend, |
| | | DirectoryServer.getBackendWithBaseDN(parentBaseDN)); |
| | |
| | | assertTrue(parentBackend.getSubordinateBackends().length == 1); |
| | | |
| | | e = createEntry(parentBaseDN); |
| | | addOperation = conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertTrue(parentBackend.entryExists(parentBaseDN)); |
| | | assertTrue(DirectoryServer.isNamingContext(parentBaseDN)); |
| | | assertFalse(DirectoryServer.isNamingContext(childBaseDN)); |
| | | |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | // Verify that we can see both entries with a subtree search. |
| | | InternalSearchOperation internalSearch = |
| | | conn.processSearch(parentBaseDN, SearchScope.WHOLE_SUBTREE, |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testInsertIntermediateBackend() |
| | | throws Exception |
| | | @Test |
| | | public void testInsertIntermediateBackend() throws Exception |
| | | { |
| | | // Add the parent backend to the server and its corresponding base entry. |
| | | DN parentBaseDN = DN.valueOf("o=parent"); |
| | |
| | | Entry parentBackendEntry = createBackendEntry(parentBackendID, true, |
| | | parentBaseDN); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(parentBackendEntry.getName(), |
| | | parentBackendEntry.getObjectClasses(), |
| | | parentBackendEntry.getUserAttributes(), |
| | | parentBackendEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(parentBackendEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | Backend parentBackend = DirectoryServer.getBackend(parentBackendID); |
| | | Backend<?> parentBackend = DirectoryServer.getBackend(parentBackendID); |
| | | assertNotNull(parentBackend); |
| | | assertEquals(parentBackend, |
| | | DirectoryServer.getBackendWithBaseDN(parentBaseDN)); |
| | |
| | | assertFalse(parentBackend.entryExists(parentBaseDN)); |
| | | |
| | | Entry e = createEntry(parentBaseDN); |
| | | addOperation = conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertTrue(parentBackend.entryExists(parentBaseDN)); |
| | | assertTrue(DirectoryServer.isNamingContext(parentBaseDN)); |
| | |
| | | Entry grandchildBackendEntry = createBackendEntry(grandchildBackendID, true, |
| | | grandchildBaseDN); |
| | | |
| | | addOperation = |
| | | conn.processAdd(grandchildBackendEntry.getName(), |
| | | grandchildBackendEntry.getObjectClasses(), |
| | | grandchildBackendEntry.getUserAttributes(), |
| | | grandchildBackendEntry.getOperationalAttributes()); |
| | | addOperation = getRootConnection().processAdd(grandchildBackendEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | Backend grandchildBackend = DirectoryServer.getBackend(grandchildBackendID); |
| | | Backend<?> grandchildBackend = DirectoryServer.getBackend(grandchildBackendID); |
| | | assertNotNull(grandchildBackend); |
| | | assertEquals(grandchildBackend, |
| | | DirectoryServer.getBackendWithBaseDN(grandchildBaseDN)); |
| | |
| | | // Verify that we can't create the grandchild base entry because its parent |
| | | // doesn't exist. |
| | | e = createEntry(grandchildBaseDN); |
| | | addOperation = conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.NO_SUCH_OBJECT); |
| | | assertFalse(grandchildBackend.entryExists(grandchildBaseDN)); |
| | | |
| | |
| | | Entry childBackendEntry = createBackendEntry(childBackendID, true, |
| | | childBaseDN); |
| | | |
| | | addOperation = |
| | | conn.processAdd(childBackendEntry.getName(), |
| | | childBackendEntry.getObjectClasses(), |
| | | childBackendEntry.getUserAttributes(), |
| | | childBackendEntry.getOperationalAttributes()); |
| | | addOperation = getRootConnection().processAdd(childBackendEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | Backend childBackend = DirectoryServer.getBackend(childBackendID); |
| | | Backend<?> childBackend = DirectoryServer.getBackend(childBackendID); |
| | | assertNotNull(childBackend); |
| | | assertEquals(childBackend, |
| | | DirectoryServer.getBackendWithBaseDN(childBaseDN)); |
| | |
| | | assertEquals(grandchildBackend.getParentBackend(), childBackend); |
| | | |
| | | e = createEntry(childBaseDN); |
| | | addOperation = conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertTrue(childBackend.entryExists(childBaseDN)); |
| | | |
| | | // Now we can create the grandchild base entry. |
| | | e = createEntry(grandchildBaseDN); |
| | | addOperation = conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertTrue(grandchildBackend.entryExists(grandchildBaseDN)); |
| | | |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | // Verify that a subtree search can see all three entries. |
| | | InternalSearchOperation internalSearch = |
| | | conn.processSearch(parentBaseDN, SearchScope.WHOLE_SUBTREE, |
| | |
| | | // Add the child entry back into the server to get things back to the way |
| | | // they were before we disabled the backend. |
| | | e = createEntry(childBaseDN); |
| | | addOperation = conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertTrue(childBackend.entryExists(childBaseDN)); |
| | | |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.plugins.DisconnectClientPlugin; |
| | | import org.opends.server.plugins.InvocationCounterPlugin; |
| | |
| | | import org.opends.server.tools.*; |
| | | import org.opends.server.tools.LDAPReader; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.util.StaticUtils; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | |
| | | "sn: User", |
| | | "cn: Test User"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | // new InternalClientConnection(new AuthenticationInfo()); |
| | | |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | InternalClientConnection conn = getRootConnection(); |
| | | AddOperation addOperation = conn.processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | BindOperation bindOperation = |
| | |
| | | |
| | | package org.opends.server.core; |
| | | |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.net.Socket; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.concurrent.locks.Lock; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.controls.LDAPAssertionRequestControl; |
| | | import org.opends.server.controls.ProxiedAuthV1Control; |
| | |
| | | import org.opends.server.protocols.ldap.*; |
| | | import org.opends.server.tools.LDAPWriter; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.util.ServerConstants; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.testng.Assert.*; |
| | | |
| | | @SuppressWarnings("javadoc") |
| | | public class CompareOperationTestCase extends OperationTestCase |
| | | { |
| | |
| | | "aci: (targetattr=\"*\")(version 3.0; acl \"Proxy Rights\"; " + |
| | | "allow(proxy) userdn=\"ldap:///uid=proxy.user,o=test\";)" |
| | | ); |
| | | AddOperation addOperation = |
| | | connection.processAdd(entry.getName(), |
| | | entry.getObjectClasses(), |
| | | entry.getUserAttributes(), |
| | | entry.getOperationalAttributes()); |
| | | AddOperation addOperation = connection.processAdd(entry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertNotNull(DirectoryServer.getEntry(entry.getName())); |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.controls.MatchedValuesControl; |
| | |
| | | import org.opends.server.tools.LDAPModify; |
| | | import org.opends.server.tools.LDAPWriter; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.util.ServerConstants; |
| | | import org.opends.server.util.StaticUtils; |
| | | import org.testng.annotations.BeforeClass; |
| | |
| | | if (DirectoryServer.getEntry(suffixDN) == null) |
| | | { |
| | | Entry suffixEntry = StaticUtils.createEntry(suffixDN); |
| | | AddOperation addOperation = |
| | | connection.processAdd(suffixEntry.getName(), |
| | | suffixEntry.getObjectClasses(), |
| | | suffixEntry.getUserAttributes(), |
| | | suffixEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = connection.processAdd(suffixEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertNotNull(DirectoryServer.getEntry(suffixEntry.getName())); |
| | | } |
| | |
| | | if (DirectoryServer.getEntry(baseDN) == null) |
| | | { |
| | | Entry baseEntry = StaticUtils.createEntry(baseDN); |
| | | AddOperation addOperation = |
| | | connection.processAdd(baseEntry.getName(), |
| | | baseEntry.getObjectClasses(), |
| | | baseEntry.getUserAttributes(), |
| | | baseEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = connection.processAdd(baseEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertNotNull(DirectoryServer.getEntry(baseEntry.getName())); |
| | | } |
| | |
| | | Entry ldapSubentry = TestCaseUtils.makeEntry( |
| | | "dn: cn=subentry," + BASE, |
| | | "objectclass: ldapsubentry"); |
| | | AddOperation addOperation = |
| | | connection.processAdd(ldapSubentry.getName(), |
| | | ldapSubentry.getObjectClasses(), |
| | | ldapSubentry.getUserAttributes(), |
| | | ldapSubentry.getOperationalAttributes()); |
| | | AddOperation addOperation = connection.processAdd(ldapSubentry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertNotNull(DirectoryServer.getEntry(ldapSubentry.getName())); |
| | | |
| | |
| | | // The add operation changes the attributes, so let's duplicate the entry. |
| | | Entry duplicateEntry = testEntry.duplicate(false); |
| | | |
| | | addOperation = |
| | | connection.processAdd(duplicateEntry.getName(), |
| | | duplicateEntry.getObjectClasses(), |
| | | duplicateEntry.getUserAttributes(), |
| | | duplicateEntry.getOperationalAttributes()); |
| | | addOperation = connection.processAdd(duplicateEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertNotNull(DirectoryServer.getEntry(testEntry.getName())); |
| | | |
| | |
| | | "objectclass: referral", |
| | | "ref: ldap://hostb/OU=People,O=MNN,C=US", |
| | | "ref: ldap://hostc/OU=People,O=MNN,C=US"); |
| | | addOperation = |
| | | connection.processAdd(referralEntry.getName(), |
| | | referralEntry.getObjectClasses(), |
| | | referralEntry.getUserAttributes(), |
| | | referralEntry.getOperationalAttributes()); |
| | | addOperation = connection.processAdd(referralEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertNotNull(DirectoryServer.getEntry(referralEntry.getName())); |
| | | |
| | |
| | | "objectclass: top", |
| | | "objectclass: organizationalunit", |
| | | "ou: level1"); |
| | | addOperation = |
| | | connection.processAdd(level1Entry.getName(), |
| | | level1Entry.getObjectClasses(), |
| | | level1Entry.getUserAttributes(), |
| | | level1Entry.getOperationalAttributes()); |
| | | addOperation = connection.processAdd(level1Entry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertNotNull(DirectoryServer.getEntry(level1Entry.getName())); |
| | | |
| | |
| | | "objectclass: top", |
| | | "objectclass: organizationalunit", |
| | | "ou: level2"); |
| | | addOperation = |
| | | connection.processAdd(level2Entry.getName(), |
| | | level2Entry.getObjectClasses(), |
| | | level2Entry.getUserAttributes(), |
| | | level2Entry.getOperationalAttributes()); |
| | | addOperation = connection.processAdd(level2Entry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertNotNull(DirectoryServer.getEntry(level2Entry.getName())); |
| | | |
| | |
| | | "ref: ldap://hostb/OU=People,O=MNN,C=US", |
| | | "ref: ldap://hostc/OU=People,O=MNN,C=US", |
| | | "ref: ldap://hostd/OU=People,O=MNN,C=US"); |
| | | addOperation = |
| | | connection.processAdd(referral2Entry.getName(), |
| | | referral2Entry.getObjectClasses(), |
| | | referral2Entry.getUserAttributes(), |
| | | referral2Entry.getOperationalAttributes()); |
| | | addOperation = connection.processAdd(referral2Entry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertNotNull(DirectoryServer.getEntry(referral2Entry.getName())); |
| | | } |
| | |
| | | package org.opends.server.core; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | |
| | | import org.opends.server.protocols.ldap.LDAPModification; |
| | | import org.opends.server.tools.LDAPDelete; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.RawModification; |
| | | import org.opends.server.types.SubEntry; |
| | | import org.opends.server.types.SubtreeSpecification; |
| | | import org.opends.server.util.StaticUtils; |
| | | import org.testng.annotations.AfterClass; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.BeforeMethod; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.forgerock.opendj.ldap.ModificationType.*; |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | SubentryManager manager = DirectoryServer.getSubentryManager(); |
| | | assertNotNull(manager); |
| | | List<SubEntry> subentryList = manager.getSubentries(testEntry.getName()); |
| | | assertNotNull(subentryList); |
| | | assertTrue(subentryList.isEmpty()); |
| | | assertThat(subentryList).isEmpty(); |
| | | subentryList = manager.getCollectiveSubentries(testEntry.getName()); |
| | | assertNotNull(subentryList); |
| | | assertTrue(subentryList.isEmpty()); |
| | | assertThat(subentryList).isEmpty(); |
| | | |
| | | TestCaseUtils.clearJEBackend(false, "userRoot", SUFFIX); |
| | | } |
| | |
| | | { |
| | | SubentryManager manager = DirectoryServer.getSubentryManager(); |
| | | assertNotNull(manager); |
| | | |
| | | List<SubEntry> subentryList = manager.getSubentries(testEntry.getName()); |
| | | assertNotNull(subentryList); |
| | | assertEquals(subentryList.size(), 2); |
| | | assertEquals(subentryList.get(0).getDN(), ldapSubentry.getName()); |
| | | assertEquals(subentryList.get(1).getDN(), legacyLdapSubentry.getName()); |
| | | subentryList.clear(); |
| | | assertThat(getDns(subentryList)).containsExactly(ldapSubentry.getName(), legacyLdapSubentry.getName()); |
| | | |
| | | subentryList = manager.getSubentries(testEntry); |
| | | assertNotNull(subentryList); |
| | | assertEquals(subentryList.size(), 2); |
| | | assertEquals(subentryList.get(0).getEntry(), ldapSubentry); |
| | | assertEquals(subentryList.get(1).getEntry(), legacyLdapSubentry); |
| | | subentryList.clear(); |
| | | assertThat(getEntries(subentryList)).containsExactly(ldapSubentry, legacyLdapSubentry); |
| | | |
| | | subentryList = manager.getCollectiveSubentries(testEntry.getName()); |
| | | assertNotNull(subentryList); |
| | | assertEquals(subentryList.size(), 1); |
| | | assertEquals(subentryList.get(0).getDN(), collectiveSubentry.getName()); |
| | | subentryList.clear(); |
| | | assertThat(getDns(subentryList)).containsExactly(collectiveSubentry.getName()); |
| | | |
| | | subentryList = manager.getCollectiveSubentries(testEntry); |
| | | // FIXME following line does not work because server's Entry.equals() is not reflexive |
| | | // assertThat(getEntries(subentryList)).containsExactly(collectiveSubentry); |
| | | assertNotNull(subentryList); |
| | | assertEquals(subentryList.size(), 1); |
| | | assertEquals(subentryList.get(0).getEntry(), collectiveSubentry); |
| | | subentryList.clear(); |
| | | |
| | | subentryList = manager.getSubentries(legacyLdapSubentry.getName().parent()); |
| | | assertNotNull(subentryList); |
| | | assertEquals(subentryList.size(), 1); |
| | | assertEquals(subentryList.get(0).getEntry(), legacyLdapSubentry); |
| | | subentryList.clear(); |
| | | assertThat(getEntries(subentryList)).containsExactly(legacyLdapSubentry); |
| | | |
| | | subentryList = manager.getSubentries(legacyLdapSubentry.getName().parent().parent()); |
| | | assertNotNull(subentryList); |
| | | assertEquals(subentryList.size(), 0); |
| | | assertThat(subentryList).isEmpty(); |
| | | } |
| | | |
| | | private List<Entry> getEntries(List<SubEntry> subentries) |
| | | { |
| | | final List<Entry> results = new ArrayList<Entry>(); |
| | | for (SubEntry subEntry : subentries) |
| | | { |
| | | results.add(subEntry.getEntry()); |
| | | } |
| | | return results; |
| | | } |
| | | |
| | | private List<DN> getDns(List<SubEntry> subentries) |
| | | { |
| | | final List<DN> results = new ArrayList<DN>(); |
| | | for (SubEntry subEntry : subentries) |
| | | { |
| | | results.add(subEntry.getDN()); |
| | | } |
| | | return results; |
| | | } |
| | | |
| | | @Test |
| | | public void testCollectiveAttributes() throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | ArrayList<ByteString> values = new ArrayList<ByteString>(); |
| | | values.add(ByteString.valueOf("real-overrides-virtual")); |
| | | LDAPAttribute attr = new LDAPAttribute( |
| | | "collectiveConflictBehavior", values); |
| | | ArrayList<RawModification> mods = new ArrayList<RawModification>(); |
| | | mods.add(new LDAPModification(ModificationType.REPLACE, attr)); |
| | | ModifyOperation modifyOperation = |
| | | conn.processModify(ByteString.valueOf( |
| | | collectiveSubentry.getName().toNormalizedString()), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | Entry entry = DirectoryServer.getEntry(testEntry.getName()); |
| | | AttributeType attrType = DirectoryServer.getAttributeType("c-l"); |
| | | assertTrue(entry.hasAttribute(attrType)); |
| | | assertTrue(entry.hasValue(attrType, null, ByteString.valueOf("Savoie"))); |
| | | |
| | | attrType = DirectoryServer.getAttributeType("preferredlanguage"); |
| | | assertTrue(entry.hasAttribute(attrType)); |
| | | assertTrue(entry.hasValue(attrType, null, ByteString.valueOf("fr"))); |
| | | replaceAttribute(collectiveSubentry, "collectiveConflictBehavior", "real-overrides-virtual"); |
| | | hasValues(testEntry.getName(), "c-l", "Savoie"); |
| | | hasValues(testEntry.getName(), "preferredlanguage", "fr"); |
| | | } |
| | | |
| | | |
| | |
| | | try |
| | | { |
| | | // Normal user will not inherit the collective description attribute. |
| | | Entry e = DirectoryServer.getEntry(DN |
| | | .valueOf("uid=normal user,ou=people,o=test")); |
| | | Entry e = DirectoryServer.getEntry(DN.valueOf("uid=normal user,ou=people,o=test")); |
| | | assertNotNull(e); |
| | | |
| | | List<Attribute> description = e.getAttribute("description"); |
| | | assertNull(description); |
| | | |
| | | // Collective user will inherit the collective description attribute. |
| | | e = DirectoryServer.getEntry(DN |
| | | .valueOf("uid=collective user,ou=people,o=test")); |
| | | e = DirectoryServer.getEntry(DN.valueOf("uid=collective user,ou=people,o=test")); |
| | | assertNotNull(e); |
| | | |
| | | description = e.getAttribute("description"); |
| | |
| | | @Test |
| | | public void testInheritedCollectiveAttributes() throws Exception |
| | | { |
| | | InternalClientConnection connection = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | // Add test inherited from DN collective subentry. |
| | | Entry collectiveDNInheritedSubentry = TestCaseUtils.makeEntry( |
| | | "dn: cn=Inherited From DN Collective Subentry," + SUFFIX, |
| | |
| | | "inheritAttribute: postalAddress", |
| | | "subtreeSpecification: {base \"ou=Test SubEntry Manager\"}", |
| | | "cn: Inherited From DN Collective Subentry"); |
| | | AddOperation addOperation = |
| | | connection.processAdd(collectiveDNInheritedSubentry.getName(), |
| | | collectiveDNInheritedSubentry.getObjectClasses(), |
| | | collectiveDNInheritedSubentry.getUserAttributes(), |
| | | collectiveDNInheritedSubentry.getOperationalAttributes()); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertNotNull(DirectoryServer.getEntry( |
| | | collectiveDNInheritedSubentry.getName())); |
| | | addEntry(collectiveDNInheritedSubentry); |
| | | |
| | | // Add test inherited from RDN collective subentry. |
| | | Entry collectiveRDNInheritedSubentry = TestCaseUtils.makeEntry( |
| | |
| | | "inheritAttribute: telephoneNumber", |
| | | "subtreeSpecification: {base \"ou=Test SubEntry Manager\"}", |
| | | "cn: Inherited From RDN Collective Subentry"); |
| | | addOperation = |
| | | connection.processAdd(collectiveRDNInheritedSubentry.getName(), |
| | | collectiveRDNInheritedSubentry.getObjectClasses(), |
| | | collectiveRDNInheritedSubentry.getUserAttributes(), |
| | | collectiveRDNInheritedSubentry.getOperationalAttributes()); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertNotNull(DirectoryServer.getEntry( |
| | | collectiveRDNInheritedSubentry.getName())); |
| | | addEntry(collectiveRDNInheritedSubentry); |
| | | |
| | | // Test Inherited Collective Attributes on test entry. |
| | | Entry entry = DirectoryServer.getEntry(testEntry.getName()); |
| | | AttributeType attrType = DirectoryServer.getAttributeType("postaladdress"); |
| | | assertTrue(entry.hasAttribute(attrType)); |
| | | assertTrue(entry.hasValue(attrType, null, |
| | | ByteString.valueOf("Sub City, Collective Street, AK 47"))); |
| | | |
| | | attrType = DirectoryServer.getAttributeType("telephonenumber"); |
| | | assertTrue(entry.hasAttribute(attrType)); |
| | | assertTrue(entry.hasValue(attrType, null, |
| | | ByteString.valueOf("+1 999 999 9999"))); |
| | | hasValues(testEntry.getName(), "postaladdress", "Sub City, Collective Street, AK 47"); |
| | | hasValues(testEntry.getName(), "telephonenumber", "+1 999 999 9999"); |
| | | |
| | | // Cleanup. |
| | | TestCaseUtils.deleteEntry(collectiveRDNInheritedSubentry.getName()); |
| | |
| | | @Test |
| | | public void testCollectiveAttributeConflict() throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | ArrayList<ByteString> values = new ArrayList<ByteString>(); |
| | | values.add(ByteString.valueOf("ja")); |
| | | LDAPAttribute attr = new LDAPAttribute( |
| | | "preferredLanguage", values); |
| | | ArrayList<RawModification> mods = new ArrayList<RawModification>(); |
| | | mods.add(new LDAPModification(ModificationType.REPLACE, attr)); |
| | | ModifyOperation modifyOperation = |
| | | conn.processModify(ByteString.valueOf( |
| | | testEntry.getName().toNormalizedString()), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | DN dn = testEntry.getName(); |
| | | replaceAttribute(testEntry, "preferredLanguage", "ja"); |
| | | |
| | | // real-overrides-virtual. |
| | | values = new ArrayList<ByteString>(); |
| | | values.add(ByteString.valueOf("real-overrides-virtual")); |
| | | attr = new LDAPAttribute( |
| | | "collectiveConflictBehavior", values); |
| | | mods = new ArrayList<RawModification>(); |
| | | mods.add(new LDAPModification(ModificationType.REPLACE, attr)); |
| | | modifyOperation = |
| | | conn.processModify(ByteString.valueOf( |
| | | collectiveSubentry.getName().toNormalizedString()), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | Entry entry = DirectoryServer.getEntry(testEntry.getName()); |
| | | AttributeType attrType = DirectoryServer.getAttributeType("preferredlanguage"); |
| | | assertTrue(entry.hasAttribute(attrType)); |
| | | assertTrue(entry.hasValue(attrType, null, ByteString.valueOf("ja"))); |
| | | assertFalse(entry.hasValue(attrType, null, ByteString.valueOf("fr"))); |
| | | replaceAttribute(collectiveSubentry, "collectiveConflictBehavior", "real-overrides-virtual"); |
| | | hasValues(dn, "preferredlanguage", "ja"); |
| | | doesNotHaveValues(dn, "preferredlanguage", "fr"); |
| | | |
| | | // virtual-overrides-real. |
| | | values = new ArrayList<ByteString>(); |
| | | values.add(ByteString.valueOf("virtual-overrides-real")); |
| | | attr = new LDAPAttribute( |
| | | "collectiveConflictBehavior", values); |
| | | mods = new ArrayList<RawModification>(); |
| | | mods.add(new LDAPModification(ModificationType.REPLACE, attr)); |
| | | modifyOperation = |
| | | conn.processModify(ByteString.valueOf( |
| | | collectiveSubentry.getName().toNormalizedString()), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | entry = DirectoryServer.getEntry(testEntry.getName()); |
| | | attrType = DirectoryServer.getAttributeType("preferredlanguage"); |
| | | assertTrue(entry.hasAttribute(attrType)); |
| | | assertTrue(entry.hasValue(attrType, null, ByteString.valueOf("fr"))); |
| | | assertFalse(entry.hasValue(attrType, null, ByteString.valueOf("ja"))); |
| | | replaceAttribute(collectiveSubentry, "collectiveConflictBehavior", "virtual-overrides-real"); |
| | | hasValues(dn, "preferredlanguage", "fr"); |
| | | doesNotHaveValues(dn, "preferredlanguage", "ja"); |
| | | |
| | | // merge-real-and-virtual. |
| | | values = new ArrayList<ByteString>(); |
| | | values.add(ByteString.valueOf("merge-real-and-virtual")); |
| | | attr = new LDAPAttribute( |
| | | "collectiveConflictBehavior", values); |
| | | mods = new ArrayList<RawModification>(); |
| | | mods.add(new LDAPModification(ModificationType.REPLACE, attr)); |
| | | modifyOperation = |
| | | conn.processModify(ByteString.valueOf( |
| | | collectiveSubentry.getName().toNormalizedString()), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | entry = DirectoryServer.getEntry(testEntry.getName()); |
| | | attrType = DirectoryServer.getAttributeType("preferredlanguage"); |
| | | assertTrue(entry.hasAttribute(attrType)); |
| | | assertTrue(entry.hasValue(attrType, null, ByteString.valueOf("ja"))); |
| | | assertTrue(entry.hasValue(attrType, null, ByteString.valueOf("fr"))); |
| | | replaceAttribute(collectiveSubentry, "collectiveConflictBehavior", "merge-real-and-virtual"); |
| | | hasValues(dn, "preferredlanguage", "ja", "fr"); |
| | | |
| | | // cleanup. |
| | | values = new ArrayList<ByteString>(); |
| | | values.add(ByteString.valueOf("ja")); |
| | | attr = new LDAPAttribute( |
| | | "preferredLanguage", values); |
| | | mods = new ArrayList<RawModification>(); |
| | | mods.add(new LDAPModification(ModificationType.DELETE, attr)); |
| | | modifyOperation = |
| | | conn.processModify(ByteString.valueOf( |
| | | testEntry.getName().toNormalizedString()), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | deleteAttribute(testEntry, "preferredLanguage", "ja"); |
| | | } |
| | | |
| | | private void hasValues(DN dn, String attrTypeLower, String... values) throws DirectoryException |
| | | { |
| | | Entry entry = DirectoryServer.getEntry(dn); |
| | | AttributeType attrType = DirectoryServer.getAttributeType(attrTypeLower); |
| | | assertTrue(entry.hasAttribute(attrType)); |
| | | for (String value : values) |
| | | { |
| | | assertTrue(entry.hasValue(attrType, null, ByteString.valueOf(value))); |
| | | } |
| | | } |
| | | |
| | | private void doesNotHaveValues(DN dn, String attrTypeLower, String... values) throws DirectoryException |
| | | { |
| | | Entry entry = DirectoryServer.getEntry(dn); |
| | | AttributeType attrType = DirectoryServer.getAttributeType(attrTypeLower); |
| | | assertTrue(entry.hasAttribute(attrType)); |
| | | for (String value : values) |
| | | { |
| | | assertFalse(entry.hasValue(attrType, null, ByteString.valueOf(value))); |
| | | } |
| | | } |
| | | |
| | | private void hasNoAttribute(DN dn, String lowerName) throws Exception |
| | | { |
| | | Entry entry = DirectoryServer.getEntry(dn); |
| | | AttributeType attrType = DirectoryServer.getAttributeType(lowerName); |
| | | assertFalse(entry.hasAttribute(attrType)); |
| | | } |
| | | |
| | | @Test |
| | | public void testCollectiveAttributeSubentries() throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | LinkedHashSet<String> attributes = new LinkedHashSet<String>(); |
| | | attributes.add("collectiveAttributeSubentries"); |
| | | Set<String> attributes = newSet("collectiveAttributeSubentries"); |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation( |
| | | conn, |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | getRootConnection(), nextOperationID(), nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.valueOf(testEntry.getName().toString()), |
| | | SearchScope.BASE_OBJECT, |
| | |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertEquals(searchOperation.getEntriesSent(), 1); |
| | | AttributeType attrType = DirectoryServer.getAttributeType("collectiveattributesubentries"); |
| | | assertTrue(searchOperation.getSearchEntries().getFirst().hasValue( |
| | | attrType, null, ByteString.valueOf(collectiveSubentry.getName()))); |
| | | Entry e = searchOperation.getSearchEntries().getFirst(); |
| | | assertTrue(e.hasValue(attrType, null, ByteString.valueOf(collectiveSubentry.getName()))); |
| | | } |
| | | |
| | | @Test |
| | | public void testCollectiveExclusions() throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | DN dn = testEntry.getName(); |
| | | |
| | | ArrayList<ByteString> values = new ArrayList<ByteString>(); |
| | | values.add(ByteString.valueOf("real-overrides-virtual")); |
| | | LDAPAttribute attr = new LDAPAttribute( |
| | | "collectiveConflictBehavior", values); |
| | | ArrayList<RawModification> mods = new ArrayList<RawModification>(); |
| | | mods.add(new LDAPModification(ModificationType.REPLACE, attr)); |
| | | ModifyOperation modifyOperation = |
| | | conn.processModify(ByteString.valueOf( |
| | | collectiveSubentry.getName().toNormalizedString()), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | values = new ArrayList<ByteString>(); |
| | | values.add(ByteString.valueOf("c-l")); |
| | | attr = new LDAPAttribute("collectiveExclusions", values); |
| | | mods = new ArrayList<RawModification>(); |
| | | mods.add(new LDAPModification(ModificationType.REPLACE, attr)); |
| | | modifyOperation = |
| | | conn.processModify(ByteString.valueOf( |
| | | testEntry.getName().toNormalizedString()), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | replaceAttribute(collectiveSubentry, "collectiveConflictBehavior", "real-overrides-virtual"); |
| | | replaceAttribute(testEntry, "collectiveExclusions", "c-l"); |
| | | hasNoAttribute(dn, "c-l"); |
| | | hasValues(dn, "preferredlanguage", "fr"); |
| | | |
| | | Entry entry = DirectoryServer.getEntry(testEntry.getName()); |
| | | AttributeType attrType = DirectoryServer.getAttributeType("c-l"); |
| | | assertFalse(entry.hasAttribute(attrType)); |
| | | attrType = DirectoryServer.getAttributeType("preferredlanguage"); |
| | | assertTrue(entry.hasAttribute(attrType)); |
| | | assertTrue(entry.hasValue(attrType, null, ByteString.valueOf("fr"))); |
| | | replaceAttribute(testEntry, "collectiveExclusions", "preferredLanguage"); |
| | | hasNoAttribute(dn, "preferredlanguage"); |
| | | hasValues(dn, "c-l", "Savoie"); |
| | | |
| | | values = new ArrayList<ByteString>(); |
| | | values.add(ByteString.valueOf("preferredLanguage")); |
| | | attr = new LDAPAttribute("collectiveExclusions", values); |
| | | mods = new ArrayList<RawModification>(); |
| | | mods.add(new LDAPModification(ModificationType.REPLACE, attr)); |
| | | modifyOperation = |
| | | conn.processModify(ByteString.valueOf( |
| | | testEntry.getName().toNormalizedString()), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | entry = DirectoryServer.getEntry(testEntry.getName()); |
| | | attrType = DirectoryServer.getAttributeType("preferredlanguage"); |
| | | assertFalse(entry.hasAttribute(attrType)); |
| | | attrType = DirectoryServer.getAttributeType("c-l"); |
| | | assertTrue(entry.hasAttribute(attrType)); |
| | | assertTrue(entry.hasValue(attrType, null, ByteString.valueOf("Savoie"))); |
| | | |
| | | values = new ArrayList<ByteString>(); |
| | | values.add(ByteString.valueOf("excludeAllCollectiveAttributes")); |
| | | attr = new LDAPAttribute("collectiveExclusions", values); |
| | | mods = new ArrayList<RawModification>(); |
| | | mods.add(new LDAPModification(ModificationType.REPLACE, attr)); |
| | | modifyOperation = |
| | | conn.processModify(ByteString.valueOf( |
| | | testEntry.getName().toNormalizedString()), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | entry = DirectoryServer.getEntry(testEntry.getName()); |
| | | attrType = DirectoryServer.getAttributeType("preferredlanguage"); |
| | | assertFalse(entry.hasAttribute(attrType)); |
| | | attrType = DirectoryServer.getAttributeType("c-l"); |
| | | assertFalse(entry.hasAttribute(attrType)); |
| | | replaceAttribute(testEntry, "collectiveExclusions", "excludeAllCollectiveAttributes"); |
| | | hasNoAttribute(dn, "preferredlanguage"); |
| | | hasNoAttribute(dn, "c-l"); |
| | | |
| | | // cleanup. |
| | | values = new ArrayList<ByteString>(); |
| | | values.add(ByteString.valueOf("excludeAllCollectiveAttributes")); |
| | | attr = new LDAPAttribute("collectiveExclusions", values); |
| | | mods = new ArrayList<RawModification>(); |
| | | mods.add(new LDAPModification(ModificationType.DELETE, attr)); |
| | | modifyOperation = |
| | | conn.processModify(ByteString.valueOf( |
| | | testEntry.getName().toNormalizedString()), mods); |
| | | deleteAttribute(testEntry, "collectiveExclusions", "excludeAllCollectiveAttributes"); |
| | | } |
| | | |
| | | private void deleteAttribute(Entry e, String attrType, String oldValue) |
| | | { |
| | | InternalClientConnection conn = getRootConnection(); |
| | | List<RawModification> mods = newRawModifications(DELETE, attrType, oldValue); |
| | | ModifyOperation modifyOperation = conn.processModify(ByteString.valueOf(e.getName().toNormalizedString()), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | | private void replaceAttribute(Entry e, String attrType, String newValue) |
| | | { |
| | | InternalClientConnection conn = getRootConnection(); |
| | | List<RawModification> mods = newRawModifications(REPLACE, attrType, newValue); |
| | | ModifyOperation modifyOperation = conn.processModify(ByteString.valueOf(e.getName().toNormalizedString()), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | | private List<RawModification> newRawModifications(ModificationType modType, String attrType, String value) |
| | | { |
| | | ArrayList<ByteString> values = newArrayList(ByteString.valueOf(value)); |
| | | LDAPAttribute attr = new LDAPAttribute(attrType, values); |
| | | return newList((RawModification) new LDAPModification(modType, attr)); |
| | | } |
| | | |
| | | @Test |
| | | public void testSubtreeDelete() throws Exception |
| | | { |
| | |
| | | |
| | | assertTrue(DirectoryServer.getSubentryManager().getCollectiveSubentries( |
| | | DN.valueOf("uid=rogasawara," + BASE)).isEmpty()); |
| | | |
| | | assertTrue(DirectoryServer.getSubentryManager().getSubentries( |
| | | DN.valueOf("uid=rogasawara," + BASE)).isEmpty()); |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | InternalClientConnection connection = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | // Add Relative Spec test subentry. |
| | | Entry relativeSubentry = TestCaseUtils.makeEntry( |
| | | "dn: cn=Relative Subentry," + SUFFIX, |
| | |
| | | "objectclass: subentry", |
| | | "subtreeSpecification: {base \"ou=Test SubEntry Manager\", specificationFilter \"(objectClass=*)\"}", |
| | | "cn: Subentry"); |
| | | AddOperation addOperation = |
| | | connection.processAdd(relativeSubentry.getName(), |
| | | relativeSubentry.getObjectClasses(), |
| | | relativeSubentry.getUserAttributes(), |
| | | relativeSubentry.getOperationalAttributes()); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertNotNull(DirectoryServer.getEntry(relativeSubentry.getName())); |
| | | addEntry(relativeSubentry); |
| | | |
| | | List<SubEntry> relativeSubList = |
| | | DirectoryServer.getSubentryManager().getSubentries(); |
| | |
| | | |
| | | private void addTestEntries() throws Exception |
| | | { |
| | | InternalClientConnection connection = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | // Add suffix entry. |
| | | DN suffixDN = DN.valueOf(SUFFIX); |
| | | if (DirectoryServer.getEntry(suffixDN) == null) |
| | | { |
| | | Entry suffixEntry = StaticUtils.createEntry(suffixDN); |
| | | AddOperation addOperation = |
| | | connection.processAdd(suffixEntry.getName(), |
| | | suffixEntry.getObjectClasses(), |
| | | suffixEntry.getUserAttributes(), |
| | | suffixEntry.getOperationalAttributes()); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertNotNull(DirectoryServer.getEntry(suffixEntry.getName())); |
| | | addEntry(StaticUtils.createEntry(suffixDN)); |
| | | } |
| | | |
| | | // Add base entry. |
| | | DN baseDN = DN.valueOf(BASE); |
| | | if (DirectoryServer.getEntry(baseDN) == null) |
| | | { |
| | | Entry baseEntry = StaticUtils.createEntry(baseDN); |
| | | AddOperation addOperation = |
| | | connection.processAdd(baseEntry.getName(), |
| | | baseEntry.getObjectClasses(), |
| | | baseEntry.getUserAttributes(), |
| | | baseEntry.getOperationalAttributes()); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertNotNull(DirectoryServer.getEntry(baseEntry.getName())); |
| | | addEntry(StaticUtils.createEntry(baseDN)); |
| | | } |
| | | |
| | | // Add role entry. |
| | |
| | | "telephoneNumber: +1 999 999 9999", |
| | | "cn: Sales" |
| | | ); |
| | | AddOperation addOperation = |
| | | connection.processAdd(roleEntry.getName(), |
| | | roleEntry.getObjectClasses(), |
| | | roleEntry.getUserAttributes(), |
| | | roleEntry.getOperationalAttributes()); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertNotNull(DirectoryServer.getEntry(roleEntry.getName())); |
| | | addEntry(roleEntry); |
| | | |
| | | // Add test entry. |
| | | testEntry = TestCaseUtils.makeEntry( |
| | |
| | | "manager: cn=Sales," + BASE, |
| | | "title: Sales" |
| | | ); |
| | | addOperation = |
| | | connection.processAdd(testEntry.getName(), |
| | | testEntry.getObjectClasses(), |
| | | testEntry.getUserAttributes(), |
| | | testEntry.getOperationalAttributes()); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertNotNull(DirectoryServer.getEntry(testEntry.getName())); |
| | | addEntry(testEntry); |
| | | |
| | | // Add test subentry. |
| | | ldapSubentry = TestCaseUtils.makeEntry( |
| | |
| | | "objectclass: subentry", |
| | | "subtreeSpecification: {base \"ou=Test SubEntry Manager\"}", |
| | | "cn: Subentry"); |
| | | addOperation = |
| | | connection.processAdd(ldapSubentry.getName(), |
| | | ldapSubentry.getObjectClasses(), |
| | | ldapSubentry.getUserAttributes(), |
| | | ldapSubentry.getOperationalAttributes()); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertNotNull(DirectoryServer.getEntry(ldapSubentry.getName())); |
| | | addEntry(ldapSubentry); |
| | | |
| | | // Add test legacy subentry. |
| | | legacyLdapSubentry = TestCaseUtils.makeEntry( |
| | |
| | | "objectClass: top", |
| | | "objectclass: ldapSubentry", |
| | | "cn: Legacy Subentry"); |
| | | addOperation = |
| | | connection.processAdd(legacyLdapSubentry.getName(), |
| | | legacyLdapSubentry.getObjectClasses(), |
| | | legacyLdapSubentry.getUserAttributes(), |
| | | legacyLdapSubentry.getOperationalAttributes()); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertNotNull(DirectoryServer.getEntry(legacyLdapSubentry.getName())); |
| | | addEntry(legacyLdapSubentry); |
| | | |
| | | // Add test collective subentry. |
| | | collectiveSubentry = TestCaseUtils.makeEntry( |
| | |
| | | "preferredLanguage;collective: fr", |
| | | "subtreeSpecification: {base \"ou=Test SubEntry Manager\"}", |
| | | "cn: Collective Subentry"); |
| | | addOperation = |
| | | connection.processAdd(collectiveSubentry.getName(), |
| | | collectiveSubentry.getObjectClasses(), |
| | | collectiveSubentry.getUserAttributes(), |
| | | collectiveSubentry.getOperationalAttributes()); |
| | | addEntry(collectiveSubentry); |
| | | } |
| | | |
| | | private void addEntry(Entry e) throws DirectoryException |
| | | { |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertNotNull(DirectoryServer.getEntry(collectiveSubentry.getName())); |
| | | assertNotNull(DirectoryServer.getEntry(e.getName())); |
| | | } |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | | |
| | | |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.api.AuthenticationPolicy; |
| | | import org.opends.server.api.PasswordValidator; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.util.StaticUtils; |
| | | import org.testng.annotations.AfterClass; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.api.AuthenticationPolicy; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.util.StaticUtils; |
| | | import org.testng.annotations.AfterClass; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | |
| | | /** |
| | | * A set of test cases for the Directory Server subentry password policy. |
| | | */ |
| | | @SuppressWarnings("javadoc") |
| | | public class SubentryPasswordPolicyTestCase |
| | | extends CoreTestCase |
| | | { |
| | |
| | | TestCaseUtils.startServer(); |
| | | TestCaseUtils.clearJEBackend(false, "userRoot", SUFFIX); |
| | | |
| | | InternalClientConnection connection = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | // Add suffix entry. |
| | | DN suffixDN = DN.valueOf(SUFFIX); |
| | | if (DirectoryServer.getEntry(suffixDN) == null) |
| | | { |
| | | Entry suffixEntry = StaticUtils.createEntry(suffixDN); |
| | | AddOperation addOperation = |
| | | connection.processAdd(suffixEntry.getName(), |
| | | suffixEntry.getObjectClasses(), |
| | | suffixEntry.getUserAttributes(), |
| | | suffixEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(suffixEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertNotNull(DirectoryServer.getEntry(suffixEntry.getName())); |
| | | } |
| | |
| | | if (DirectoryServer.getEntry(baseDN) == null) |
| | | { |
| | | Entry baseEntry = StaticUtils.createEntry(baseDN); |
| | | AddOperation addOperation = |
| | | connection.processAdd(baseEntry.getName(), |
| | | baseEntry.getObjectClasses(), |
| | | baseEntry.getUserAttributes(), |
| | | baseEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(baseEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertNotNull(DirectoryServer.getEntry(baseEntry.getName())); |
| | | } |
| | |
| | | "cn: Rodney Ogasawara", |
| | | "title: Sales, Director" |
| | | ); |
| | | AddOperation addOperation = |
| | | connection.processAdd(testEntry.getName(), |
| | | testEntry.getObjectClasses(), |
| | | testEntry.getUserAttributes(), |
| | | testEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(testEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertNotNull(DirectoryServer.getEntry(testEntry.getName())); |
| | | } |
| | |
| | | public void testInvalidConfigurations(Entry e) |
| | | throws Exception |
| | | { |
| | | InternalClientConnection connection = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | AddOperation addOperation = |
| | | connection.processAdd(e.getName(), |
| | | e.getObjectClasses(), |
| | | e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertTrue(addOperation.getResultCode() != ResultCode.SUCCESS); |
| | | assertNull(DirectoryServer.getEntry(e.getName())); |
| | | } |
| | |
| | | "pwdSafeModify: TRUE" |
| | | ); |
| | | |
| | | InternalClientConnection connection = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | AddOperation addOperation = |
| | | connection.processAdd(policyEntry.getName(), |
| | | policyEntry.getObjectClasses(), |
| | | policyEntry.getUserAttributes(), |
| | | policyEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(policyEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertNotNull(DirectoryServer.getEntry(policyEntry.getName())); |
| | | |
| | |
| | | assertEquals(policy.getPasswordHistoryCount(), 5); |
| | | assertEquals(policy.getPasswordExpirationWarningInterval(), 864000); |
| | | assertEquals(policy.getGraceLoginCount(), 3); |
| | | assertEquals(policy.getLockoutFailureExpirationInterval(), |
| | | 3600); |
| | | assertEquals(policy.getLockoutFailureExpirationInterval(), 3600); |
| | | assertEquals(policy.isAllowUserPasswordChanges(), false); |
| | | assertEquals(policy.isPasswordChangeRequiresCurrentPassword(), true); |
| | | |
| | |
| | | "ds-cfg-password-validator: cn=Length-Based Password Validator,cn=Password Validators,cn=config" |
| | | ); |
| | | |
| | | InternalClientConnection connection = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | AddOperation addOperation = |
| | | connection.processAdd(policyEntry.getName(), |
| | | policyEntry.getObjectClasses(), |
| | | policyEntry.getUserAttributes(), |
| | | policyEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(policyEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertNotNull(DirectoryServer.getEntry(policyEntry.getName())); |
| | | |
| | |
| | | "pwdAttribute: userPassword" |
| | | ); |
| | | |
| | | InternalClientConnection connection = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | AddOperation addOperation = |
| | | connection.processAdd(policyEntry.getName(), |
| | | policyEntry.getObjectClasses(), |
| | | policyEntry.getUserAttributes(), |
| | | policyEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(policyEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertNotNull(DirectoryServer.getEntry(policyEntry.getName())); |
| | | |
| | |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | | import org.testng.annotations.Test; |
| | | import org.testng.annotations.BeforeClass; |
| | | import static org.testng.Assert.*; |
| | | import java.net.Socket; |
| | | import java.util.Collections; |
| | | import java.util.Hashtable; |
| | | import java.util.List; |
| | | import java.util.concurrent.locks.Lock; |
| | | |
| | | import javax.naming.Context; |
| | | import javax.naming.InvalidNameException; |
| | | import javax.naming.directory.DirContext; |
| | | import javax.naming.directory.InitialDirContext; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.api.ClientConnection; |
| | | import org.opends.server.controls.ProxiedAuthV1Control; |
| | |
| | | import org.opends.server.tools.LDAPModify; |
| | | import org.opends.server.tools.LDAPWriter; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.util.ServerConstants; |
| | | import org.opends.server.util.StaticUtils; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import java.net.Socket; |
| | | import java.util.Collections; |
| | | import java.util.Hashtable; |
| | | import java.util.List; |
| | | import java.util.concurrent.locks.Lock; |
| | | |
| | | import javax.naming.Context; |
| | | import javax.naming.InvalidNameException; |
| | | import javax.naming.directory.DirContext; |
| | | import javax.naming.directory.InitialDirContext; |
| | | import static org.testng.Assert.*; |
| | | |
| | | @SuppressWarnings("javadoc") |
| | | public class TestModifyDNOperation extends OperationTestCase |
| | |
| | | "description: This is the description for Aaccf Amar." |
| | | ); |
| | | |
| | | AddOperation addOperation = |
| | | connection.processAdd(exampleCom.getName(), |
| | | exampleCom.getObjectClasses(), |
| | | exampleCom.getUserAttributes(), |
| | | exampleCom.getOperationalAttributes()); |
| | | AddOperation addOperation = connection.processAdd(exampleCom); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertNotNull(DirectoryServer.getEntry(exampleCom.getName())); |
| | | |
| | | addOperation = |
| | | connection.processAdd(people.getName(), |
| | | people.getObjectClasses(), |
| | | people.getUserAttributes(), |
| | | people.getOperationalAttributes()); |
| | | addOperation = connection.processAdd(people); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertNotNull(DirectoryServer.getEntry(people.getName())); |
| | | |
| | | addOperation = |
| | | connection.processAdd(entry.getName(), |
| | | entry.getObjectClasses(), |
| | | entry.getUserAttributes(), |
| | | entry.getOperationalAttributes()); |
| | | addOperation = connection.processAdd(entry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertNotNull(DirectoryServer.getEntry(entry.getName())); |
| | | |
| | |
| | | import java.util.Collections; |
| | | |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.DirectoryServerTestCase; |
| | | import org.opends.server.TestCaseUtils; |
| | |
| | | import org.opends.server.api.ClientConnection; |
| | | import org.opends.server.core.*; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.ldap.LDAPFilter; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.util.StaticUtils; |
| | | import org.opends.server.workflowelement.WorkflowElement; |
| | | import org.testng.annotations.BeforeClass; |
| | |
| | | @SuppressWarnings("javadoc") |
| | | public class NetworkGroupTest extends DirectoryServerTestCase { |
| | | //=========================================================================== |
| | | // |
| | | // B E F O R E C L A S S |
| | | // |
| | | //=========================================================================== |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | //=========================================================================== |
| | | // |
| | | // D A T A P R O V I D E R |
| | | // |
| | | //=========================================================================== |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Provides the priorities for 3 network groups |
| | | */ |
| | | /** Provides the priorities for 3 network groups. */ |
| | | @DataProvider (name = "PrioritySet_0") |
| | | public Object[][] initPrioritySet_0() |
| | | { |
| | |
| | | |
| | | |
| | | //=========================================================================== |
| | | // |
| | | // T E S T C A S E S |
| | | // |
| | | //=========================================================================== |
| | | |
| | | |
| | |
| | | doCheckNetworkGroup(defaultNG, dnToSearch, dnSubordinate, null, |
| | | existsInDefault); |
| | | |
| | | // Dump the default network group |
| | | dump(defaultNG, "defaultNetworkGroup> "); |
| | | |
| | | // let's get the admin network group -- it should always exist |
| | | NetworkGroup adminNG = NetworkGroup.getAdminNetworkGroup(); |
| | |
| | | doCheckNetworkGroup(adminNG, dnToSearch, dnSubordinate, null, |
| | | existsInAdmin); |
| | | |
| | | // Dump the default network group |
| | | dump(adminNG, "adminNetworkGroup> "); |
| | | |
| | | // let's get the internal network group -- it should always exist |
| | | NetworkGroup internalNG = NetworkGroup.getInternalNetworkGroup(); |
| | |
| | | // let's check the routing through the network group |
| | | doCheckNetworkGroup(internalNG, dnToSearch, dnSubordinate, null, |
| | | existsInInternal); |
| | | |
| | | // Dump the default network group |
| | | dump(internalNG, "internalNetworkGroup> "); |
| | | } |
| | | |
| | | |
| | |
| | | int expectedNamingContexts |
| | | ) throws Exception |
| | | { |
| | | SearchOperation search = connection.processSearch( |
| | | DN.valueOf(""), |
| | | SearchScope.SINGLE_LEVEL, |
| | | LDAPFilter.decode("(objectClass=*)").toSearchFilter()); |
| | | SearchOperation search = connection.processSearch("", SearchScope.SINGLE_LEVEL, "(objectClass=*)"); |
| | | |
| | | // Check the number of found naming context |
| | | ResultCode expectedRC = |
| | | (shouldExist ? ResultCode.SUCCESS : ResultCode.NO_SUCH_OBJECT); |
| | | assertEquals(search.getResultCode(), expectedRC); |
| | | assertEquals(search.getResultCode(), shouldExist ? ResultCode.SUCCESS : ResultCode.NO_SUCH_OBJECT); |
| | | if (shouldExist) |
| | | { |
| | | assertEquals(search.getEntriesSent(), expectedNamingContexts); |
| | |
| | | boolean shouldExist |
| | | ) throws Exception |
| | | { |
| | | SearchOperation search = connection.processSearch( |
| | | DN.valueOf(baseDN), |
| | | SearchScope.BASE_OBJECT, |
| | | LDAPFilter.decode("(objectClass=*)").toSearchFilter()); |
| | | SearchOperation search = connection.processSearch(baseDN, SearchScope.BASE_OBJECT, "(objectClass=*)"); |
| | | |
| | | // Compare the result code with the expected one |
| | | ResultCode resultCode = search.getResultCode(); |
| | | if (shouldExist) |
| | | { |
| | | assertEquals(resultCode, ResultCode.SUCCESS); |
| | | } |
| | | else |
| | | { |
| | | assertEquals(resultCode, ResultCode.NO_SUCH_OBJECT); |
| | | } |
| | | assertEquals(search.getResultCode(), shouldExist ? ResultCode.SUCCESS : ResultCode.NO_SUCH_OBJECT); |
| | | } |
| | | |
| | | |
| | |
| | | "objectClass: organization", |
| | | "o: " + namingAttribute); |
| | | |
| | | AddOperation addOperation = connection.processAdd( |
| | | e.getName(), |
| | | e.getObjectClasses(), |
| | | e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | |
| | | AddOperation addOperation = connection.processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | System.out.print(msg); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Prints a text to System.out. |
| | | */ |
| | | private void writeln(String msg) |
| | | { |
| | | write(msg + "\n"); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Dump the network group info to the console. |
| | | */ |
| | | private void dump(NetworkGroup networkGroup, String prompt) |
| | | { |
| | | final boolean doDump = false; |
| | | |
| | | if (doDump) |
| | | { |
| | | StringBuilder sb = networkGroup.toString(prompt); |
| | | writeln(sb.toString()); |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.admin.server.AdminTestCaseUtils; |
| | | import org.opends.server.admin.std.meta. |
| | | CramMD5SASLMechanismHandlerCfgDefn; |
| | | import org.opends.server.admin.std.server. |
| | | CramMD5SASLMechanismHandlerCfg; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.admin.std.meta.CramMD5SASLMechanismHandlerCfgDefn; |
| | | import org.opends.server.admin.std.server.CramMD5SASLMechanismHandlerCfg; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.core.BindOperation; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.tools.LDAPSearch; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import static org.testng.Assert.*; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * A set of test cases for the CRAM-MD5 SASL mechanism handler. |
| | | */ |
| | | @SuppressWarnings("javadoc") |
| | | public class CRAMMD5SASLMechanismHandlerTestCase |
| | | extends ExtensionsTestCase |
| | | { |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @BeforeClass() |
| | | public void startServer() |
| | | throws Exception |
| | | @BeforeClass |
| | | public void startServer() throws Exception |
| | | { |
| | | TestCaseUtils.startServer(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves a set of invalid configuration entries. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @DataProvider(name = "invalidConfigs") |
| | | public Object[][] getInvalidConfigs() |
| | | throws Exception |
| | | public Object[][] getInvalidConfigs() throws Exception |
| | | { |
| | | List<Entry> entries = TestCaseUtils.makeEntries( |
| | | "dn: cn=CRAM-MD5,cn=SASL Mechanisms,cn=config", |
| | |
| | | "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," + |
| | | "cn=Password Policies,cn=config"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | String[] args = |
| | |
| | | "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," + |
| | | "cn=Password Policies,cn=config"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | String[] args = |
| | |
| | | "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," + |
| | | "cn=Password Policies,cn=config"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | String[] args = |
| | |
| | | "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," + |
| | | "cn=Password Policies,cn=config"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | String[] args = |
| | |
| | | "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," + |
| | | "cn=Password Policies,cn=config"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | String[] args = |
| | |
| | | "cn: Test User", |
| | | "userPassword: password"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | String[] args = |
| | |
| | | "cn: Test User", |
| | | "userPassword: password"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | String[] args = |
| | |
| | | "cn: Test User", |
| | | "userPassword: password"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | String[] args = |
| | |
| | | "cn: Test User", |
| | | "userPassword: password"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | String[] args = |
| | |
| | | |
| | | |
| | | |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | | import static org.opends.server.util.ServerConstants.OID_CANCEL_REQUEST; |
| | | import static org.opends.server.util.ServerConstants.OID_WHO_AM_I_REQUEST; |
| | | import static org.testng.Assert.assertEquals; |
| | | |
| | | import java.net.Socket; |
| | | import java.util.ArrayList; |
| | | import java.util.LinkedHashSet; |
| | | |
| | | import org.forgerock.opendj.io.ASN1; |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.plugins.DelayPreOpPlugin; |
| | | import org.forgerock.opendj.io.ASN1; |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.ldap.AddRequestProtocolOp; |
| | | import org.opends.server.protocols.ldap.AddResponseProtocolOp; |
| | | import org.opends.server.protocols.ldap.BindRequestProtocolOp; |
| | |
| | | import org.opends.server.protocols.ldap.ModifyResponseProtocolOp; |
| | | import org.opends.server.protocols.ldap.SearchRequestProtocolOp; |
| | | import org.opends.server.protocols.ldap.SearchResultDoneProtocolOp; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.opends.server.types.Entry; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.opends.server.types.RawAttribute; |
| | | import org.opends.server.types.RawModification; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * A set of test cases for the cancel extended operation handler. |
| | |
| | | "objectClass: top", |
| | | "objectClass: device", |
| | | "cn: test"); |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "objectClass: top", |
| | | "objectClass: device", |
| | | "cn: test"); |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | |
| | | |
| | | |
| | | import static org.opends.server.util.ServerConstants.SASL_MECHANISM_DIGEST_MD5; |
| | | import static org.testng.Assert.assertEquals; |
| | | import static org.testng.Assert.assertFalse; |
| | | import static org.testng.Assert.assertTrue; |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * A set of test cases for the DIGEST-MD5 SASL mechanism handler. |
| | |
| | | "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," + |
| | | "cn=Password Policies,cn=config"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | String[] args = |
| | |
| | | "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," + |
| | | "cn=Password Policies,cn=config"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | String[] args = |
| | |
| | | "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," + |
| | | "cn=Password Policies,cn=config"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | String[] args = |
| | |
| | | "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," + |
| | | "cn=Password Policies,cn=config"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | String[] args = |
| | |
| | | "cn: Test User", |
| | | "userPassword: password"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | String[] args = |
| | |
| | | "cn: Test User", |
| | | "userPassword: password"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | String[] args = |
| | |
| | | "cn: Test User", |
| | | "userPassword: password"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | String[] args = |
| | |
| | | "cn: Test User", |
| | | "userPassword: password"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | String[] args = |
| | |
| | | "cn: Test User", |
| | | "userPassword: password"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | String[] args = |
| | |
| | | "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," + |
| | | "cn=Password Policies,cn=config"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | String[] args = |
| | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | |
| | | |
| | | DeleteOperation deleteOperation = conn.processDelete(e.getName()); |
| | | DeleteOperation deleteOperation = getRootConnection().processDelete(e.getName()); |
| | | assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.admin.server.AdminTestCaseUtils; |
| | | import org.opends.server.admin.std.meta.ExactMatchIdentityMapperCfgDefn; |
| | | import org.opends.server.admin.std.server.ExactMatchIdentityMapperCfg; |
| | | import org.opends.server.api.IdentityMapper; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ModifyOperation; |
| | |
| | | import org.opends.server.protocols.ldap.LDAPAttribute; |
| | | import org.opends.server.protocols.ldap.LDAPModification; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | "sn: Test", |
| | | "cn: Test", |
| | | "userPassword: password"); |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "sn: Test", |
| | | "cn: Test", |
| | | "userPassword: password"); |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "sn: Test", |
| | | "cn: Test", |
| | | "userPassword: password"); |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "sn: Test", |
| | | "cn: Test", |
| | | "userPassword: password"); |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "sn: Test", |
| | | "cn: Test", |
| | | "userPassword: password"); |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | userEntry = TestCaseUtils.makeEntry( |
| | |
| | | "sn: Test", |
| | | "cn: Test", |
| | | "userPassword: password"); |
| | | addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "sn: Bar", |
| | | "cn: Bar", |
| | | "userPassword: password"); |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "sn: Bar", |
| | | "cn: Bar", |
| | | "userPassword: password"); |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "sn: Bar", |
| | | "cn: Bar", |
| | | "userPassword: password"); |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "sn: User", |
| | | "cn: Test User", |
| | | "userPassword: password"); |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | assertNull(mappedEntry); |
| | | |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | // Create a modification to change the map attribute from uid to cn. |
| | | ArrayList<ByteString> values = new ArrayList<ByteString>(); |
| | | values.add(ByteString.valueOf("cn")); |
| | |
| | | "sn: User", |
| | | "cn: Test User", |
| | | "userPassword: password"); |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | assertEquals(mappedEntry.getName(), DN.valueOf("uid=test,o=test")); |
| | | |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | // Create a modification to set the map base DN to "dc=example,dc=com". |
| | | ArrayList<ByteString> values = new ArrayList<ByteString>(); |
| | | values.add(ByteString.valueOf("dc=example,dc=com")); |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.admin.server.AdminTestCaseUtils; |
| | | import org.opends.server.admin.std.meta.ExternalSASLMechanismHandlerCfgDefn; |
| | | import org.opends.server.admin.std.server.ExternalSASLMechanismHandlerCfg; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ModifyOperation; |
| | |
| | | import org.opends.server.tools.LDAPSearch; |
| | | import org.opends.server.tools.LDAPWriter; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.util.Base64; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | |
| | | |
| | | /** |
| | | * A set of test cases for the EXTERNAL SASL mechanism handler. |
| | | */ |
| | |
| | | "givenName: Test", |
| | | "sn: User"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "givenName: Test", |
| | | "sn: User"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "givenName: Test", |
| | | "sn: User"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | String dnStr = "cn=EXTERNAL,cn=SASL Mechanisms,cn=config"; |
| | | String attrName = "ds-cfg-certificate-validation-policy"; |
| | | ArrayList<Modification> mods = new ArrayList<Modification>(); |
| | |
| | | "sn: User", |
| | | "userCertificate;binary:: " + Base64.encode(certBytes)); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "sn: User", |
| | | "userCertificate;binary:: " + Certificate); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "sn: User", |
| | | "userCertificate;binary:: " + Base64.encode(certBytes)); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | InternalClientConnection conn = getRootConnection(); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "sn: User", |
| | | "userCertificate;binary:: " + Certificate); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | InternalClientConnection conn = getRootConnection(); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.io.ASN1; |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.admin.server.AdminTestCaseUtils; |
| | | import org.opends.server.admin.std.meta.PasswordModifyExtendedOperationHandlerCfgDefn; |
| | | import org.opends.server.admin.std.server.PasswordModifyExtendedOperationHandlerCfg; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.*; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.tools.LDAPPasswordModify; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.extensions.ExtensionsConstants.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | "userPassword: password"); |
| | | |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | 0); |
| | | |
| | | // Perform an internal bind to verify the password was actually changed. |
| | | conn = new InternalClientConnection(new AuthenticationInfo()); |
| | | InternalClientConnection conn = new InternalClientConnection(new AuthenticationInfo()); |
| | | BindOperation bindOperation = |
| | | conn.processSimpleBind(userEntry.getName(), |
| | | ByteString.valueOf("newPassword")); |
| | |
| | | "userPassword: password"); |
| | | |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | 0); |
| | | |
| | | // Perform an internal bind to verify the password was actually changed. |
| | | conn = new InternalClientConnection(new AuthenticationInfo()); |
| | | InternalClientConnection conn = new InternalClientConnection(new AuthenticationInfo()); |
| | | BindOperation bindOperation = |
| | | conn.processSimpleBind(userEntry.getName(), |
| | | ByteString.valueOf("newPassword")); |
| | |
| | | "userPassword: password"); |
| | | |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "userPassword: password"); |
| | | |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | 0); |
| | | |
| | | // Perform an internal bind to verify the password was actually changed. |
| | | conn = new InternalClientConnection(new AuthenticationInfo()); |
| | | InternalClientConnection conn = new InternalClientConnection(new AuthenticationInfo()); |
| | | BindOperation bindOperation = |
| | | conn.processSimpleBind(userEntry.getName(), |
| | | ByteString.valueOf("newPassword")); |
| | |
| | | "userPassword: password"); |
| | | |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | 0); |
| | | |
| | | // Perform an internal bind to verify the password was actually changed. |
| | | conn = new InternalClientConnection(new AuthenticationInfo()); |
| | | InternalClientConnection conn = new InternalClientConnection(new AuthenticationInfo()); |
| | | BindOperation bindOperation = |
| | | conn.processSimpleBind(userEntry.getName(), |
| | | ByteString.valueOf("newPassword")); |
| | |
| | | "userPassword: password"); |
| | | |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | 0); |
| | | |
| | | // Perform an internal bind to verify the password was actually changed. |
| | | conn = new InternalClientConnection(new AuthenticationInfo()); |
| | | InternalClientConnection conn = new InternalClientConnection(new AuthenticationInfo()); |
| | | BindOperation bindOperation = |
| | | conn.processSimpleBind(userEntry.getName(), |
| | | ByteString.valueOf("newPassword")); |
| | |
| | | "userPassword: password"); |
| | | |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | 0); |
| | | |
| | | // Perform an internal bind to verify the password was actually changed. |
| | | conn = new InternalClientConnection(new AuthenticationInfo()); |
| | | InternalClientConnection conn = new InternalClientConnection(new AuthenticationInfo()); |
| | | BindOperation bindOperation = |
| | | conn.processSimpleBind(userEntry.getName(), |
| | | ByteString.valueOf("newPassword")); |
| | |
| | | "userPassword: password"); |
| | | |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | 0); |
| | | |
| | | // Perform an internal bind to verify the password was actually changed. |
| | | conn = new InternalClientConnection(new AuthenticationInfo()); |
| | | InternalClientConnection conn = new InternalClientConnection(new AuthenticationInfo()); |
| | | BindOperation bindOperation = |
| | | conn.processSimpleBind(userEntry.getName(), |
| | | ByteString.valueOf("newPassword")); |
| | |
| | | "userPassword: password"); |
| | | |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | 0); |
| | | |
| | | // Perform an internal bind to verify the password was actually changed. |
| | | conn = new InternalClientConnection(new AuthenticationInfo()); |
| | | InternalClientConnection conn = new InternalClientConnection(new AuthenticationInfo()); |
| | | BindOperation bindOperation = |
| | | conn.processSimpleBind(userEntry.getName(), |
| | | ByteString.valueOf("newPassword")); |
| | |
| | | "userPassword: password"); |
| | | |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | 0); |
| | | |
| | | // Perform an internal bind to verify the password was actually changed. |
| | | conn = new InternalClientConnection(new AuthenticationInfo()); |
| | | InternalClientConnection conn = new InternalClientConnection(new AuthenticationInfo()); |
| | | BindOperation bindOperation = |
| | | conn.processSimpleBind(userEntry.getName(), |
| | | ByteString.valueOf("newPassword")); |
| | |
| | | "userPassword: password"); |
| | | |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "userPassword: password"); |
| | | |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | String dnStr = "cn=Default Password Policy,cn=Password Policies,cn=config"; |
| | | String attr = "ds-cfg-allow-pre-encoded-passwords"; |
| | | ArrayList<Modification> mods = new ArrayList<Modification>(); |
| | |
| | | "userPassword: password"); |
| | | |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | /* Make sure preEncoded passwords are rejected */ |
| | |
| | | ArrayList<Modification> mods = new ArrayList<Modification>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create(attr, "false"))); |
| | | ModifyOperation modifyOperation = |
| | | conn.processModify(DN.valueOf(dnStr), mods); |
| | | ModifyOperation modifyOperation = getRootConnection().processModify(DN.valueOf(dnStr), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | String[] args = |
| | |
| | | "userPassword: password"); |
| | | |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | /* Make sure preEncoded passwords are rejected */ |
| | |
| | | ArrayList<Modification> mods = new ArrayList<Modification>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create(attr, "false"))); |
| | | ModifyOperation modifyOperation = |
| | | conn.processModify(DN.valueOf(dnStr), mods); |
| | | ModifyOperation modifyOperation = getRootConnection().processModify(DN.valueOf(dnStr), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | String[] args = |
| | |
| | | "userPassword: password"); |
| | | |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | String dnStr = "cn=Default Password Policy,cn=Password Policies,cn=config"; |
| | | String attr = "ds-cfg-allow-user-password-changes"; |
| | | ArrayList<Modification> mods = new ArrayList<Modification>(); |
| | |
| | | "userPassword: password"); |
| | | |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | String dnStr = "cn=Default Password Policy,cn=Password Policies,cn=config"; |
| | | String attr = "ds-cfg-allow-user-password-changes"; |
| | | ArrayList<Modification> mods = new ArrayList<Modification>(); |
| | |
| | | "userPassword: password"); |
| | | |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | String dnStr = "cn=Default Password Policy,cn=Password Policies,cn=config"; |
| | | String attr = "ds-cfg-password-change-requires-current-password"; |
| | | ArrayList<Modification> mods = new ArrayList<Modification>(); |
| | |
| | | "userPassword: password"); |
| | | |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | String dnStr = "cn=Default Password Policy,cn=Password Policies,cn=config"; |
| | | String attr = "ds-cfg-require-secure-authentication"; |
| | | ArrayList<Modification> mods = new ArrayList<Modification>(); |
| | |
| | | "userPassword: password"); |
| | | |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | String dnStr = "cn=Default Password Policy,cn=Password Policies,cn=config"; |
| | | String attr = "ds-cfg-require-secure-password-changes"; |
| | | ArrayList<Modification> mods = new ArrayList<Modification>(); |
| | |
| | | "userPassword: password"); |
| | | |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | String dnStr = "cn=Default Password Policy,cn=Password Policies,cn=config"; |
| | | String attr = "ds-cfg-require-secure-password-changes"; |
| | | ArrayList<Modification> mods = new ArrayList<Modification>(); |
| | |
| | | "userPassword: password"); |
| | | |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | String dnStr = "cn=Default Password Policy,cn=Password Policies,cn=config"; |
| | | String attr = "ds-cfg-min-password-age"; |
| | | ArrayList<Modification> mods = new ArrayList<Modification>(); |
| | |
| | | "userPassword: password"); |
| | | |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | String dnStr = "cn=Default Password Policy,cn=Password Policies,cn=config"; |
| | | String attr = "ds-cfg-min-password-age"; |
| | | ArrayList<Modification> mods = new ArrayList<Modification>(); |
| | |
| | | "userPassword: password"); |
| | | |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | String dnStr = "cn=Default Password Policy,cn=Password Policies,cn=config"; |
| | | String attr1 = "ds-cfg-max-password-age"; |
| | | String attr2 = "ds-cfg-expire-passwords-without-warning"; |
| | |
| | | "userPassword: password"); |
| | | |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | String dnStr = "cn=Default Password Policy,cn=Password Policies,cn=config"; |
| | | String attr1 = "ds-cfg-max-password-age"; |
| | | String attr2 = "ds-cfg-expire-passwords-without-warning"; |
| | |
| | | "userPassword: password"); |
| | | |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | String dnStr = "cn=Default Password Policy,cn=Password Policies,cn=config"; |
| | | String attr = "ds-cfg-password-generator"; |
| | | ArrayList<Modification> mods = new ArrayList<Modification>(); |
| | |
| | | "userPassword: password"); |
| | | |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | String dnStr = "cn=Default Password Policy,cn=Password Policies,cn=config"; |
| | | String attr = "ds-cfg-password-generator"; |
| | | ArrayList<Modification> mods = new ArrayList<Modification>(); |
| | |
| | | "userPassword: password"); |
| | | |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | String dnStr = "cn=Default Password Policy,cn=Password Policies,cn=config"; |
| | | String attr = "ds-cfg-password-validator"; |
| | | String valDN = |
| | |
| | | "userPassword: password"); |
| | | |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | String dnStr = "cn=Default Password Policy,cn=Password Policies,cn=config"; |
| | | String attr = "ds-cfg-password-validator"; |
| | | String valDN = |
| | |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = conn.processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | | AddOperation addOperation = |
| | | conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(), |
| | | userEntry.getUserAttributes(), |
| | | userEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = conn.processAdd(userEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.api.SASLMechanismHandler; |
| | |
| | | import org.opends.server.tools.LDAPSearch; |
| | | import org.opends.server.types.AuthenticationInfo; |
| | | import org.opends.server.types.Entry; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | /** |
| | | * Tests to ensure that the SASL PLAIN mechanism is loaded and available in |
| | | * the server, and that it reports that it is password based and not secure. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testSASLPlainLoaded() |
| | | { |
| | | SASLMechanismHandler handler = |
| | | DirectoryServer.getSASLMechanismHandler("PLAIN"); |
| | | SASLMechanismHandler<?> handler = DirectoryServer.getSASLMechanismHandler("PLAIN"); |
| | | assertNotNull(handler); |
| | | |
| | | assertTrue(handler.isPasswordBased("PLAIN")); |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testSASLPlainAdvertised() |
| | | throws Exception |
| | | public void testSASLPlainAdvertised() throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalClientConnection conn = getRootConnection(); |
| | | InternalSearchOperation op = |
| | | conn.processSearch(ByteString.empty(), SearchScope.BASE_OBJECT, |
| | | LDAPFilter.decode("(supportedSASLMechanisms=PLAIN)")); |
| | |
| | | "givenName: Test", |
| | | "sn: User", |
| | | "cn: Test User", |
| | | "userPassword: " + password.toString()); |
| | | "userPassword: " + password); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "givenName: Test", |
| | | "sn: User", |
| | | "cn: Test User", |
| | | "userPassword: " + password.toString()); |
| | | "userPassword: " + password); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "givenName: Test", |
| | | "sn: User", |
| | | "cn: Test User", |
| | | "userPassword: " + password.toString()); |
| | | "userPassword: " + password); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "givenName: Test", |
| | | "sn: User", |
| | | "cn: Test User", |
| | | "userPassword: " + password.toString()); |
| | | "userPassword: " + password); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "givenName: Test", |
| | | "sn: User", |
| | | "cn: Test User", |
| | | "userPassword: " + password.toString()); |
| | | "userPassword: " + password); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "cn: Test User", |
| | | "userPassword: password"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | |
| | | |
| | | import java.io.File; |
| | | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.tools.LDAPSearch; |
| | | import org.opends.server.types.Entry; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | |
| | | |
| | | /** |
| | | * A set of test cases for the StartTLS extended operation handler. |
| | | */ |
| | |
| | | "givenName: Test", |
| | | "sn: User"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "givenName: Test", |
| | | "sn: User"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | |
| | | |
| | | import java.net.Socket; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.controls.ProxiedAuthV2Control; |
| | | import org.opends.server.core.AddOperation; |
| | |
| | | import org.opends.server.tools.LDAPAuthenticationHandler; |
| | | import org.opends.server.tools.LDAPReader; |
| | | import org.opends.server.tools.LDAPWriter; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import static org.testng.Assert.*; |
| | | import org.opends.server.types.AuthenticationInfo; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * A set of test cases for the "Who Am I?" extended operation. |
| | |
| | | "cn: Test User", |
| | | "userPassword: password"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOp = conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOp = getRootConnection().processAdd(e); |
| | | assertEquals(addOp.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | | conn = new InternalClientConnection(new AuthenticationInfo(e, false)); |
| | | InternalClientConnection conn = new InternalClientConnection(new AuthenticationInfo(e, false)); |
| | | ExtendedOperation extOp = |
| | | conn.processExtendedOperation(OID_WHO_AM_I_REQUEST, null); |
| | | assertEquals(extOp.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | "cn: Test User", |
| | | "userPassword: password"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOp = conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOp = getRootConnection().processAdd(e); |
| | | assertEquals(addOp.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | |
| | | |
| | | |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.io.ByteArrayInputStream; |
| | | import java.util.ArrayList; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.admin.server.AdminTestCaseUtils; |
| | | import org.opends.server.admin.std.meta.EntryUUIDPluginCfgDefn; |
| | | import org.opends.server.admin.std.server.EntryUUIDPluginCfg; |
| | | import org.opends.server.api.plugin.PluginType; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryConfig; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.LDIFImportConfig; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * This class defines a set of tests for the |
| | |
| | | "objectClass: device", |
| | | "cn: test"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | e = DirectoryConfig.getEntry(e.getName()); |
| | |
| | | "cn: test", |
| | | "entryUUID: " + UUID.randomUUID()); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | e = DirectoryConfig.getEntry(e.getName()); |
| | |
| | | */ |
| | | package org.opends.server.plugins; |
| | | |
| | | |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.admin.server.AdminTestCaseUtils; |
| | | import org.opends.server.admin.std.meta.LastModPluginCfgDefn; |
| | | import org.opends.server.admin.std.server.LastModPluginCfg; |
| | | import org.opends.server.api.plugin.PluginType; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ModifyDNOperation; |
| | |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.DirectoryConfig; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryConfig; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.Modification; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.opends.server.types.RDN; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class defines a set of tests for the |
| | | * org.opends.server.plugins.LastModPlugin class. |
| | |
| | | "objectClass: device", |
| | | "cn: test"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | e = DirectoryConfig.getEntry(e.getName()); |
| | |
| | | "objectClass: device", |
| | | "cn: test"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | | ModifyDNOperation modifyDNOperation = |
| | | conn.processModifyDN(e.getName(), RDN.decode("cn=test2"), false); |
| | | getRootConnection().processModifyDN(e.getName(), RDN.decode("cn=test2"), false); |
| | | assertEquals(modifyDNOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | e = DirectoryConfig.getEntry(DN.valueOf("cn=test2,o=test")); |
| | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.AddOperation; |
| | |
| | | import org.opends.server.protocols.ldap.LDAPFilter; |
| | | import org.opends.server.protocols.ldap.LDAPModification; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @BeforeClass() |
| | | @BeforeClass |
| | | public void startServer() |
| | | throws Exception |
| | | { |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testProcessAdd1() |
| | | throws Exception |
| | | { |
| | |
| | | values.add(ByteString.valueOf("test")); |
| | | attrs.add(new LDAPAttribute("cn", values)); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = conn.processAdd(dn, attrs); |
| | | AddOperation addOperation = getRootConnection().processAdd(dn, attrs); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testProcessAdd2() |
| | | throws Exception |
| | | { |
| | |
| | | "objectClass: device", |
| | | "cn: test"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testProcessSimpleBind1() |
| | | throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalClientConnection conn = getRootConnection(); |
| | | BindOperation bindOperation = |
| | | conn.processSimpleBind(ByteString.valueOf("cn=Directory Manager"), |
| | | ByteString.valueOf("password")); |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testProcessSimpleBind2() |
| | | throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalClientConnection conn = getRootConnection(); |
| | | BindOperation bindOperation = |
| | | conn.processSimpleBind(DN.valueOf("cn=Directory Manager"), |
| | | ByteString.valueOf("password")); |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testProcessSASLBind1() |
| | | throws Exception |
| | | { |
| | | ByteString creds = |
| | | ByteString.valueOf("\u0000dn:cn=Directory Manager\u0000password"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalClientConnection conn = getRootConnection(); |
| | | BindOperation bindOperation = |
| | | conn.processSASLBind(ByteString.empty(), "PLAIN", creds); |
| | | assertEquals(bindOperation.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testProcessSASLBind2() |
| | | throws Exception |
| | | { |
| | | ByteString creds = |
| | | ByteString.valueOf("\u0000dn:cn=Directory Manager\u0000password"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalClientConnection conn = getRootConnection(); |
| | | BindOperation bindOperation = |
| | | conn.processSASLBind(DN.rootDN(), "PLAIN", creds); |
| | | assertEquals(bindOperation.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testProcessCompare1() |
| | | throws Exception |
| | | { |
| | |
| | | "objectClass: device", |
| | | "cn: test"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | CompareOperation compareOperation = |
| | | conn.processCompare(ByteString.valueOf("cn=test,o=test"), "cn", |
| | | ByteString.valueOf("test")); |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testProcessCompare2() |
| | | throws Exception |
| | | { |
| | |
| | | "objectClass: device", |
| | | "cn: test"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | CompareOperation compareOperation = |
| | | conn.processCompare(DN.valueOf("cn=test,o=test"), |
| | | DirectoryServer.getAttributeType("cn", true), |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testProcessDelete1() |
| | | throws Exception |
| | | { |
| | |
| | | "objectClass: device", |
| | | "cn: test"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | | DeleteOperation deleteOperation = |
| | | conn.processDelete(ByteString.valueOf("cn=test,o=test")); |
| | | getRootConnection().processDelete(ByteString.valueOf("cn=test,o=test")); |
| | | assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testProcessDelete2() |
| | | throws Exception |
| | | { |
| | |
| | | "objectClass: device", |
| | | "cn: test"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | | DeleteOperation deleteOperation = |
| | | conn.processDelete(DN.valueOf("cn=test,o=test")); |
| | | getRootConnection().processDelete(DN.valueOf("cn=test,o=test")); |
| | | assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testProcessExtendedOperation() |
| | | throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalClientConnection conn = getRootConnection(); |
| | | ExtendedOperation extendedOperation = |
| | | conn.processExtendedOperation(OID_WHO_AM_I_REQUEST, null); |
| | | assertEquals(extendedOperation.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testProcessModify1() |
| | | throws Exception |
| | | { |
| | |
| | | "objectClass: device", |
| | | "cn: test"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | mods.add(new LDAPModification(ModificationType.REPLACE, |
| | | new LDAPAttribute("description", values))); |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | ModifyOperation modifyOperation = |
| | | conn.processModify(ByteString.valueOf("cn=test,o=test"), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testProcessModify2() |
| | | throws Exception |
| | | { |
| | |
| | | "objectClass: device", |
| | | "cn: test"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | | ArrayList<Modification> mods = new ArrayList<Modification>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create("description", "This is a test"))); |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | ModifyOperation modifyOperation = |
| | | conn.processModify(DN.valueOf("cn=test,o=test"), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testProcessModifyDN1() |
| | | throws Exception |
| | | { |
| | |
| | | "objectClass: device", |
| | | "cn: test"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | ModifyDNOperation modifyDNOperation = |
| | | conn.processModifyDN(ByteString.valueOf("cn=test,o=test"), |
| | | ByteString.valueOf("cn=test2"), true); |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testProcessModifyDN2() |
| | | throws Exception |
| | | { |
| | |
| | | "objectClass: device", |
| | | "cn: test"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | ModifyDNOperation modifyDNOperation = |
| | | conn.processModifyDN(ByteString.valueOf("cn=test,o=test"), |
| | | ByteString.valueOf("cn=test2"), true, |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testProcessModifyDN3() |
| | | throws Exception |
| | | { |
| | |
| | | "objectClass: device", |
| | | "cn: test"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | InternalClientConnection conn = getRootConnection(); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testProcessModifyDN4() |
| | | throws Exception |
| | | { |
| | |
| | | "objectClass: device", |
| | | "cn: test"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | InternalClientConnection conn = getRootConnection(); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testProcessSearch1() |
| | | throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalClientConnection conn = getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(ByteString.valueOf(""), SearchScope.BASE_OBJECT, |
| | | LDAPFilter.decode("(objectClass=*)")); |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testProcessSearch2() |
| | | throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalClientConnection conn = getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(ByteString.valueOf(""), SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testProcessSearch3() |
| | | throws Exception |
| | | { |
| | | TestInternalSearchListener searchListener = |
| | | new TestInternalSearchListener(); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalClientConnection conn = getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(ByteString.valueOf(""), SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testProcessSearch4() |
| | | throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalClientConnection conn = getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(DN.rootDN(), SearchScope.BASE_OBJECT, |
| | | SearchFilter.createFilterFromString("(objectClass=*)")); |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testProcessSearch5() |
| | | throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalClientConnection conn = getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(DN.rootDN(), SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testProcessSearch6() |
| | | throws Exception |
| | | { |
| | | TestInternalSearchListener searchListener = |
| | | new TestInternalSearchListener(); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalClientConnection conn = getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(DN.rootDN(), SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSendSearchReference() |
| | | throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalClientConnection conn = getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(ByteString.valueOf(""), SearchScope.BASE_OBJECT, |
| | | LDAPFilter.decode("(objectClass=*)")); |
| | |
| | | /** |
| | | * Tests the <CODE>sendIntermediateResponseMessage</CODE> method. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSendIntermediateResponseMessage() |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | assertFalse(conn.sendIntermediateResponseMessage(null)); |
| | | assertFalse(getRootConnection().sendIntermediateResponseMessage(null)); |
| | | } |
| | | |
| | | |
| | |
| | | /** |
| | | * Tests the <CODE>disconnect</CODE> method. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testDisconnect() |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | conn.disconnect(DisconnectReason.OTHER, false, |
| | | getRootConnection().disconnect(DisconnectReason.OTHER, false, |
| | | LocalizableMessage.raw("testDisconnect")); |
| | | } |
| | | |
| | |
| | | /** |
| | | * Tests the <CODE>removeOperationInProgress</CODE> method. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testRemoveOperationInProgress() |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | assertFalse(conn.removeOperationInProgress(1)); |
| | | assertFalse(getRootConnection().removeOperationInProgress(1)); |
| | | } |
| | | |
| | | |
| | |
| | | /** |
| | | * Tests the <CODE>cancelOperation</CODE> method. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testCancelOperation() |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | CancelResult cancelResult = |
| | | conn.cancelOperation(1, |
| | | getRootConnection().cancelOperation(1, |
| | | new CancelRequest(true, LocalizableMessage.raw("testCancelOperation"))); |
| | | assertEquals(cancelResult.getResultCode(), ResultCode.CANNOT_CANCEL); |
| | | } |
| | |
| | | /** |
| | | * Tests the <CODE>cancelAllOperations</CODE> method. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testCancelAllOperations() |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | conn.cancelAllOperations(new CancelRequest(true, |
| | | getRootConnection().cancelAllOperations(new CancelRequest(true, |
| | | LocalizableMessage.raw("testCancelOperation"))); |
| | | } |
| | | |
| | |
| | | /** |
| | | * Tests the <CODE>cancelAllOperationsExcept</CODE> method. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testCancelAllOperationsExcept() |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | conn.cancelAllOperationsExcept( |
| | | getRootConnection().cancelAllOperationsExcept( |
| | | new CancelRequest(true, LocalizableMessage.raw("testCancelOperation")), 1); |
| | | } |
| | | |
| | |
| | | /** |
| | | * Tests the <CODE>toString</CODE> method. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testToString() |
| | | { |
| | | StringBuilder buffer = new StringBuilder(); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | conn.toString(buffer); |
| | | |
| | | assertFalse(buffer.toString().equals("")); |
| | | assertFalse(getRootConnection().toString().equals("")); |
| | | } |
| | | } |
| | | |
| | |
| | | import java.util.LinkedHashSet; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.core.AddOperation; |
| | |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.ldap.LDAPFilter; |
| | | import org.opends.server.types.Attribute; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.DN; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.opends.server.types.Entry; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.types.SearchResultEntry; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | public class LDAPSyntaxTest extends AttributeSyntaxTest |
| | | { |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected AttributeSyntax<?> getRule() |
| | | { |
| | | return new LDAPSyntaxDescriptionSyntax(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name="acceptableValues") |
| | | public Object[][] createAcceptableValues() |
| | |
| | | "cn: syntax-test", |
| | | "sn: xyz", |
| | | "test-attr-regex: invalid regex"); |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | AddOperation addOperation = conn.processAdd(entry.getName(), |
| | | entry.getObjectClasses(), |
| | | entry.getUserAttributes(), |
| | | entry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(entry); |
| | | assertEquals(addOperation.getResultCode(), |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX); |
| | | |
| | |
| | | "cn: syntax-test", |
| | | "sn: xyz", |
| | | "test-attr-enum: arbit-day"); |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | AddOperation addOperation = conn.processAdd(entry.getName(), |
| | | entry.getObjectClasses(), |
| | | entry.getUserAttributes(), |
| | | entry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(entry); |
| | | assertEquals(addOperation.getResultCode(), |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX); |
| | | |
| | |
| | | |
| | | |
| | | |
| | | //Parses the OID from the syntax defitions. |
| | | /** Parses the OID from the syntax defitions. */ |
| | | private String getOIDFromLdapSyntax(String valueStr) |
| | | { |
| | | int pos = 0; |
| | | int length = valueStr.length(); |
| | | |
| | | while ((pos < length) && (valueStr.charAt(pos) == ' ')) |
| | | while (pos < length && valueStr.charAt(pos) == ' ') |
| | | { |
| | | pos++; |
| | | } |
| | | // The next character must be an open parenthesis. If it is not, then that |
| | | // is an error. |
| | | char c = valueStr.charAt(pos++); |
| | | assertEquals(valueStr.charAt(pos++), '('); |
| | | |
| | | // Skip over any spaces immediately following the opening parenthesis. |
| | | while ((pos < length) && ((c = valueStr.charAt(pos)) == ' ')) |
| | | while (pos < length && valueStr.charAt(pos) == ' ') |
| | | { |
| | | pos++; |
| | | } |
| | | int oidStartPos = pos; |
| | | |
| | | while ((pos < length) && ((c = valueStr.charAt(pos)) != ' ') |
| | | && (c = valueStr.charAt(pos)) != ')') |
| | | while (pos < length |
| | | && valueStr.charAt(pos) != ' ' |
| | | && valueStr.charAt(pos) != ')') |
| | | { |
| | | pos++; |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | //Adds a substitutionsyntax to the schema. |
| | | /** Adds a substitutionsyntax to the schema. */ |
| | | private void addSubtitutionSyntax() throws Exception |
| | | { |
| | | //Add the substitution syntax for an unimplemented syntax. |
| | |
| | | |
| | | |
| | | |
| | | //Deletes the substitutionSyntax from the schema. |
| | | /** Deletes the substitutionSyntax from the schema. */ |
| | | private void deleteSubstitutionSyntax() throws Exception |
| | | { |
| | | //delete the substitution syntax. |
| | |
| | | } |
| | | |
| | | |
| | | //Adds a regex syntax to the schema. |
| | | /** Adds a regex syntax to the schema. */ |
| | | private void addRegexSyntax() throws Exception |
| | | { |
| | | //Add the substitution syntax for an unimplemented syntax. |
| | |
| | | |
| | | |
| | | |
| | | //Deletes the regex syntax from the schema. |
| | | /** Deletes the regex syntax from the schema. */ |
| | | private void deleteRegexSyntax() throws Exception |
| | | { |
| | | //delete the substitution syntax. |
| | |
| | | |
| | | |
| | | |
| | | //Adds an enum syntax to the schema. |
| | | /** Adds an enum syntax to the schema. */ |
| | | private void addEnumSyntax() throws Exception |
| | | { |
| | | //Add the enum syntax. |
| | |
| | | |
| | | |
| | | |
| | | //Deletes the enum syntax from the schema. |
| | | /** Deletes the enum syntax from the schema. */ |
| | | private void deleteEnumSyntax() throws Exception |
| | | { |
| | | int resultCode = TestCaseUtils.applyModifications(true, |
| | |
| | | |
| | | import java.util.Set; |
| | | |
| | | import org.assertj.core.api.SoftAssertions; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.DirectoryServerTestCase; |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.types.AttributeParser; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.SearchFilter; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | |
| | | /** |
| | | * Add a task definition and check that it completes with the expected state. |
| | | * The task is expected to complete quickly and the timeout is set |
| | | * accordingly. |
| | | * @param taskEntry The task entry. |
| | | * @param expectedState The expected completion state of the task. |
| | | * @throws Exception If the test fails. |
| | | */ |
| | | protected void testTask(Entry taskEntry, TaskState expectedState) |
| | | throws Exception |
| | | { |
| | | testTask(taskEntry, expectedState, 30); |
| | | } |
| | | |
| | | /** |
| | | * Add a task definition and check that it completes with the expected state. |
| | | * @param taskEntry The task entry. |
| | | * @param expectedState The expected completion state of the task. |
| | | * @param timeout The number of seconds to wait for the task to complete. |
| | |
| | | protected void testTask(Entry taskEntry, TaskState expectedState, int timeout) |
| | | throws Exception |
| | | { |
| | | InternalClientConnection connection = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalClientConnection connection = getRootConnection(); |
| | | |
| | | // Add the task. |
| | | AddOperation addOperation = |
| | | connection.processAdd(taskEntry.getName(), |
| | | taskEntry.getObjectClasses(), |
| | | taskEntry.getUserAttributes(), |
| | | taskEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = connection.processAdd(taskEntry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS, |
| | | "Add of the task definition was not successful"); |
| | | |
| | |
| | | Entry resultEntry = null; |
| | | String completionTime = null; |
| | | long startMillisecs = System.currentTimeMillis(); |
| | | boolean timedOut; |
| | | do |
| | | { |
| | | Thread.sleep(100); |
| | | InternalSearchOperation searchOperation = |
| | | connection.processSearch(taskEntry.getName(), |
| | | SearchScope.BASE_OBJECT, |
| | | filter); |
| | | try |
| | | { |
| | | resultEntry = searchOperation.getSearchEntries().getFirst(); |
| | | } catch (Exception e) |
| | | { |
| | | // FIXME How is this possible? Must be issue 858. |
| | | // fail("Task entry was not returned from the search."); |
| | | continue; |
| | | } |
| | | completionTime = resultEntry.parseAttribute( |
| | | ATTR_TASK_COMPLETION_TIME.toLowerCase()).asString(); |
| | | |
| | | if (completionTime == null) |
| | | { |
| | | if (System.currentTimeMillis() - startMillisecs > 1000*timeout) |
| | | { |
| | | break; |
| | | } |
| | | Thread.sleep(10); |
| | | } |
| | | } while (completionTime == null); |
| | | |
| | | if (completionTime == null) |
| | | { |
| | | fail("The task had not completed after " + timeout + " seconds."); |
| | | resultEntry = searchOperation.getSearchEntries().getFirst(); |
| | | completionTime = parseAttribute(resultEntry, ATTR_TASK_COMPLETION_TIME).asString(); |
| | | timedOut = System.currentTimeMillis() - startMillisecs > 1000 * timeout; |
| | | } |
| | | while (completionTime == null && timedOut); |
| | | |
| | | assertNotNull(completionTime, "The task had not completed after " + timeout + " seconds."); |
| | | |
| | | // Check that the task state is as expected. |
| | | String stateString = |
| | | resultEntry.parseAttribute(ATTR_TASK_STATE.toLowerCase()).asString(); |
| | | String stateString = parseAttribute(resultEntry, ATTR_TASK_STATE).asString(); |
| | | TaskState taskState = TaskState.fromString(stateString); |
| | | assertEquals(taskState, expectedState, |
| | | "The task completed in an unexpected state"); |
| | | |
| | | // Check that the task contains some log messages. |
| | | Set<String> logMessages = resultEntry.parseAttribute( |
| | | ATTR_TASK_LOG_MESSAGES.toLowerCase()).asSetOfString(); |
| | | if (taskState != TaskState.COMPLETED_SUCCESSFULLY && |
| | | logMessages.size() == 0) |
| | | { |
| | | fail("No log messages were written to the task entry on a failed task"); |
| | | } |
| | | Set<String> logMessages = parseAttribute(resultEntry, ATTR_TASK_LOG_MESSAGES).asSetOfString(); |
| | | final String msg = "No log messages were written to the task entry on a failed task"; |
| | | SoftAssertions softly = new SoftAssertions(); |
| | | softly.assertThat(taskState).as(msg).isNotEqualTo(TaskState.COMPLETED_SUCCESSFULLY); |
| | | softly.assertThat(logMessages).as(msg).isNotEmpty(); |
| | | softly.assertAll(); |
| | | } |
| | | |
| | | |
| | | private AttributeParser parseAttribute(Entry resultEntry, String attrName) |
| | | { |
| | | return resultEntry.parseAttribute(attrName.toLowerCase()); |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the specified task from the server, regardless of its current |
| | | * state. |
| | | * |
| | | * @param taskEntryDN The DN of the entry for the task to retrieve. |
| | | * |
| | | * @return The requested task entry. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test(enabled=false) // This isn't a test method, but TestNG thinks it is. |
| | | public static Task getTask(DN taskEntryDN) |
| | | throws Exception |
| | | public static Task getTask(DN taskEntryDN) throws Exception |
| | | { |
| | | TaskBackend taskBackend = |
| | | (TaskBackend) DirectoryServer.getBackend(DN.valueOf("cn=tasks")); |
| | |
| | | if (task == null) |
| | | { |
| | | long stopWaitingTime = System.currentTimeMillis() + 10000L; |
| | | while ((task == null) && (System.currentTimeMillis() < stopWaitingTime)) |
| | | while (task == null && System.currentTimeMillis() < stopWaitingTime) |
| | | { |
| | | Thread.sleep(10); |
| | | task = taskBackend.getScheduledTask(taskEntryDN); |
| | | } |
| | | } |
| | | |
| | | if (task == null) |
| | | { |
| | | throw new AssertionError("There is no such task " + |
| | | taskEntryDN.toString()); |
| | | } |
| | | |
| | | assertNotNull(task, "There is no such task " + taskEntryDN); |
| | | return task; |
| | | } |
| | | |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test(enabled=false) // This isn't a test method, but TestNG thinks it is. |
| | | public static Task getCompletedTask(DN taskEntryDN) |
| | | throws Exception |
| | | public static Task getCompletedTask(DN taskEntryDN) throws Exception |
| | | { |
| | | Task task = getTask(taskEntryDN); |
| | | |
| | | if (! TaskState.isDone(task.getTaskState())) |
| | | { |
| | | long stopWaitingTime = System.currentTimeMillis() + 20000L; |
| | | while ((! TaskState.isDone(task.getTaskState())) && |
| | | (System.currentTimeMillis() < stopWaitingTime)) |
| | | while (! TaskState.isDone(task.getTaskState()) && |
| | | System.currentTimeMillis() < stopWaitingTime) |
| | | { |
| | | Thread.sleep(10); |
| | | } |
| | | } |
| | | |
| | | if (! TaskState.isDone(task.getTaskState())) |
| | | { |
| | | throw new AssertionError("Task " + taskEntryDN.toString() + |
| | | " did not complete in a timely manner."); |
| | | } |
| | | |
| | | assertTrue(TaskState.isDone(task.getTaskState()), "Task " + taskEntryDN + " did not complete in a timely manner."); |
| | | return task; |
| | | } |
| | | } |
| | |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS. |
| | | */ |
| | | |
| | | |
| | | package org.opends.server.tasks; |
| | | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | import org.testng.annotations.AfterClass; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.opends.server.api.TestTaskListener; |
| | | import java.io.File; |
| | | import java.util.UUID; |
| | | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.backends.task.TaskState; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.testng.annotations.AfterClass; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.opends.server.api.TestTaskListener.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.util.UUID; |
| | | import java.io.File; |
| | | |
| | | /** |
| | | * Tests the backup and restore tasks. |
| | | */ |
| | | @SuppressWarnings("javadoc") |
| | | public class TestBackupAndRestore extends TasksTestCase |
| | | { |
| | | @BeforeClass |
| | | public final void setUp() throws Exception { |
| | | TestCaseUtils.startServer(); |
| | | TestTaskListener.registerListeners(); |
| | | registerListeners(); |
| | | } |
| | | |
| | | |
| | | @AfterClass |
| | | public final void cleanUp() throws Exception { |
| | | TestTaskListener.deregisterListeners(); |
| | | deregisterListeners(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Backup and restore tasks test data provider. |
| | | * |
| | |
| | | { |
| | | // A valid backup task. |
| | | TestCaseUtils.makeEntry( |
| | | "dn: ds-task-id=" + UUID.randomUUID() + |
| | | ",cn=Scheduled Tasks,cn=Tasks", |
| | | "dn: ds-task-id=" + UUID.randomUUID() + ",cn=Scheduled Tasks,cn=Tasks", |
| | | "objectclass: top", |
| | | "objectclass: ds-task", |
| | | "objectclass: ds-task-backup", |
| | |
| | | // Incompatible settings of backup-directory-path and |
| | | // incremental-base-id. |
| | | TestCaseUtils.makeEntry( |
| | | "dn: ds-task-id=" + UUID.randomUUID() + |
| | | ",cn=Scheduled Tasks,cn=Tasks", |
| | | "dn: ds-task-id=" + UUID.randomUUID() + ",cn=Scheduled Tasks,cn=Tasks", |
| | | "objectclass: top", |
| | | "objectclass: ds-task", |
| | | "objectclass: ds-task-backup", |
| | |
| | | { |
| | | // Incompatible settings for backend-id and backup-all. |
| | | TestCaseUtils.makeEntry( |
| | | "dn: ds-task-id=" + UUID.randomUUID() + |
| | | ",cn=Scheduled Tasks,cn=Tasks", |
| | | "dn: ds-task-id=" + UUID.randomUUID() + ",cn=Scheduled Tasks,cn=Tasks", |
| | | "objectclass: top", |
| | | "objectclass: ds-task", |
| | | "objectclass: ds-task-backup", |
| | |
| | | { |
| | | // Neither of backend-id or backup-all specified. |
| | | TestCaseUtils.makeEntry( |
| | | "dn: ds-task-id=" + UUID.randomUUID() + |
| | | ",cn=Scheduled Tasks,cn=Tasks", |
| | | "dn: ds-task-id=" + UUID.randomUUID() + ",cn=Scheduled Tasks,cn=Tasks", |
| | | "objectclass: top", |
| | | "objectclass: ds-task", |
| | | "objectclass: ds-task-backup", |
| | |
| | | { |
| | | // Incompatible settings for incremental and incremental-base-id. |
| | | TestCaseUtils.makeEntry( |
| | | "dn: ds-task-id=" + UUID.randomUUID() + |
| | | ",cn=Scheduled Tasks,cn=Tasks", |
| | | "dn: ds-task-id=" + UUID.randomUUID() + ",cn=Scheduled Tasks,cn=Tasks", |
| | | "objectclass: top", |
| | | "objectclass: ds-task", |
| | | "objectclass: ds-task-backup", |
| | |
| | | { |
| | | // Incompatible settings for hash and sign-hash. |
| | | TestCaseUtils.makeEntry( |
| | | "dn: ds-task-id=" + UUID.randomUUID() + |
| | | ",cn=Scheduled Tasks,cn=Tasks", |
| | | "dn: ds-task-id=" + UUID.randomUUID() + ",cn=Scheduled Tasks,cn=Tasks", |
| | | "objectclass: top", |
| | | "objectclass: ds-task", |
| | | "objectclass: ds-task-backup", |
| | |
| | | { |
| | | // Specified backend does not support backup. |
| | | TestCaseUtils.makeEntry( |
| | | "dn: ds-task-id=" + UUID.randomUUID() + |
| | | ",cn=Scheduled Tasks,cn=Tasks", |
| | | "dn: ds-task-id=" + UUID.randomUUID() + ",cn=Scheduled Tasks,cn=Tasks", |
| | | "objectclass: top", |
| | | "objectclass: ds-task", |
| | | "objectclass: ds-task-backup", |
| | |
| | | { |
| | | // A valid restore task. |
| | | TestCaseUtils.makeEntry( |
| | | "dn: ds-task-id=" + UUID.randomUUID() + |
| | | ",cn=Scheduled Tasks,cn=Tasks", |
| | | "dn: ds-task-id=" + UUID.randomUUID() + ",cn=Scheduled Tasks,cn=Tasks", |
| | | "objectclass: top", |
| | | "objectclass: ds-task", |
| | | "objectclass: ds-task-restore", |
| | | "ds-task-class-name: org.opends.server.tasks.RestoreTask", |
| | | "ds-backup-directory-path: bak" + File.separator + |
| | | "userRoot" |
| | | "ds-backup-directory-path: bak" + File.separator + "userRoot" |
| | | ), |
| | | TaskState.COMPLETED_SUCCESSFULLY |
| | | }, |
| | | { |
| | | // Non-existent restore directory-path. |
| | | TestCaseUtils.makeEntry( |
| | | "dn: ds-task-id=" + UUID.randomUUID() + |
| | | ",cn=Scheduled Tasks,cn=Tasks", |
| | | "dn: ds-task-id=" + UUID.randomUUID() + ",cn=Scheduled Tasks,cn=Tasks", |
| | | "objectclass: top", |
| | | "objectclass: ds-task", |
| | | "objectclass: ds-task-restore", |
| | |
| | | { |
| | | // Invalid restore directory-path. |
| | | TestCaseUtils.makeEntry( |
| | | "dn: ds-task-id=" + UUID.randomUUID() + |
| | | ",cn=Scheduled Tasks,cn=Tasks", |
| | | "dn: ds-task-id=" + UUID.randomUUID() + ",cn=Scheduled Tasks,cn=Tasks", |
| | | "objectclass: top", |
| | | "objectclass: ds-task", |
| | | "objectclass: ds-task-restore", |
| | |
| | | { |
| | | // Invalid restore backup-id. |
| | | TestCaseUtils.makeEntry( |
| | | "dn: ds-task-id=" + UUID.randomUUID() + |
| | | ",cn=Scheduled Tasks,cn=Tasks", |
| | | "dn: ds-task-id=" + UUID.randomUUID() + ",cn=Scheduled Tasks,cn=Tasks", |
| | | "objectclass: top", |
| | | "objectclass: ds-task", |
| | | "objectclass: ds-task-restore", |
| | | "ds-task-class-name: org.opends.server.tasks.RestoreTask", |
| | | "ds-backup-directory-path: bak" + File.separator + |
| | | "userRoot", |
| | | "ds-backup-directory-path: bak" + File.separator + "userRoot", |
| | | "ds-backup-id: monday" |
| | | ), |
| | | TaskState.STOPPED_BY_ERROR |
| | |
| | | }; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Test that various backup and restore task definitions complete with the |
| | | * expected state. |
| | |
| | | * @param expectedState The expected completion state of the task. |
| | | */ |
| | | @Test(dataProvider = "backups") |
| | | public void testBackups(Entry taskEntry, TaskState expectedState) |
| | | throws Exception |
| | | public void testBackups(Entry taskEntry, TaskState expectedState) throws Exception |
| | | { |
| | | int backupBeginCount = TestTaskListener.backupBeginCount.get(); |
| | | int backupEndCount = TestTaskListener.backupEndCount.get(); |
| | | int restoreBeginCount = TestTaskListener.restoreBeginCount.get(); |
| | | int restoreEndCount = TestTaskListener.restoreEndCount.get(); |
| | | final int backupBeginCountStart = backupBeginCount.get(); |
| | | final int backupEndCountStart = backupEndCount.get(); |
| | | final int restoreBeginCountStart = restoreBeginCount.get(); |
| | | final int restoreEndCountStart = restoreEndCount.get(); |
| | | |
| | | ObjectClass backupClass = |
| | | DirectoryServer.getObjectClass("ds-task-backup", true); |
| | | ObjectClass backupClass = DirectoryServer.getObjectClass("ds-task-backup", true); |
| | | |
| | | testTask(taskEntry, expectedState); |
| | | if ((expectedState == TaskState.COMPLETED_SUCCESSFULLY) || |
| | | (expectedState == TaskState.COMPLETED_WITH_ERRORS)) |
| | | testTask(taskEntry, expectedState, 30); |
| | | if (expectedState == TaskState.COMPLETED_SUCCESSFULLY || |
| | | expectedState == TaskState.COMPLETED_WITH_ERRORS) |
| | | { |
| | | if (taskEntry.hasObjectClass(backupClass)) |
| | | { |
| | | // The backup task can back up multiple backends at the same time, so |
| | | // we the count may be incremented by more than one in those cases. |
| | | assertTrue(TestTaskListener.backupBeginCount.get() > backupBeginCount); |
| | | assertTrue(TestTaskListener.backupEndCount.get() > backupEndCount); |
| | | assertEquals(TestTaskListener.backupBeginCount.get(), |
| | | TestTaskListener.backupEndCount.get()); |
| | | assertThat(backupBeginCount.get()).isGreaterThan(backupBeginCountStart); |
| | | assertThat(backupEndCount.get()).isGreaterThan(backupEndCountStart); |
| | | assertEquals(backupBeginCount.get(), backupEndCount.get()); |
| | | } |
| | | else |
| | | { |
| | | assertEquals(TestTaskListener.restoreBeginCount.get(), |
| | | (restoreBeginCount+1)); |
| | | assertEquals(TestTaskListener.restoreEndCount.get(), |
| | | (restoreEndCount+1)); |
| | | assertEquals(TestTaskListener.restoreBeginCount.get(), |
| | | TestTaskListener.restoreEndCount.get()); |
| | | assertEquals(restoreBeginCount.get(), restoreBeginCountStart + 1); |
| | | assertEquals(restoreEndCount.get(), restoreEndCountStart + 1); |
| | | assertEquals(restoreBeginCount.get(), restoreEndCount.get()); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | package org.opends.server.tasks; |
| | | |
| | | import org.testng.annotations.Test; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.AfterClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.api.TestTaskListener; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.backends.task.TaskState; |
| | | |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.io.File; |
| | | import java.util.UUID; |
| | | |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.api.TestTaskListener; |
| | | import org.opends.server.backends.task.TaskState; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.testng.annotations.AfterClass; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * Tests invocation of the import and export tasks, but does not aim to |
| | |
| | | public void testBadTask(Entry taskEntry, ResultCode resultCode) |
| | | throws Exception |
| | | { |
| | | InternalClientConnection connection = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | // Add the task. |
| | | AddOperation addOperation = |
| | | connection.processAdd(taskEntry.getName(), |
| | | taskEntry.getObjectClasses(), |
| | | taskEntry.getUserAttributes(), |
| | | taskEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(taskEntry); |
| | | assertEquals(addOperation.getResultCode(), resultCode); |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.tools; |
| | | |
| | | |
| | | |
| | | import java.io.File; |
| | | import java.net.InetAddress; |
| | | import java.net.Socket; |
| | |
| | | import java.util.List; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.api.SASLMechanismHandler; |
| | | import org.opends.server.controls.PasswordPolicyRequestControl; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.extensions.AnonymousSASLMechanismHandler; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import static org.testng.Assert.*; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.LDAPException; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * A set of test cases for the LDAP authentication handler. |
| | |
| | | "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," + |
| | | "cn=Password Policies,cn=config"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | | SASLMechanismHandler cramMD5Handler = |
| | | SASLMechanismHandler<?> cramMD5Handler = |
| | | DirectoryServer.getSASLMechanismHandler("CRAM-MD5"); |
| | | DirectoryServer.deregisterSASLMechanismHandler("CRAM-MD5"); |
| | | |
| | |
| | | "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," + |
| | | "cn=Password Policies,cn=config"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," + |
| | | "cn=Password Policies,cn=config"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "cn: Test User", |
| | | "userPassword: password"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," + |
| | | "cn=Password Policies,cn=config"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," + |
| | | "cn=Password Policies,cn=config"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | | SASLMechanismHandler digestMD5Handler = |
| | | SASLMechanismHandler<?> digestMD5Handler = |
| | | DirectoryServer.getSASLMechanismHandler("DIGEST-MD5"); |
| | | DirectoryServer.deregisterSASLMechanismHandler("DIGEST-MD5"); |
| | | |
| | |
| | | "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," + |
| | | "cn=Password Policies,cn=config"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," + |
| | | "cn=Password Policies,cn=config"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," + |
| | | "cn=Password Policies,cn=config"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," + |
| | | "cn=Password Policies,cn=config"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "cn: Test User", |
| | | "userPassword: password"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," + |
| | | "cn=Password Policies,cn=config"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "sn: User", |
| | | "cn: Test User"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | | SASLMechanismHandler externalHandler = |
| | | SASLMechanismHandler<?> externalHandler = |
| | | DirectoryServer.getSASLMechanismHandler("EXTERNAL"); |
| | | DirectoryServer.deregisterSASLMechanismHandler("EXTERNAL"); |
| | | |
| | |
| | | "sn: User", |
| | | "cn: Test User"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "sn: User", |
| | | "cn: Test User"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | | SASLMechanismHandler externalHandler = |
| | | SASLMechanismHandler<?> externalHandler = |
| | | DirectoryServer.getSASLMechanismHandler("EXTERNAL"); |
| | | DirectoryServer.deregisterSASLMechanismHandler("EXTERNAL"); |
| | | |
| | |
| | | "sn: User", |
| | | "cn: Test User"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "cn: Test User", |
| | | "userPassword: password"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | | SASLMechanismHandler plainHandler = |
| | | SASLMechanismHandler<?> plainHandler = |
| | | DirectoryServer.getSASLMechanismHandler("PLAIN"); |
| | | DirectoryServer.deregisterSASLMechanismHandler("PLAIN"); |
| | | |
| | |
| | | "cn: Test User", |
| | | "userPassword: password"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "cn: Test User", |
| | | "userPassword: password"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "cn: Test User", |
| | | "userPassword: password"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "cn: Test User", |
| | | "userPassword: password"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," + |
| | | "cn=Password Policies,cn=config"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," + |
| | | "cn=Password Policies,cn=config"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "sn: User", |
| | | "cn: Test User"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "cn: Test User", |
| | | "userPassword: password"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | */ |
| | | package org.opends.server.tools; |
| | | |
| | | |
| | | |
| | | import java.io.File; |
| | | import java.io.FileWriter; |
| | | import java.util.ArrayList; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.util.Base64; |
| | | import org.opends.server.util.StaticUtils; |
| | | import org.testng.annotations.AfterClass; |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.ldap.LDAPResultCode.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | |
| | | |
| | | /** |
| | | * A set of test cases for the LDAPCompare tool. |
| | | */ |
| | |
| | | public void testMultipleCompareAllTrue() throws Exception |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | Backend memoryBackend = |
| | | Backend<?> memoryBackend = |
| | | DirectoryServer.getBackend(TestCaseUtils.TEST_BACKEND_ID); |
| | | String dn1 = "arg=success,o=test1,o=test"; |
| | | String dn2 = "arg=success,o=test2,o=test"; |
| | |
| | | public void testMultipleCompareOneCompareIsFalse() throws Exception |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | Backend memoryBackend = |
| | | Backend<?> memoryBackend = |
| | | DirectoryServer.getBackend(TestCaseUtils.TEST_BACKEND_ID); |
| | | String dn1 = "arg=success,o=test1,o=test"; |
| | | String dn2 = "arg=fail,o=test2,o=test"; |
| | |
| | | public void testMultipleCompareOneNoSuchObject() throws Exception |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | Backend memoryBackend = |
| | | Backend<?> memoryBackend = |
| | | DirectoryServer.getBackend(TestCaseUtils.TEST_BACKEND_ID); |
| | | String dn1 = "arg=success,o=test1,o=test"; |
| | | addEntriesUpToParentDN(memoryBackend, DN.valueOf(dn1)); |
| | |
| | | } |
| | | |
| | | |
| | | private void addEntriesUpToParentDN(Backend backend, DN entryDN) |
| | | throws Exception |
| | | private void addEntriesUpToParentDN(Backend<?> backend, DN entryDN) throws Exception |
| | | { |
| | | if (!backend.entryExists(entryDN.parent())) |
| | | { |
| | |
| | | "ds-privilege-name: bypass-acl", |
| | | "sn: User"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "ds-privilege-name: bypass-acl", |
| | | "sn: User"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "ds-privilege-name: bypass-acl", |
| | | "sn: User"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "ds-privilege-name: bypass-acl", |
| | | "sn: User"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," + |
| | | "cn=Password Policies,cn=config"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," + |
| | | "cn=Password Policies,cn=config"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "cn: Test User", |
| | | "userPassword: password"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | */ |
| | | package org.opends.server.tools; |
| | | |
| | | |
| | | |
| | | import java.io.File; |
| | | import java.io.FileWriter; |
| | | import java.util.ArrayList; |
| | | |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.ldap.LDAPResultCode; |
| | | import org.opends.server.types.Entry; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.ldap.LDAPResultCode; |
| | | import org.opends.server.types.Entry; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * A set of test cases for the LDAPDelete tool. |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | String trustStorePath = DirectoryServer.getInstanceRoot() + File.separator + |
| | | "config" + File.separator + "client.truststore"; |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | |
| | | "cn: Test User", |
| | | "userPassword: password"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "cn: Test User", |
| | | "userPassword: password"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "cn: Test User", |
| | | "userPassword: password"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "cn: Test User", |
| | | "userPassword: password"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | import java.io.FileWriter; |
| | | import java.util.ArrayList; |
| | | |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.ldap.LDAPResultCode; |
| | | import org.opends.server.types.Entry; |
| | | import org.testng.annotations.AfterClass; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.ldap.LDAPResultCode; |
| | | import org.opends.server.types.Entry; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | |
| | | import static org.testng.Assert.*; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | import static org.testng.Assert.*; |
| | | |
| | | |
| | | /** |
| | |
| | | "ds-privilege-name: bypass-acl", |
| | | "sn: User"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "ds-privilege-name: bypass-acl", |
| | | "sn: User"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "ds-privilege-name: bypass-acl", |
| | | "sn: User"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "ds-privilege-name: bypass-acl", |
| | | "sn: User"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," + |
| | | "cn=Password Policies,cn=config"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," + |
| | | "cn=Password Policies,cn=config"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "objectClass: organizationalUnit", |
| | | "ou: People"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | String path = TestCaseUtils.createTempFile( |
| | |
| | | "objectClass: organizationalUnit", |
| | | "ou: People"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | String path = TestCaseUtils.createTempFile( |
| | |
| | | "objectClass: organizationalUnit", |
| | | "ou: People"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | String path = TestCaseUtils.createTempFile("dn: ou=People,o=test", |
| | |
| | | "objectClass: organizationalUnit", |
| | | "ou: People"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | String path = TestCaseUtils.createTempFile("dn: ou=People,o=test", |
| | |
| | | "objectClass: organizationalUnit", |
| | | "ou: People"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | String path = TestCaseUtils.createTempFile("dn: ou=People,o=test", |
| | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.Entry; |
| | | import org.testng.annotations.AfterClass; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.types.Entry; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | |
| | | import static org.testng.Assert.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * A set of test cases for the LDAPSearch tool. |
| | |
| | | "givenName: Test", |
| | | "sn: User"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "givenName: Test", |
| | | "sn: User"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "givenName: Test", |
| | | "sn: User"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "givenName: Test", |
| | | "sn: User"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," + |
| | | "cn=Password Policies,cn=config"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," + |
| | | "cn=Password Policies,cn=config"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | |
| | | "objectClass: ldapSubEntry", |
| | | "cn: test"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | String[] args = |
| | |
| | | "sn: Root", |
| | | "userPassword: password"); |
| | | |
| | | AddOperation addOperation = |
| | | conn.processAdd(entry.getName(), entry.getObjectClasses(), |
| | | entry.getUserAttributes(), |
| | | entry.getOperationalAttributes()); |
| | | AddOperation addOperation = conn.processAdd(entry); |
| | | assertPrivilege(addOperation.getResultCode(), hasPrivilege); |
| | | |
| | | DN dnToRemove = entry.getName(); |
| | |
| | | "l;collective: Test", |
| | | "subtreeSpecification: {}"); |
| | | |
| | | AddOperation addOperation = |
| | | conn.processAdd(entry.getName(), entry.getObjectClasses(), |
| | | entry.getUserAttributes(), |
| | | entry.getOperationalAttributes()); |
| | | AddOperation addOperation = conn.processAdd(entry); |
| | | assertPrivilege(addOperation.getResultCode(), hasPrivilege); |
| | | |
| | | DN dnToRemove = entry.getName(); |
| | |
| | | "ds-task-class-name: org.opends.server.tasks.AddSchemaFileTask", |
| | | "ds-task-schema-file-name: 05-" + identifier + ".ldif"); |
| | | |
| | | AddOperation addOperation = |
| | | conn.processAdd(taskEntry.getName(), taskEntry.getObjectClasses(), |
| | | taskEntry.getUserAttributes(), |
| | | taskEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = conn.processAdd(taskEntry); |
| | | assertPrivilege(addOperation.getResultCode(), hasPrivilege); |
| | | |
| | | if (hasPrivilege) |
| | |
| | | "ds-backup-directory-path: bak", |
| | | "ds-task-backup-all: TRUE"); |
| | | |
| | | AddOperation addOperation = |
| | | conn.processAdd(taskEntry.getName(), taskEntry.getObjectClasses(), |
| | | taskEntry.getUserAttributes(), |
| | | taskEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = conn.processAdd(taskEntry); |
| | | assertPrivilege(addOperation.getResultCode(), hasPrivilege); |
| | | |
| | | if (hasPrivilege) |
| | |
| | | "ds-task-class-name: org.opends.server.tasks.RestoreTask", |
| | | "ds-backup-directory-path: bak" + File.separator + "userRoot"); |
| | | |
| | | AddOperation addOperation = |
| | | conn.processAdd(taskEntry.getName(), taskEntry.getObjectClasses(), |
| | | taskEntry.getUserAttributes(), |
| | | taskEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = conn.processAdd(taskEntry); |
| | | assertPrivilege(addOperation.getResultCode(), hasPrivilege); |
| | | |
| | | if (hasPrivilege) |
| | |
| | | "ds-task-export-backend-id: userRoot", |
| | | "ds-task-export-ldif-file: " + tempFilePath); |
| | | |
| | | AddOperation addOperation = |
| | | conn.processAdd(taskEntry.getName(), taskEntry.getObjectClasses(), |
| | | taskEntry.getUserAttributes(), |
| | | taskEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = conn.processAdd(taskEntry); |
| | | assertPrivilege(addOperation.getResultCode(), hasPrivilege); |
| | | |
| | | if (hasPrivilege) |
| | |
| | | "ds-task-import-backend-id: userRoot", |
| | | "ds-task-import-ldif-file: " + path); |
| | | |
| | | AddOperation addOperation = |
| | | conn.processAdd(taskEntry.getName(), taskEntry.getObjectClasses(), |
| | | taskEntry.getUserAttributes(), |
| | | taskEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = conn.processAdd(taskEntry); |
| | | assertPrivilege(addOperation.getResultCode(), hasPrivilege); |
| | | |
| | | if (hasPrivilege) |
| | |
| | | "ds-task-rebuild-base-dn: dc=example,dc=com", |
| | | "ds-task-rebuild-index: cn"); |
| | | |
| | | AddOperation addOperation = |
| | | conn.processAdd(taskEntry.getName(), taskEntry.getObjectClasses(), |
| | | taskEntry.getUserAttributes(), |
| | | taskEntry.getOperationalAttributes()); |
| | | AddOperation addOperation = conn.processAdd(taskEntry); |
| | | assertPrivilege(addOperation.getResultCode(), hasPrivilege); |
| | | |
| | | if (hasPrivilege) |