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

neil_a_wilson
15.50.2006 c933bedb75818290b5a49ca178fcfc5340dbb3c3
Update the LDAPSearch, LDAPModify, LDAPCompare, and LDAPDelete tools to rename
the "--controls" argument to "--control", since each instance only allows the
user to specify information about a single control. Issue #1009.

Update the LDAPSearch, LDAPModify, LDAPCompare, and LDAPDelete tools to allow
multiple instances of the "-J"/"--control" argument to specify multiple
arbitrary controls. Issue #1010.
7 files modified
126 ■■■■■ changed files
opends/src/server/org/opends/server/tools/LDAPCompare.java 9 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/LDAPDelete.java 10 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/LDAPModify.java 9 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/LDAPSearch.java 8 ●●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/tools/LDAPDeleteTestCase.java 28 ●●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/tools/LDAPModifyTestCase.java 32 ●●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/tools/LDAPSearchTestCase.java 30 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/LDAPCompare.java
@@ -464,7 +464,7 @@
      argParser.addArgument(assertionFilter);
      controlStr =
           new StringArgument("controls", 'J', "controls", false, false, true,
           new StringArgument("control", 'J', "control", false, true, true,
                    "{controloid[:criticality[:value|::b64value|:<filePath]]}",
                    null, null, MSGID_DESCRIPTION_CONTROLS);
      argParser.addArgument(controlStr);
@@ -698,9 +698,11 @@
    compareOptions.setVerbose(verbose.isPresent());
    compareOptions.setContinueOnError(continueOnError.isPresent());
    compareOptions.setEncoding(encodingStr.getValue());
    if(controlStr.hasValue())
    if(controlStr.isPresent())
    {
      String ctrlString = controlStr.getValue();
      for (String ctrlString : controlStr.getValues())
      {
      LDAPControl ctrl = LDAPToolUtils.getControl(ctrlString, err);
      if(ctrl == null)
      {
@@ -712,6 +714,7 @@
      }
      compareOptions.getControls().add(ctrl);
    }
    }
    if (assertionFilter.isPresent())
    {
opends/src/server/org/opends/server/tools/LDAPDelete.java
@@ -440,7 +440,7 @@
      argParser.addArgument(deleteSubtree);
      controlStr =
           new StringArgument("controls", 'J', "controls", false, false, true,
           new StringArgument("control", 'J', "control", false, true, true,
                    "{controloid[:criticality[:value|::b64value|:<fileurl]]}",
                    null, null, MSGID_DESCRIPTION_CONTROLS);
      argParser.addArgument(controlStr);
@@ -591,9 +591,11 @@
    deleteOptions.setContinueOnError(continueOnError.isPresent());
    deleteOptions.setEncoding(encodingStr.getValue());
    deleteOptions.setDeleteSubtree(deleteSubtree.isPresent());
    if(controlStr.hasValue())
    if(controlStr.isPresent())
    {
      String ctrlString = controlStr.getValue();
      for (String ctrlString : controlStr.getValues())
      {
      LDAPControl ctrl = LDAPToolUtils.getControl(ctrlString, err);
      if(ctrl == null)
      {
@@ -605,6 +607,8 @@
      }
      deleteOptions.getControls().add(ctrl);
    }
    }
    if(deleteOptions.getDeleteSubtree())
    {
      LDAPControl control = new LDAPControl(OID_SUBTREE_DELETE_CONTROL);
opends/src/server/org/opends/server/tools/LDAPModify.java
@@ -726,7 +726,7 @@
      argParser.addArgument(postReadAttributes);
      controlStr =
           new StringArgument("controls", 'J', "controls", false, false, true,
           new StringArgument("control", 'J', "control", false, true, true,
                    "{controloid[:criticality[:value|::b64value|:<fileurl]]}",
                    null, null, MSGID_DESCRIPTION_CONTROLS);
      argParser.addArgument(controlStr);
@@ -878,9 +878,11 @@
    modifyOptions.setContinueOnError(continueOnError.isPresent());
    modifyOptions.setEncoding(encodingStr.getValue());
    modifyOptions.setDefaultAdd(defaultAdd.isPresent());
    if(controlStr.hasValue())
    if (controlStr.isPresent())
    {
      String ctrlString = controlStr.getValue();
      for (String ctrlString : controlStr.getValues())
      {
      LDAPControl ctrl = LDAPToolUtils.getControl(ctrlString, err);
      if(ctrl == null)
      {
@@ -892,6 +894,7 @@
      }
      modifyOptions.getControls().add(ctrl);
    }
    }
    if (proxyAuthzID.isPresent())
    {
opends/src/server/org/opends/server/tools/LDAPSearch.java
@@ -702,7 +702,7 @@
      argParser.addArgument(matchedValuesFilter);
      controlStr =
           new StringArgument("controls", 'J', "controls", false, false, true,
           new StringArgument("control", 'J', "control", false, true, true,
                    "{controloid[:criticality[:value|::b64value|:<fileurl]]}",
                    null, null, MSGID_DESCRIPTION_CONTROLS);
      argParser.addArgument(controlStr);
@@ -955,9 +955,10 @@
      return 1;
    }
    if(controlStr.hasValue())
    if(controlStr.isPresent())
    {
      String ctrlString = controlStr.getValue();
      for (String ctrlString : controlStr.getValues())
      {
      LDAPControl ctrl = LDAPToolUtils.getControl(ctrlString, err);
      if(ctrl == null)
      {
@@ -969,6 +970,7 @@
      }
      searchOptions.getControls().add(ctrl);
    }
    }
    if (proxyAuthzID.isPresent())
    {
opends/tests/unit-tests-testng/src/server/org/opends/server/tools/LDAPDeleteTestCase.java
@@ -850,6 +850,34 @@
  /**
   * Tests the inclusion of multiple arbitrary controls in the request to the
   * server.
   *
   * @throws  Exception  If an unexpectd problem occurs.
   */
  @Test()
  public void testMultipleRequestControls()
         throws Exception
  {
    TestCaseUtils.initializeTestBackend(true);
    String[] args =
    {
      "-h", "127.0.0.1",
      "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
      "-D", "cn=Directory Manager",
      "-w", "password",
      "-J", OID_MANAGE_DSAIT_CONTROL + ":false",
      "-J", OID_SUBTREE_DELETE_CONTROL + ":true",
      "o=test"
    };
    assertEquals(LDAPDelete.mainDelete(args, false, null, System.err), 0);
  }
  /**
   * Tests the LDAPDelete tool with the "--help" option.
   */
  @Test()
opends/tests/unit-tests-testng/src/server/org/opends/server/tools/LDAPModifyTestCase.java
@@ -1549,6 +1549,38 @@
  /**
   * Tests the inclusion of multiple arbitrary controls in the request to the
   * server.
   *
   * @throws  Exception  If an unexpectd problem occurs.
   */
  @Test()
  public void testMultipleRequestControls()
         throws Exception
  {
    TestCaseUtils.initializeTestBackend(true);
    String path = TestCaseUtils.createTempFile(
         "dn: o=test",
         "changetype: delete");
    String[] args =
    {
      "-h", "127.0.0.1",
      "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
      "-D", "cn=Directory Manager",
      "-w", "password",
      "-J", OID_MANAGE_DSAIT_CONTROL + ":false",
      "-J", OID_SUBTREE_DELETE_CONTROL + ":true",
      "-f", path
    };
    assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
  }
  /**
   * Tests with various forms of malformed LDIF changes.
   *
   * @throws  Exception  If an unexpected problem occurs.
opends/tests/unit-tests-testng/src/server/org/opends/server/tools/LDAPSearchTestCase.java
@@ -1350,6 +1350,36 @@
  /**
   * Tests the inclusion of multiple arbitrary controls in the request to the
   * server.
   *
   * @throws  Exception  If an unexpectd problem occurs.
   */
  @Test()
  public void testMultipleRequestControls()
         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", OID_ACCOUNT_USABLE_CONTROL + ":true",
      "-J", OID_MANAGE_DSAIT_CONTROL + ":false",
      "(objectClass=*)"
    };
    assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0);
  }
  /**
   * Tests the LDAPSearch tool with the "--help" option.
   */
  @Test()