db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r543302 - in /db/derby/code/trunk/java: engine/org/apache/derby/catalog/SystemProcedures.java testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AuthenticationTest.java
Date Thu, 31 May 2007 23:02:19 GMT
Author: djd
Date: Thu May 31 16:02:18 2007
New Revision: 543302

URL: http://svn.apache.org/viewvc?view=rev&rev=543302
Log:
DERBY-2735 (partial) More tests and fix the return from SYSCS_GET_USER_ACCESS when default
connection
mode is not set.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/catalog/SystemProcedures.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AuthenticationTest.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/catalog/SystemProcedures.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/catalog/SystemProcedures.java?view=diff&rev=543302&r1=543301&r2=543302
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/catalog/SystemProcedures.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/catalog/SystemProcedures.java Thu May
31 16:02:18 2007
@@ -1638,6 +1638,8 @@
                 SYSCS_GET_DATABASE_PROPERTY(Property.DEFAULT_CONNECTION_MODE_PROPERTY);
             if (defaultAccess != null)
                 defaultAccess = StringUtil.SQLToUpperCase(defaultAccess);
+            else
+                defaultAccess = Property.FULL_ACCESS; // is the default.
             
             return defaultAccess;
             

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AuthenticationTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AuthenticationTest.java?view=diff&rev=543302&r1=543301&r2=543302
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AuthenticationTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AuthenticationTest.java
Thu May 31 16:02:18 2007
@@ -92,6 +92,9 @@
         test = new AuthenticationTest("testNotFullAccessUsers");
         setBaseProps(suite, test);
         
+        test = new AuthenticationTest("testUserAccessRoutines");
+        setBaseProps(suite, test);
+        
         test = new AuthenticationTest(
             "testChangePasswordAndDatabasePropertiesOnly");
         setBaseProps(suite, test);
@@ -591,6 +594,57 @@
         conn1.commit();
         stmt.close();
         conn1.close();
+    }
+    
+    /**
+     * Test the procedure and function that provide short-cuts
+     * to setting and getting connection level access.
+     * @throws SQLException
+     */
+    public void testUserAccessRoutines() throws SQLException
+    {
+        // use valid user/pwd to set the full accessusers.
+        Connection conn1 = openDefaultConnection(
+            "dan", ("dan" + PASSWORD_SUFFIX));
+        
+        PreparedStatement psGetAccess = conn1.prepareStatement(
+            "VALUES SYSCS_UTIL.SYSCS_GET_USER_ACCESS(?)");
+        CallableStatement csSetAccess = conn1.prepareCall(
+            "CALL SYSCS_UTIL.SYSCS_SET_USER_ACCESS(?, ?)"); 
+        
+        // Clear out the properties to ensure we start afresh
+        setDatabaseProperty("derby.database.fullAccessUsers", 
+                null, conn1);
+        setDatabaseProperty("derby.database.readOnlyAccessUsers", 
+                null, conn1);
+        
+        csSetAccess.setString(1, "dan");
+        csSetAccess.setString(2, "FULLACCESS");
+
+        // Random user will now have only READONLYACCESS
+        setDatabaseProperty(
+                "derby.database.defaultConnectionMode","READONLYACCESS", conn1);       
+        conn1.commit();             
+        psGetAccess.setString(1, "TONYBLAIR");
+        JDBC.assertSingleValueResultSet(psGetAccess.executeQuery(), "READONLYACCESS");
+        conn1.commit();
+
+        // Random user will now have FULLACCESS
+        setDatabaseProperty(
+                "derby.database.defaultConnectionMode","FULLACCESS", conn1);       
+        conn1.commit();             
+        psGetAccess.setString(1, "TONYBLAIR");
+        JDBC.assertSingleValueResultSet(psGetAccess.executeQuery(), "FULLACCESS");
+        conn1.commit();
+        
+        // and still full access
+        setDatabaseProperty(
+                "derby.database.defaultConnectionMode", null, conn1);       
+        conn1.commit();             
+        psGetAccess.setString(1, "TONYBLAIR");
+        JDBC.assertSingleValueResultSet(psGetAccess.executeQuery(), "FULLACCESS");
+        conn1.commit();
+           
     }
     
     public void testGreekCharacters() throws SQLException {



Mime
View raw message