mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Ludovic Poitou
22.07.2011 f767be424e83355aeb5d7213995d2cac880495b6
Fix issue OPENDJ-211.
The value part of control specification is optional. And therefore there should be no : to finish the specification.
Now if the specification ends with :, then it's the same as no value.
Test added with the ManageDSAIt control.
2 files modified
40 ■■■■■ changed files
opends/src/server/org/opends/server/tools/LDAPToolUtils.java 6 ●●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/tools/LDAPSearchTestCase.java 34 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/LDAPToolUtils.java
@@ -23,6 +23,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011 ForgeRock AS
 */
package org.opends.server.tools;
import org.opends.messages.Message;
@@ -165,6 +166,11 @@
    }
    String valString = remainder.substring(idx+1, remainder.length());
    if (valString.length() == 0)
    {
      control = new LDAPControl(controlOID, controlCriticality);
      return control;
    }
    if(valString.charAt(0) == ':')
    {
      controlValue =
opends/tests/unit-tests-testng/src/server/org/opends/server/tools/LDAPSearchTestCase.java
@@ -23,6 +23,7 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2011 ForgeRock AS
 */
package org.opends.server.tools;
@@ -2357,6 +2358,35 @@
    assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0);
  }
  /**
   * Tests the use of a control with an empty value.
   * We use the ManageDSAIt control for this.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testControlNoValue()
         throws Exception
  {
    TestCaseUtils.initializeTestBackend(true);
    String[] args =
    {
      "-h", "127.0.0.1",
      "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
      "-D", "cn=Directory Manager",
      "-w", "password",
      "-b", "o=test",
      "-s", "base",
      "-J", "managedsait:false:",
      "--noPropertiesFile",
      "(objectClass=*)",
      "dn"
    };
    assertTrue(LDAPSearch.mainSearch(args, false, null, null) == 0);
  }
  /**
@@ -2369,6 +2399,10 @@
  public void testVLVWithoutSort()
         throws Exception
  {
    // Test is supposed to fail in parsing arguments. But we do not
    // want it to fail because there no backend to search in.
    TestCaseUtils.clearJEBackend(true, "userRoot", "dc=example,dc=com");
    String[] args =
    {
      "-h", "127.0.0.1",