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

coulbeck
26.37.2007 8ee52cb8be2fb60d8c7c52c68c0c1d4309c4e2b4
Fix issue 1516: encode-password with --encodedPasswordFile doesn't work.
2 files modified
43 ■■■■ changed files
opendj-sdk/opends/src/server/org/opends/server/tools/EncodePassword.java 8 ●●●● patch | view | raw | blame | history
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/tools/EncodePasswordTestCase.java 35 ●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/server/org/opends/server/tools/EncodePassword.java
@@ -319,7 +319,8 @@
        return 1;
      }
      if ((! encodedPassword.isPresent()) && (! schemeName.isPresent()))
      if ((! encodedPassword.isPresent()) && (! encodedPasswordFile.isPresent())
           && (! schemeName.isPresent()))
      {
        int    msgID   = MSGID_ENCPW_NO_SCHEME;
        String message = getMessage(msgID, schemeName.getLongIdentifier());
@@ -339,6 +340,11 @@
      compareMode = true;
      encodedPW = new ASN1OctetString(encodedPassword.getValue());
    }
    else if (encodedPasswordFile.hasValue())
    {
      compareMode = true;
      encodedPW = new ASN1OctetString(encodedPasswordFile.getValue());
    }
    else
    {
      compareMode = false;
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/tools/EncodePasswordTestCase.java
@@ -29,7 +29,6 @@
import java.io.File;
import java.io.FileWriter;
import java.util.ArrayList;
import org.testng.annotations.BeforeClass;
@@ -37,18 +36,11 @@
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.opends.server.types.OperatingSystem;
import org.opends.server.types.ResultCode;
import org.opends.server.util.Base64;
import static org.testng.Assert.*;
import static org.opends.server.util.ServerConstants.*;
@@ -61,9 +53,12 @@
  // The path to the Directory Server configuration file.
  private String configFilePath;
  // The path to the temporary file containing a password.
  // The path to the temporary file containing a clear-text password.
  private String passwordFilePath;
  // The path to the temporary file containing an encoded password.
  private String encodedPasswordFilePath;
  /**
@@ -81,6 +76,9 @@
                     "config" + File.separator + "config.ldif";
    passwordFilePath = TestCaseUtils.createTempFile("password");
    encodedPasswordFilePath =
         TestCaseUtils.createTempFile("{SHA}C5wmJdwh7wX2rU3fR8XyA4N6oyw=");
  }
@@ -462,6 +460,25 @@
  /**
   * Tests the EncodePassword tool by performing a comparison of clear-text
   * with a valid matching encoded password.
   */
  @Test()
  public void testCompareMatchingEncodedPasswordsFromFile()
  {
    String[] args =
    {
      "--configFile", configFilePath,
      "--clearPasswordFile", passwordFilePath,
      "--encodedPasswordFile", encodedPasswordFilePath
    };
    assertEquals(EncodePassword.encodePassword(args, false, null, null), 0);
  }
  /**
   * Tests the EncodePassword tool by performing a comparison of clear-text
   * with a valid matching auth password.
   */
  @Test()