db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject svn commit: r169913 - in /incubator/derby/code/trunk/java: engine/org/apache/derby/impl/store/raw/ testing/org/apache/derbyTesting/functionTests/harness/ testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache/derbyTesting/functionTests/suites/ testing/org/apache/derbyTesting/functionTests/tests/store/ tools/org/apache/derby/impl/tools/ij/
Date Thu, 12 May 2005 23:57:18 GMT
Author: mikem
Date: Thu May 12 16:57:17 2005
New Revision: 169913

URL: http://svn.apache.org/viewcvs?rev=169913&view=rev
Log:
his patch fixes Derby 236  http://issues.apache.org/jira/browse/DERBY-236 - BootPassword gets
written out in plain text in sane mode and in our test environment.

Changes include

1. remove sanity debug code in RawStore to not write bootpassword in plain text into the service.properties
2. currently the test harness does not seem to pass on the encryption related properties to
the MultiTest and with change in #1, encryption wont be used for stress.multi. So changes
made to  RunTest to pass on the encryption, testEncryptionAlgorithm values to the MultiTest
harness. Also changed mtTestCase to recognize the encryption properties and modify the database
url to use for the MultiTest.
ran derbyall on jdk142 with no failures
verified that encryption run for stress.multi was running ok, by adding keepfiles=true to
encryptionAll.properties and checking the service.properties for all the databases created
as part of this encryptionAll testrun. 

submitted by: ksunithaghm@gmail.com


Added:
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/EncryptionTest.out
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/EncryptionTest.java
Modified:
    incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/RawStore.java
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/RunTest.java
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/encryption.runall
    incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/mtTestCase.java

Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/RawStore.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/RawStore.java?rev=169913&r1=169912&r2=169913&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/RawStore.java (original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/RawStore.java Thu
May 12 16:57:17 2005
@@ -175,27 +175,6 @@
 			String dataEncryption = properties.getProperty(Attribute.DATA_ENCRYPTION);
 			databaseEncrypted = Boolean.valueOf(dataEncryption).booleanValue();
 
-
-			if (SanityManager.DEBUG)
-			{
-				if (!databaseEncrypted)
-				{
-					// check for system property if running under sanity - this
-					// gives more test coverage for those that that hard code
-					// connection URL in the test or somehow go thru the test
-					// harness in a strange way.
-					String testEncryption =
-						PropertyUtil.getSystemProperty("testDataEncryption");
-
-					if (testEncryption != null)
-					{
-						properties.put(Attribute.DATA_ENCRYPTION, "true");
-						properties.put(Attribute.BOOT_PASSWORD, testEncryption);
-						databaseEncrypted = true;
-                    }
-				}
-			}
-
 			if (databaseEncrypted)
 			{
 					cipherFactory =

Modified: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/RunTest.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/RunTest.java?rev=169913&r1=169912&r2=169913&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/RunTest.java
(original)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/RunTest.java
Thu May 12 16:57:17 2005
@@ -2021,13 +2021,24 @@
             jvm.setFlags(jvmflags);
         }
         
-        jvm.setD(jvmProps);
         
         if (testType.equals("multi"))
         {
             if ( (jvmflags != null) && (jvmflags.indexOf("mx") == -1) )
                 jvm.setMx(64*1024*1024); // -mx64m
+            
+            // MultiTest is special case, so pass on properties
+            // related to encryption to MultiTest
+            jvmProps.addElement("encryption="+encryption);
+            Properties props = new Properties();
+            // parse and get only the special properties that are needed for the url 
+            SpecialFlags.parse(testSpecialProps, props, new Properties());
+            String encryptionAlgorithm = props.getProperty("testEncryptionAlgorithm");
+            if(encryptionAlgorithm != null)
+                jvmProps.addElement("encryptionAlgorithm=\""+ Attribute.CRYPTO_ALGORITHM

+                        +"="+encryptionAlgorithm+"\"");
         }
+        jvm.setD(jvmProps);
             
         Vector v = jvm.getCommandLine();
         if ( ij.startsWith("ij") )

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/EncryptionTest.out
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/EncryptionTest.out?rev=169913&view=auto
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/EncryptionTest.out
(added)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/EncryptionTest.out
Thu May 12 16:57:17 2005
@@ -0,0 +1 @@
+TEST PASSED

Modified: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/encryption.runall
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/encryption.runall?rev=169913&r1=169912&r2=169913&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/encryption.runall
(original)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/encryption.runall
Thu May 12 16:57:17 2005
@@ -1,2 +1,3 @@
-unit/T_Cipher.unit
-store/encryptDatabase.sql
+unit/T_Cipher.unit
+store/encryptDatabase.sql
+store/EncryptionTest.java

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/EncryptionTest.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/EncryptionTest.java?rev=169913&view=auto
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/EncryptionTest.java
(added)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/EncryptionTest.java
Thu May 12 16:57:17 2005
@@ -0,0 +1,74 @@
+/*
+ 
+ Derby - Class org.apache.derbyTesting.functionTests.tests.store.EncryptionTest
+ 
+ Copyright 2002, 2005 The Apache Software Foundation or its licensors, as applicable.
+ 
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+ 
+ http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ 
+ */
+
+package org.apache.derbyTesting.functionTests.tests.store;
+
+import java.sql.Connection;
+import java.sql.Statement;
+import java.sql.PreparedStatement;
+import java.sql.DriverManager;
+import java.util.Properties;
+import java.io.*;
+
+/**
+ * check if bootpassword is not written out in plain text into service.properties
+ * for an encrypted database run within the test harness.
+ * In future encryption related testcases can be added to this test
+ */
+public class EncryptionTest {
+    public static void main(String[] args) {
+        Connection conn = null;
+        try {
+            // use the ij utility to read the property file and
+            // make the initial connection.
+            org.apache.derby.tools.ij.getPropertyArg(args);
+            conn = org.apache.derby.tools.ij.startJBMS();
+
+            // Test 1
+            // Derby 236 - boot password should not be written out
+            // into service.properties
+            String derbyHome = System.getProperty("derby.system.home");
+
+            // read in the properties in the service.properties file of the db
+            Properties serviceProperties = new Properties();
+            File f = new File(derbyHome + "/wombat/service.properties");
+            serviceProperties.load(new FileInputStream(f.getAbsolutePath()));
+            if (serviceProperties.getProperty("bootPassword") == null)
+                report("TEST PASSED");
+            else
+                report("FAIL -- bootPassword should not be written out into service.properties");
+            
+            conn.close();
+        } catch (Throwable e) {
+            report("FAIL -- unexpected exception: " + e);
+            e.printStackTrace();
+        }
+
+    }
+
+    /**
+     * print message
+     * @param msg to print out 
+     */
+    public static void report(String msg) {
+        System.out.println(msg);
+    }
+
+}

Modified: incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/mtTestCase.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/mtTestCase.java?rev=169913&r1=169912&r2=169913&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/mtTestCase.java (original)
+++ incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/mtTestCase.java Thu
May 12 16:57:17 2005
@@ -142,20 +142,40 @@
 			String framework = p.getProperty("framework");
 			
 			if (framework != null)
-				{
-					String newURLPrefix = null;
-					framework = framework.toUpperCase(java.util.Locale.ENGLISH);
-					if (framework.equals("DB2JNET") || framework.equals("DERBYNET"))
-						newURLPrefix= "jdbc:derby:net://localhost:1527/";
-					else if (framework.equals("DERBYNETCLIENT"))
-						newURLPrefix= "jdbc:derby://localhost:1527/";
-					if (newURLPrefix != null)
-					{
-						updateURLProperties(p,newURLPrefix);
-						p.setProperty("ij.user","APP");
-						p.setProperty("ij.password","PWD");
-					}
+            {
+                String newURLPrefix = null;
+                framework = framework.toUpperCase(java.util.Locale.ENGLISH);
+                if (framework.equals("DB2JNET") || framework.equals("DERBYNET"))
+                    newURLPrefix= "jdbc:derby:net://localhost:1527/";
+                else if (framework.equals("DERBYNETCLIENT"))
+                    newURLPrefix= "jdbc:derby://localhost:1527/";
+                if (newURLPrefix != null)
+                {
+                    updateURLProperties(p,newURLPrefix);
+                    p.setProperty("ij.user","APP");
+                    p.setProperty("ij.password","PWD");
+                }
 			}
+            // this is a special case for the MultiTest.
+            // check and alter url if there are any encryption related 
+            // properties that need to be set on the url 
+            if (("true").equalsIgnoreCase(p.getProperty("encryption"))) 
+            {
+               String encryptUrl = "dataEncryption=true;bootPassword=Thursday";
+               String dbUrl = p.getProperty("database");
+               String encryptionAlgorithm = p.getProperty("encryptionAlgorithm");
+               if (encryptionAlgorithm != null)
+               {
+                   p.setProperty(
+                       "database",
+                       dbUrl + ";" + encryptUrl + ";" + encryptionAlgorithm);
+               }
+               else
+               {
+                   p.setProperty("database",dbUrl + ";"+encryptUrl);
+               }
+            }
+            
 			System.setProperties(p);
 		}
 		// set input stream



Mime
View raw message