commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
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 GMT
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");
+        }
+    }
 }



Mime
View raw message