Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 55583 invoked from network); 16 Mar 2007 17:16:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 16 Mar 2007 17:16:32 -0000 Received: (qmail 53045 invoked by uid 500); 16 Mar 2007 17:16:41 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 53022 invoked by uid 500); 16 Mar 2007 17:16:40 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 53011 invoked by uid 99); 16 Mar 2007 17:16:40 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Mar 2007 10:16:40 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Mar 2007 10:16:31 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id D34111A9838; Fri, 16 Mar 2007 10:16:11 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: derby-commits@db.apache.org From: djd@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070316171611.D34111A9838@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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"); } } }