Return-Path: Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: (qmail 31042 invoked from network); 18 Jan 2010 22:54:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 18 Jan 2010 22:54:22 -0000 Received: (qmail 44551 invoked by uid 500); 18 Jan 2010 22:54:22 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 44453 invoked by uid 500); 18 Jan 2010 22:54:22 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 44444 invoked by uid 99); 18 Jan 2010 22:54:22 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 18 Jan 2010 22:54:22 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 18 Jan 2010 22:54:19 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id A126823889EA; Mon, 18 Jan 2010 22:53:58 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r900596 - in /commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources: TestPerUserPoolDataSource.java TestSharedPoolDataSource.java Date: Mon, 18 Jan 2010 22:53:58 -0000 To: commits@commons.apache.org From: sebb@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100118225358.A126823889EA@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: sebb Date: Mon Jan 18 22:53:58 2010 New Revision: 900596 URL: http://svn.apache.org/viewvc?rev=900596&view=rev Log: Extend invalidPassword to check invalid user with same user+password as a valid user Add testChangedPassword() for DBCP-8 (currently does not fail) Modified: commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/TestPerUserPoolDataSource.java commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/TestSharedPoolDataSource.java Modified: commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/TestPerUserPoolDataSource.java URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/TestPerUserPoolDataSource.java?rev=900596&r1=900595&r2=900596&view=diff ============================================================================== --- commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/TestPerUserPoolDataSource.java (original) +++ commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/TestPerUserPoolDataSource.java Mon Jan 18 22:53:58 2010 @@ -114,6 +114,19 @@ // Make sure we can still use our good password. ds.getConnection("u1", "p1").close(); + + // Try related users and passwords + ds.getConnection("foo", "bar").close(); + try { + ds.getConnection("foob", "ar").close(); + fail("Should have caused an SQLException"); + } catch (SQLException expected) { + } + try { + ds.getConnection("foo", "baz").close(); + fail("Should have generated SQLException"); + } catch (SQLException expected) { + } } @@ -497,4 +510,26 @@ c[i].close(); } } + + // See DBCP-8 + public void testChangePassword() throws Exception { + try { + ds.getConnection("foo", "bay").close(); + fail("Should have generated SQLException"); + } catch (SQLException expected) { + } + ds.getConnection("foo", "bar").close(); + TesterDriver.addUser("foo","bay"); // change the user/password setting + try { + ds.getConnection("foo", "bay").close(); // new password + try { + ds.getConnection("foo", "bar").close(); // old password + System.out.println("Should have generated SQLException"); // TODO should be fail() + } catch (SQLException expected) { + } + ds.getConnection("foo", "bay").close(); + } finally { + TesterDriver.addUser("foo","bar"); + } + } } Modified: commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/TestSharedPoolDataSource.java URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/TestSharedPoolDataSource.java?rev=900596&r1=900595&r2=900596&view=diff ============================================================================== --- commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/TestSharedPoolDataSource.java (original) +++ commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/TestSharedPoolDataSource.java Mon Jan 18 22:53:58 2010 @@ -28,6 +28,7 @@ import junit.framework.TestSuite; import org.apache.commons.dbcp.TestConnectionPool; +import org.apache.commons.dbcp.TesterDriver; import org.apache.commons.dbcp.cpdsadapter.DriverAdapterCPDS; /** @@ -116,6 +117,19 @@ // Make sure we can still use our good password. ds.getConnection("u1", "p1").close(); + + // Try related users and passwords + ds.getConnection("foo", "bar").close(); + try { + ds.getConnection("foob", "ar").close(); + fail("Should have caused an SQLException"); + } catch (SQLException expected) { + } + try { + ds.getConnection("foo", "baz").close(); + fail("Should have generated SQLException"); + } catch (SQLException expected) { + } } @@ -537,4 +551,26 @@ doTestPoolPreparedStatements(new PscbStringStringArray()); doTestPoolPreparedStatements(new PscbStringIntIntInt()); } + + // See DBCP-8 + public void testChangePassword() throws Exception { + try { + ds.getConnection("foo", "bay").close(); + fail("Should have generated SQLException"); + } catch (SQLException expected) { + } + ds.getConnection("foo", "bar").close(); + TesterDriver.addUser("foo","bay"); // change the user/password setting + try { + ds.getConnection("foo", "bay").close(); // new password + try { + ds.getConnection("foo", "bar").close(); // old password + System.out.println("Should have generated SQLException"); // TODO should be fail() + } catch (SQLException expected) { + } + ds.getConnection("foo", "bay").close(); + } finally { + TesterDriver.addUser("foo","bar"); + } + } }