From b9a03f4945d1e2a30ae01e9dd198319c487ac451 Mon Sep 17 00:00:00 2001
From: el_kaboing <el_kaboing@localhost>
Date: Tue, 22 Aug 2006 17:58:47 +0000
Subject: [PATCH] Made the Security Test Suite able to be run in Windows.

---
 opendj-sdk/opends/tests/integration-tests-testng/src/server/org/opends/server/integration/security/generate_server_cert.bat         |   31 ++++++++++
 opendj-sdk/opends/tests/integration-tests-testng/src/server/org/opends/server/integration/security/data/startup/deleteTrustMgr.ldif |   28 +++++++++
 opendj-sdk/opends/tests/integration-tests-testng/src/server/org/opends/server/integration/security/JKSStartupTests.java             |   70 +++++++++++++++--------
 3 files changed, 103 insertions(+), 26 deletions(-)

diff --git a/opendj-sdk/opends/tests/integration-tests-testng/src/server/org/opends/server/integration/security/JKSStartupTests.java b/opendj-sdk/opends/tests/integration-tests-testng/src/server/org/opends/server/integration/security/JKSStartupTests.java
index b866167..a210cbb 100644
--- a/opendj-sdk/opends/tests/integration-tests-testng/src/server/org/opends/server/integration/security/JKSStartupTests.java
+++ b/opendj-sdk/opends/tests/integration-tests-testng/src/server/org/opends/server/integration/security/JKSStartupTests.java
@@ -40,41 +40,61 @@
  *  Setup for jks tests
 */
   @Parameters({ "integration_test_home", "dsee_home", "logDir" })
-  @Test(alwaysRun=true, dependsOnMethods = { "org.opends.server.integration.schema.SchemaStartupTests.testSchemaStartup1" })
+  @Test(alwaysRun=true, dependsOnMethods = { "org.opends.server.integration.quickstart.QuickstartAddTests.testQuickstartAdd2" })
+  //@Test(alwaysRun=true, dependsOnMethods = { "org.opends.server.integration.schema.SchemaStartupTests.testSchemaStartup1" })
   public void testJKSStartup1(String integration_test_home, String dsee_home, String logDir) throws Exception
   {
     System.out.println("*********************************************");
     System.out.println("JKS SSL Startup test 1");
    
-    ds_output.redirectOutput(logDir, "JKSStartup1.txt"); 
+    String osName = new String(System.getProperty("os.name"));
+      
+    if (osName.indexOf("Windows") >= 0)  // For Windows
+    {
+	String exec_cmd = "CMD /C " + integration_test_home + "\\security\\generate_server_cert";
+      Runtime rtime = Runtime.getRuntime();
+      Process child = rtime.exec(exec_cmd);
+      child.waitFor();
 
-    String exec_cmd = "cd " + integration_test_home;
-    Runtime rtime = Runtime.getRuntime();
-    Process child = rtime.exec(exec_cmd);
-    child.waitFor();
+      exec_cmd = "CMD /C copy " + integration_test_home + "\\..\\..\\..\\..\\..\\..\\keystore " + dsee_home + "\\config";
+      rtime = Runtime.getRuntime();
+      child = rtime.exec(exec_cmd);
+      child.waitFor();
 
-    exec_cmd = "chmod +x " + integration_test_home + "/security/generate_server_cert.sh";
-    rtime = Runtime.getRuntime();
-    child = rtime.exec(exec_cmd);
-    child.waitFor();
+      exec_cmd = "CMD /C cd " + dsee_home;
+      rtime = Runtime.getRuntime();
+      child = rtime.exec(exec_cmd);
+      child.waitFor();
 
-    exec_cmd = integration_test_home + "/security/generate_server_cert.sh";
-    rtime = Runtime.getRuntime();
-    child = rtime.exec(exec_cmd);
-    child.waitFor();
+    }
+    else  // all other unix systems
+    {
+      String exec_cmd = "cd " + integration_test_home;
+      Runtime rtime = Runtime.getRuntime();
+      Process child = rtime.exec(exec_cmd);
+      child.waitFor();
 
-    exec_cmd = "cp " + "keystore " + dsee_home + "/config";
-    rtime = Runtime.getRuntime();
-    child = rtime.exec(exec_cmd);
-    child.waitFor();
+      exec_cmd = "chmod +x " + integration_test_home + "/security/generate_server_cert.sh";
+      rtime = Runtime.getRuntime();
+      child = rtime.exec(exec_cmd);
+      child.waitFor();
 
-    exec_cmd = "cd " + dsee_home;
-    rtime = Runtime.getRuntime();
-    child = rtime.exec(exec_cmd);
-    child.waitFor();
+      exec_cmd = integration_test_home + "/security/generate_server_cert.sh";
+      rtime = Runtime.getRuntime();
+      child = rtime.exec(exec_cmd);
+      child.waitFor();
+
+      exec_cmd = "cp " + "keystore " + dsee_home + "/config";
+      rtime = Runtime.getRuntime();
+      child = rtime.exec(exec_cmd);
+      child.waitFor();
+
+      exec_cmd = "cd " + dsee_home;
+      rtime = Runtime.getRuntime();
+      child = rtime.exec(exec_cmd);
+      child.waitFor();
+    }
     
-    ds_output.resetOutput();
-
     compareExitCode(0, 0);
   }
 
@@ -105,7 +125,7 @@
     String jks_mod_args[] = {"-h", hostname, "-p", port, "-D", bindDN, "-w", bindPW, "-f", datafile};
 
     ds_output.redirectOutput(logDir, "JKSStartup3_prep.txt"); 
-    int retCode = LDAPDelete.mainDelete(jks_mod_args);
+    int retCode = LDAPModify.mainModify(jks_mod_args);
     ds_output.resetOutput();
     int expCode = 0;
 
diff --git a/opendj-sdk/opends/tests/integration-tests-testng/src/server/org/opends/server/integration/security/data/startup/deleteTrustMgr.ldif b/opendj-sdk/opends/tests/integration-tests-testng/src/server/org/opends/server/integration/security/data/startup/deleteTrustMgr.ldif
index 80d0412..964e668 100644
--- a/opendj-sdk/opends/tests/integration-tests-testng/src/server/org/opends/server/integration/security/data/startup/deleteTrustMgr.ldif
+++ b/opendj-sdk/opends/tests/integration-tests-testng/src/server/org/opends/server/integration/security/data/startup/deleteTrustMgr.ldif
@@ -1 +1,27 @@
-cn=Trust Manager Provider,cn=SSL,cn=config
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License").  You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at
+# trunk/opends/resource/legal-notices/OpenDS.LICENSE
+# or https://OpenDS.dev.java.net/OpenDS.LICENSE.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at
+# trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
+# add the following below this CDDL HEADER, with the fields enclosed
+# by brackets "[]" replaced with your own identifying * information:
+#      Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#      Portions Copyright 2006 Sun Microsystems, Inc.
+#
+
+dn: cn=Trust Manager Provider,cn=SSL,cn=config
+changetype: delete
diff --git a/opendj-sdk/opends/tests/integration-tests-testng/src/server/org/opends/server/integration/security/generate_server_cert.bat b/opendj-sdk/opends/tests/integration-tests-testng/src/server/org/opends/server/integration/security/generate_server_cert.bat
new file mode 100644
index 0000000..1b82056
--- /dev/null
+++ b/opendj-sdk/opends/tests/integration-tests-testng/src/server/org/opends/server/integration/security/generate_server_cert.bat
@@ -0,0 +1,31 @@
+@echo off
+
+rem CDDL HEADER START
+rem
+rem The contents of this file are subject to the terms of the
+rem Common Development and Distribution License, Version 1.0 only
+rem (the "License").  You may not use this file except in compliance
+rem with the License.
+rem
+rem You can obtain a copy of the license at
+rem trunk/opends/resource/legal-notices/OpenDS.LICENSE
+rem or https://OpenDS.dev.java.net/OpenDS.LICENSE.
+rem See the License for the specific language governing permissions
+rem and limitations under the License.
+rem
+rem When distributing Covered Code, include this CDDL HEADER in each
+rem file and include the License file at
+rem trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
+rem add the following below this CDDL HEADER, with the fields enclosed
+rem information:
+rem      Portions Copyright [yyyy] [name of copyright owner]
+rem
+rem CDDL HEADER END
+rem
+rem
+rem      Portions Copyright 2006 Sun Microsystems, Inc.
+
+keytool -genkey -alias server-cert -keyalg rsa -dname "cn=client,O=Sun Microsystems,C=US" -keystore "keystore" -storepass "servercert" -keypass "servercert" 
+
+keytool -selfcert -alias server-cert -keystore "keystore" -storepass "servercert" 
+

--
Gitblit v1.10.0