You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by dj...@apache.org on 2006/01/23 21:55:20 UTC

svn commit: r371664 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting: functionTests/tests/jdbcapi/ functionTests/tests/lang/ functionTests/tests/unit/ unitTests/crypto/ unitTests/store/

Author: djd
Date: Mon Jan 23 12:55:15 2006
New Revision: 371664

URL: http://svn.apache.org/viewcvs?rev=371664&view=rev
Log:
DERBY-615 Enable the T_Cipher* and T_SortController tests under the SecurityManager.
Add comments (bug numbers) for why lang.dcl and jdbcapi/secureUsers1 are not runnable
under the SecurityManager.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/secureUsers1_app.properties
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/dcl_app.properties
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/T_CipherBlowfish_app.properties
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/T_CipherCFB_app.properties
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/T_CipherDES_app.properties
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/T_CipherECB_app.properties
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/T_CipherOFB_app.properties
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/T_Cipher_app.properties
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/T_SortController_app.properties
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/crypto/T_Cipher.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_SortController.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/secureUsers1_app.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/secureUsers1_app.properties?rev=371664&r1=371663&r2=371664&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/secureUsers1_app.properties (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/secureUsers1_app.properties Mon Jan 23 12:55:15 2006
@@ -18,5 +18,5 @@
 #Exclude for J2ME/Foundation - test requires ldap support which is not available with j9_foundation
 runwithfoundation=false
 
-#exclude with SecurityManager for now
+# Test fails with security manager due to bug DEBRY-857
 noSecurityManager=true

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/dcl_app.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/dcl_app.properties?rev=371664&r1=371663&r2=371664&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/dcl_app.properties (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/dcl_app.properties Mon Jan 23 12:55:15 2006
@@ -3,5 +3,6 @@
 #Exclude for J2ME/Foundation - test requires java.sql.DriverManager for server side JDBC
 runwithfoundation=false
 useextdirs=true
+# Test fails with security manager due to bug DEBRY-537
 noSecurityManager=true
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/T_CipherBlowfish_app.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/T_CipherBlowfish_app.properties?rev=371664&r1=371663&r2=371664&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/T_CipherBlowfish_app.properties (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/T_CipherBlowfish_app.properties Mon Jan 23 12:55:15 2006
@@ -1,7 +1,5 @@
 
 
 usedefaults=true
-
-#exclude with SecurityManager for now
-noSecurityManager=true
+useextdirs=true
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/T_CipherCFB_app.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/T_CipherCFB_app.properties?rev=371664&r1=371663&r2=371664&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/T_CipherCFB_app.properties (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/T_CipherCFB_app.properties Mon Jan 23 12:55:15 2006
@@ -3,7 +3,4 @@
 derby.debug.true=testSort
 
 usedefaults=true
-
-#exclude with SecurityManager for now
-noSecurityManager=true
-
+useextdirs=true

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/T_CipherDES_app.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/T_CipherDES_app.properties?rev=371664&r1=371663&r2=371664&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/T_CipherDES_app.properties (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/T_CipherDES_app.properties Mon Jan 23 12:55:15 2006
@@ -1,6 +1,3 @@
 
 usedefaults=true
-
-#exclude with SecurityManager for now
-noSecurityManager=true
-
+useextdirs=true

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/T_CipherECB_app.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/T_CipherECB_app.properties?rev=371664&r1=371663&r2=371664&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/T_CipherECB_app.properties (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/T_CipherECB_app.properties Mon Jan 23 12:55:15 2006
@@ -1,6 +1,3 @@
 
 usedefaults=true
-
-#exclude with SecurityManager for now
-noSecurityManager=true
-
+useextdirs=true

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/T_CipherOFB_app.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/T_CipherOFB_app.properties?rev=371664&r1=371663&r2=371664&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/T_CipherOFB_app.properties (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/T_CipherOFB_app.properties Mon Jan 23 12:55:15 2006
@@ -1,6 +1,3 @@
 
 usedefaults=true
-
-#exclude with SecurityManager for now
-noSecurityManager=true
-
+useextdirs=true

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/T_Cipher_app.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/T_Cipher_app.properties?rev=371664&r1=371663&r2=371664&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/T_Cipher_app.properties (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/T_Cipher_app.properties Mon Jan 23 12:55:15 2006
@@ -1,7 +1,4 @@
 
 
 usedefaults=true
-
-#exclude with SecurityManager for now
-noSecurityManager=true
-
+useextdirs=true

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/T_SortController_app.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/T_SortController_app.properties?rev=371664&r1=371663&r2=371664&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/T_SortController_app.properties (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/T_SortController_app.properties Mon Jan 23 12:55:15 2006
@@ -3,5 +3,5 @@
 usedefaults=true
 
 #exclude with SecurityManager for now
-noSecurityManager=true
+noSecurityManager=false
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/crypto/T_Cipher.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/crypto/T_Cipher.java?rev=371664&r1=371663&r2=371664&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/crypto/T_Cipher.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/crypto/T_Cipher.java Mon Jan 23 12:55:15 2006
@@ -31,9 +31,13 @@
 
 import org.apache.derby.iapi.error.StandardException;
 
+import java.security.AccessController;
 import java.security.Key;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedExceptionAction;
 
 import java.io.File;
+import java.io.FileNotFoundException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.FileInputStream;
@@ -97,7 +101,14 @@
     protected String getProvider()
     {
 	// allow for alternate providers
-	String testProvider = System.getProperty("testEncryptionProvider");
+	String testProvider = 
+		
+    	(String) AccessController.doPrivileged(new PrivilegedAction() {
+		    public Object run()  {
+		    	return System.getProperty("testEncryptionProvider");
+		    }
+	    });
+	
 	if (testProvider != null) 
 		return testProvider;
 	else
@@ -108,19 +119,12 @@
 	public void runTests() throws T_Fail {
 
 		File testFile = new File("extinout/T_Cipher.data");
-		if (testFile.exists())
-			testFile.delete();
+		deleteFile(testFile);
 
 		String bootPassword = "a secret, don't tell anyone";
 
 		try
 		{
-							
-			//if external input output files dir does not exist ,create one
-			File ifdir = new File("extinout");
-			if(!ifdir.exists())
-				ifdir.mkdirs();
-
 			RandomAccessFile file = new RandomAccessFile(testFile, "rw");
 
 			setupCiphers(bootPassword);
@@ -179,50 +183,6 @@
 			check(pattern, 1, patternLength/2, file);
 
 			file.close();
-
-			// test streaming
-			File streamFile = new File("extinout/T_CipherStream.data");
-			if (streamFile.exists())
-				streamFile.delete();
-
-			// RESOLVE: defectId 1834
-			if (false)
-			{
-/*				OutputStream enOutputStream =
-					factory.createNewCipherOutputStream(
-						new FileOutputStream(streamFile), factory.ENCRYPT, secretKey, IV);
-
-				int encryptLength = patternLength; // make it a length that is
-												   // not on 8 bytes boundary
-				enOutputStream.write(pattern, 0, encryptLength);
-				enOutputStream.write(pattern, 0, 3); // write a couple of bytes of
-												 // garbage at the end
-				enOutputStream.close();
-				enOutputStream = null;
-
-				InputStream inStream = new FileInputStream(streamFile);
-				byte[] check = new byte[encryptLength + 100];
-				int r = inStream.read(check);
-				inStream.close();
-				REPORT("Stream of " + encryptLength + " is encrypted into " + r + " length");
-				if (byteArrayIdentical(check, pattern, 0, encryptLength))
-					throw T_Fail.testFailMsg("encryption stream did not encrypt");
-
-				InputStream deInputStream =
-					factory.createNewCipherInputStream(
-						new FileInputStream(streamFile), factory.DECRYPT, secretKey, IV);
-
-				int totalRead = 0;
-				while((r = deInputStream.read(check, totalRead, check.length-totalRead)) != -1)
-					totalRead += r;
-
-				if (totalRead != encryptLength)
-					throw T_Fail.testFailMsg("decrypted stream is " + totalRead + " is not the same length");
-				if (byteArrayIdentical(check, pattern, 0, encryptLength) == false)
-					throw T_Fail.testFailMsg("decryption stream did not decrypt");
-				deInputStream.close();
-*/
-			}
 		}
 		catch (StandardException se)
 		{
@@ -647,4 +607,19 @@
             System.out.println("index " + i + " : " + array[i]);
     }
     */
+	
+	/**
+	 * Delete a file in a Privileged block as these tests are
+	 * run under the embedded engine code.
+	 */
+	private void deleteFile(final File f)
+	{
+	   	AccessController.doPrivileged(new PrivilegedAction() {
+		    public Object run()  {
+		    	if (f.exists())
+		    	    f.delete();
+		    	return null;
+		    }
+	    });
+	}
 }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_SortController.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_SortController.java?rev=371664&r1=371663&r2=371664&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_SortController.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_SortController.java Mon Jan 23 12:55:15 2006
@@ -43,6 +43,8 @@
 
 import org.apache.derby.iapi.types.SQLInteger;
 
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.Properties;
 import java.util.Vector;
 import java.util.StringTokenizer;
@@ -66,8 +68,13 @@
 		return AccessFactory.MODULE;
 	}
 
-	private void setSortBufferSize(String buf_length) {
-		System.setProperty("derby.storage.sortBufferMax", buf_length);
+	private void setSortBufferSize(final String buf_length) {
+    	AccessController.doPrivileged(new PrivilegedAction() {
+		    public Object run()  {
+		    	System.setProperty("derby.storage.sortBufferMax", buf_length);
+		    	return null;
+		    }
+	    });
 	}
 
 	/*