db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r519068 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting: functionTests/tests/upgradeTests/Changes10_2.java functionTests/tests/upgradeTests/UpgradeRun.java junit/DropDatabaseSetup.java junit/JDBCDataSource.java
Date Fri, 16 Mar 2007 17:16:11 GMT
Author: djd
Date: Fri Mar 16 10:16:10 2007
New Revision: 519068

URL: http://svn.apache.org/viewvc?view=rev&rev=519068
Log:
DERBY-2217 Add check to ensure that non-encrypted database can be encrypted after a hard upgrade.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_2.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeRun.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DropDatabaseSetup.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBCDataSource.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_2.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_2.java?view=diff&rev=519068&r1=519067&r2=519068
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_2.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_2.java
Fri Mar 16 10:16:10 2007
@@ -345,7 +345,7 @@
      */
     public void testChangeEncryptionFromNone() throws SQLException
     {
-        changeEncryption("NO_ENCRYPT_10_2");
+        changeEncryption("NO_ENCRYPT_10_2", false);
     }
     
     
@@ -357,7 +357,8 @@
      * will not be booted by the general upgrade test setup.
      * @throws SQLException
      */
-    private void changeEncryption(String logicalDBName) throws SQLException
+    private void changeEncryption(String logicalDBName,
+            boolean encryptOldDB) throws SQLException
     {
         DataSource ds = JDBCDataSource.getDataSourceLogical(logicalDBName);
         
@@ -366,6 +367,11 @@
         case PH_CREATE:
             // create the database if it was not already created.
             JDBCDataSource.setBeanProperty(ds, "createDatabase", "create");
+            if (encryptOldDB)
+            {
+                JDBCDataSource.setBeanProperty(ds, "connectionAttributes",
+                    "dataEncryption=true;bootPassword=old1234dbPhraSe");
+            }
             ds.getConnection().close();
             break;
         case PH_SOFT_UPGRADE:
@@ -385,9 +391,37 @@
             
             
         case PH_POST_SOFT_UPGRADE:
-        case PH_HARD_UPGRADE:
             // Should be able to successfully connect to it
             // using the old setup.
+            ds.getConnection().close();
+            break;
+            
+        case PH_HARD_UPGRADE:
+            // On hard upgrade should be able to connect to it
+            // changing the encryption.
+            // Note we have to explicitly upgrade additional databases.
+            JDBCDataSource.setBeanProperty(ds, "connectionAttributes",
+            "upgrade=true;dataEncryption=true;bootPassword=haRD1234upGrAde");
+            ds.getConnection().close();
+            
+            // Shutdown the database.
+            JDBCDataSource.clearStringBeanProperty(ds, "connectionAttributes");
+            JDBCDataSource.shutdownDatabase(ds);
+            
+            // Reboot with no boot password, should fail
+            try {
+                ds.getConnection();
+                fail("open re-encrypted connection without password");
+            } catch (SQLException e) {
+                assertSQLState("XJ040", e);
+                e = e.getNextException();
+                assertNotNull(e);
+                assertSQLState("XBM06", e);
+            }
+            
+            // And connect successfully.
+            JDBCDataSource.setBeanProperty(ds, "connectionAttributes",
+                       "bootPassword=haRD1234upGrAde");
             ds.getConnection().close();
             break;
         }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeRun.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeRun.java?view=diff&rev=519068&r1=519067&r2=519068
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeRun.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeRun.java
Fri Mar 16 10:16:10 2007
@@ -61,7 +61,9 @@
      * require a one-off database. The additional
      * database decorator wraps all the tests and phases.
      * They are only created if a test opens a
-     * connection against them.
+     * connection against them. In hard upgrade the test
+     * must explictly upgrade the database.
+     * The databases are shutdown at the end of each phase.
      */
     static final String[] ADDITIONAL_DBS = {
         "NO_ENCRYPT_10_2"

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DropDatabaseSetup.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DropDatabaseSetup.java?view=diff&rev=519068&r1=519067&r2=519068
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DropDatabaseSetup.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DropDatabaseSetup.java
Fri Mar 16 10:16:10 2007
@@ -52,10 +52,30 @@
         
         // Ensure the database is booted
         // since that is what shutdownDatabase() requires.
-        config.openConnection(logicalDBName).close();
-        String dbName = config.getPhysicalDatabaseName(logicalDBName);
-        DataSource ds = JDBCDataSource.getDataSource(dbName);
-        JDBCDataSource.shutdownDatabase(ds);
+        boolean shutdown;
+        try {
+            config.openConnection(logicalDBName).close();
+            shutdown = true;
+        } catch (SQLException e) {
+            // If the database cannot be booted due
+            // to some restrictions such as authentication
+            // or encrypted (ie here we don't know the 
+            // correct authentication tokens, then it's
+            // ok since we just want it shutdown anyway!
+            if ("XJ040".equals(e.getSQLState()))
+            {
+                shutdown = false;
+            }
+            else
+            {
+                throw e;
+            }
+        }
+        if (shutdown)
+        {
+            DataSource ds = JDBCDataSource.getDataSourceLogical(logicalDBName);
+            JDBCDataSource.shutdownDatabase(ds);
+        }
 
         removeDatabase();
     }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBCDataSource.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBCDataSource.java?view=diff&rev=519068&r1=519067&r2=519068
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBCDataSource.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBCDataSource.java Fri
Mar 16 10:16:10 2007
@@ -228,7 +228,7 @@
         } catch (SQLException e) {
              BaseJDBCTestCase.assertSQLState("Database shutdown", "08006", e);
         } finally {
-            setBeanProperty(ds, "shutdownDatabase", "");
+            clearStringBeanProperty(ds, "shutdownDatabase");
         }
     }
 }



Mime
View raw message