Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 42640 invoked from network); 16 Mar 2007 23:51:52 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 16 Mar 2007 23:51:52 -0000 Received: (qmail 97048 invoked by uid 500); 16 Mar 2007 23:52:00 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 97030 invoked by uid 500); 16 Mar 2007 23:52:00 -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 97014 invoked by uid 99); 16 Mar 2007 23:52:00 -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 16:52:00 -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 16:51:51 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 111FD1A9838; Fri, 16 Mar 2007 16:51:31 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r519185 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests: Changes10_2.java PhaseChanger.java UpgradeRun.java Date: Fri, 16 Mar 2007 23:51:30 -0000 To: derby-commits@db.apache.org From: djd@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070316235131.111FD1A9838@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: djd Date: Fri Mar 16 16:51:30 2007 New Revision: 519185 URL: http://svn.apache.org/viewvc?view=rev&rev=519185 Log: DERBY-2217 convert upgrade test fixture that re-encrypts an existing encrypted database dueing 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/PhaseChanger.java db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeRun.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=519185&r1=519184&r2=519185 ============================================================================== --- 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 16:51:30 2007 @@ -339,44 +339,101 @@ /** * Run the change encryption test against a - * non-encrypted database. - * + * non-encrypted database. Test that changing the encryption + * is only allowed if the database has been hard-upgraded. + * This test assumes it has its own single use database, which + * will not be booted by the general upgrade test setup. * @throws SQLException */ + public void testChangeEncryptionFromNone() throws SQLException { - changeEncryption("NO_ENCRYPT_10_2", false); + DataSource ds = JDBCDataSource.getDataSourceLogical("NO_ENCRYPT_10_2"); + + switch (getPhase()) + { + case PH_CREATE: + // create the database if it was not already created. + JDBCDataSource.setBeanProperty(ds, "createDatabase", "create"); + ds.getConnection().close(); + break; + case PH_SOFT_UPGRADE: + JDBCDataSource.setBeanProperty(ds, "connectionAttributes", + "dataEncryption=true;bootPassword=xyz1234abc"); + + try { + ds.getConnection(); + fail("open re-encrypted connection in soft upgrade"); + } catch (SQLException e) { + assertSQLState("XJ040", e); + e = e.getNextException(); + assertNotNull(e); + assertSQLState("XCL47", e); + } + break; + + + case PH_POST_SOFT_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; + } } - - /** - * Test that changing the encryption is only allowed if - * the database has been hard-upgraded. This test can - * work against an existing encrypted or un-encrypted database. + * Run the change encryption test against a + * encrypted database. Test that changing the encryption + * is only allowed if the database has been hard-upgraded. * This test assumes it has its own single use database, which * will not be booted by the general upgrade test setup. * @throws SQLException */ - private void changeEncryption(String logicalDBName, - boolean encryptOldDB) throws SQLException + + public void testChangeEncryptionFromEncryptedDatabase() throws SQLException { - DataSource ds = JDBCDataSource.getDataSourceLogical(logicalDBName); + DataSource ds = JDBCDataSource.getDataSourceLogical("ENCRYPT_10_2"); switch (getPhase()) { case PH_CREATE: - // create the database if it was not already created. + // create the database encrypted JDBCDataSource.setBeanProperty(ds, "createDatabase", "create"); - if (encryptOldDB) - { - JDBCDataSource.setBeanProperty(ds, "connectionAttributes", - "dataEncryption=true;bootPassword=old1234dbPhraSe"); - } + JDBCDataSource.setBeanProperty(ds, "connectionAttributes", + "dataEncryption=true;bootPassword=old862phRase"); ds.getConnection().close(); break; case PH_SOFT_UPGRADE: JDBCDataSource.setBeanProperty(ds, "connectionAttributes", - "dataEncryption=true;bootPassword=xyz1234abc"); + "bootPassword=old862phRase;newBootPassword=new902pHrAse"); try { ds.getConnection(); @@ -393,6 +450,8 @@ case PH_POST_SOFT_UPGRADE: // Should be able to successfully connect to it // using the old setup. + JDBCDataSource.setBeanProperty(ds, "connectionAttributes", + "bootPassword=old862phRase"); ds.getConnection().close(); break; @@ -401,7 +460,7 @@ // changing the encryption. // Note we have to explicitly upgrade additional databases. JDBCDataSource.setBeanProperty(ds, "connectionAttributes", - "upgrade=true;dataEncryption=true;bootPassword=haRD1234upGrAde"); + "upgrade=true;bootPassword=old862phRase;newBootPassword=hard924pHrAse"); ds.getConnection().close(); // Shutdown the database. @@ -421,7 +480,7 @@ // And connect successfully. JDBCDataSource.setBeanProperty(ds, "connectionAttributes", - "bootPassword=haRD1234upGrAde"); + "bootPassword=hard924pHrAse"); ds.getConnection().close(); break; } Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/PhaseChanger.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/PhaseChanger.java?view=diff&rev=519185&r1=519184&r2=519185 ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/PhaseChanger.java (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/PhaseChanger.java Fri Mar 16 16:51:30 2007 @@ -115,8 +115,9 @@ ds.getConnection().close(); } catch (SQLException e) { // if the database was never created - // don't bother shutting it down. - if ("XJ004".equals(e.getSQLState())) + // don't bother shutting it down + String sqlState = e.getSQLState(); + if ("XJ004".equals(sqlState) || "XJ040".equals(sqlState)) shutdown = false; } 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=519185&r1=519184&r2=519185 ============================================================================== --- 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 16:51:30 2007 @@ -66,7 +66,8 @@ * The databases are shutdown at the end of each phase. */ static final String[] ADDITIONAL_DBS = { - "NO_ENCRYPT_10_2" + "NO_ENCRYPT_10_2", + "ENCRYPT_10_2" }; private static String getTextVersion(int[] iv)