You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by th...@apache.org on 2013/10/09 21:22:55 UTC

svn commit: r1530770 - /hive/branches/branch-0.12/ql/src/test/org/apache/hadoop/hive/ql/security/

Author: thejas
Date: Wed Oct  9 19:22:55 2013
New Revision: 1530770

URL: http://svn.apache.org/r1530770
Log:
HIVE-5476: Authorization-provider tests fail in sequential run (Sushanth Sowmyan via Ashutosh Chauhan)

Modified:
    hive/branches/branch-0.12/ql/src/test/org/apache/hadoop/hive/ql/security/TestClientSideAuthorizationProvider.java
    hive/branches/branch-0.12/ql/src/test/org/apache/hadoop/hive/ql/security/TestMetastoreAuthorizationProvider.java
    hive/branches/branch-0.12/ql/src/test/org/apache/hadoop/hive/ql/security/TestStorageBasedClientSideAuthorizationProvider.java
    hive/branches/branch-0.12/ql/src/test/org/apache/hadoop/hive/ql/security/TestStorageBasedMetastoreAuthorizationProvider.java

Modified: hive/branches/branch-0.12/ql/src/test/org/apache/hadoop/hive/ql/security/TestClientSideAuthorizationProvider.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.12/ql/src/test/org/apache/hadoop/hive/ql/security/TestClientSideAuthorizationProvider.java?rev=1530770&r1=1530769&r2=1530770&view=diff
==============================================================================
--- hive/branches/branch-0.12/ql/src/test/org/apache/hadoop/hive/ql/security/TestClientSideAuthorizationProvider.java (original)
+++ hive/branches/branch-0.12/ql/src/test/org/apache/hadoop/hive/ql/security/TestClientSideAuthorizationProvider.java Wed Oct  9 19:22:55 2013
@@ -95,18 +95,26 @@ public class TestClientSideAuthorization
   }
 
   private void validateCreateDb(Database expectedDb, String dbName) {
-    assertEquals(expectedDb.getName(), dbName);
+    assertEquals(expectedDb.getName().toLowerCase(), dbName.toLowerCase());
   }
 
   private void validateCreateTable(Table expectedTable, String tblName, String dbName) {
     assertNotNull(expectedTable);
-    assertEquals(expectedTable.getTableName(),tblName);
-    assertEquals(expectedTable.getDbName(),dbName);
+    assertEquals(expectedTable.getTableName().toLowerCase(),tblName.toLowerCase());
+    assertEquals(expectedTable.getDbName().toLowerCase(),dbName.toLowerCase());
+  }
+
+  protected String getTestDbName(){
+    return "smp_cl_db";
+  }
+
+  protected String getTestTableName(){
+    return "smp_cl_tbl";
   }
 
   public void testSimplePrivileges() throws Exception {
-    String dbName = "smpdb";
-    String tblName = "smptbl";
+    String dbName = getTestDbName();
+    String tblName = getTestTableName();
 
     String userName = ugi.getUserName();
 
@@ -159,6 +167,10 @@ public class TestClientSideAuthorization
     ret = driver.run("alter table "+tblName+" add partition (b='2011')");
     assertEquals(0,ret.getResponseCode());
 
+    allowDropOnTable(tblName, userName, tbl.getSd().getLocation());
+    allowDropOnDb(dbName,userName,db.getLocationUri());
+    driver.run("drop database if exists "+getTestDbName()+" cascade");
+
   }
 
   protected void allowCreateInTbl(String tableName, String userName, String location)
@@ -182,6 +194,16 @@ public class TestClientSideAuthorization
     // nothing needed here by default
   }
 
+  protected void allowDropOnTable(String tblName, String userName, String location)
+      throws Exception {
+    driver.run("grant drop on table "+tblName+" to user "+userName);
+  }
+
+  protected void allowDropOnDb(String dbName, String userName, String location)
+      throws Exception {
+    driver.run("grant drop on database "+dbName+" to user "+userName);
+  }
+
   protected void assertNoPrivileges(CommandProcessorResponse ret){
     assertNotNull(ret);
     assertFalse(0 == ret.getResponseCode());

Modified: hive/branches/branch-0.12/ql/src/test/org/apache/hadoop/hive/ql/security/TestMetastoreAuthorizationProvider.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.12/ql/src/test/org/apache/hadoop/hive/ql/security/TestMetastoreAuthorizationProvider.java?rev=1530770&r1=1530769&r2=1530770&view=diff
==============================================================================
--- hive/branches/branch-0.12/ql/src/test/org/apache/hadoop/hive/ql/security/TestMetastoreAuthorizationProvider.java (original)
+++ hive/branches/branch-0.12/ql/src/test/org/apache/hadoop/hive/ql/security/TestMetastoreAuthorizationProvider.java Wed Oct  9 19:22:55 2013
@@ -115,19 +115,26 @@ public class TestMetastoreAuthorizationP
   }
 
   private void validateCreateDb(Database expectedDb, String dbName) {
-    assertEquals(expectedDb.getName(), dbName);
+    assertEquals(expectedDb.getName().toLowerCase(), dbName.toLowerCase());
   }
 
   private void validateCreateTable(Table expectedTable, String tblName, String dbName) {
     assertNotNull(expectedTable);
-    assertEquals(expectedTable.getTableName(),tblName);
-    assertEquals(expectedTable.getDbName(),dbName);
+    assertEquals(expectedTable.getTableName().toLowerCase(),tblName.toLowerCase());
+    assertEquals(expectedTable.getDbName().toLowerCase(),dbName.toLowerCase());
   }
 
-  public void testSimplePrivileges() throws Exception {
-    String dbName = "smpdb";
-    String tblName = "smptbl";
+  protected String getTestDbName(){
+    return "smp_ms_db";
+  }
+
+  protected String getTestTableName(){
+    return "smp_ms_tbl";
+  }
 
+  public void testSimplePrivileges() throws Exception {
+    String dbName = getTestDbName();
+    String tblName = getTestTableName();
     String userName = ugi.getUserName();
 
     CommandProcessorResponse ret = driver.run("create database " + dbName);
@@ -235,6 +242,10 @@ public class TestMetastoreAuthorizationP
     ret = driver.run("alter table "+tblName+" add partition (b='2011')");
     assertEquals(0,ret.getResponseCode());
 
+    allowDropOnTable(tblName, userName, tbl.getSd().getLocation());
+    allowDropOnDb(dbName,userName,db.getLocationUri());
+    driver.run("drop database if exists "+getTestDbName()+" cascade");
+
   }
 
   protected void allowCreateInTbl(String tableName, String userName, String location)
@@ -258,6 +269,16 @@ public class TestMetastoreAuthorizationP
     driver.run("revoke create on database "+dbName+" from user "+userName);
   }
 
+  protected void allowDropOnTable(String tblName, String userName, String location)
+      throws Exception {
+    driver.run("grant drop on table "+tblName+" to user "+userName);
+  }
+
+  protected void allowDropOnDb(String dbName, String userName, String location)
+      throws Exception {
+    driver.run("grant drop on database "+dbName+" to user "+userName);
+  }
+
   protected void assertNoPrivileges(MetaException me){
     assertNotNull(me);
     assertTrue(me.getMessage().indexOf("No privilege") != -1);

Modified: hive/branches/branch-0.12/ql/src/test/org/apache/hadoop/hive/ql/security/TestStorageBasedClientSideAuthorizationProvider.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.12/ql/src/test/org/apache/hadoop/hive/ql/security/TestStorageBasedClientSideAuthorizationProvider.java?rev=1530770&r1=1530769&r2=1530770&view=diff
==============================================================================
--- hive/branches/branch-0.12/ql/src/test/org/apache/hadoop/hive/ql/security/TestStorageBasedClientSideAuthorizationProvider.java (original)
+++ hive/branches/branch-0.12/ql/src/test/org/apache/hadoop/hive/ql/security/TestStorageBasedClientSideAuthorizationProvider.java Wed Oct  9 19:22:55 2013
@@ -64,6 +64,18 @@ public class TestStorageBasedClientSideA
     setPermissions(location,"-r--r--r--");
   }
 
+  @Override
+  protected void allowDropOnTable(String tblName, String userName, String location)
+      throws Exception {
+    setPermissions(location,"-rwxr--r--");
+  }
+
+  @Override
+  protected void allowDropOnDb(String dbName, String userName, String location)
+      throws Exception {
+    setPermissions(location,"-rwxr--r--");
+  }
+
   private void setPermissions(String locn, String permissions) throws Exception {
     FileSystem fs = FileSystem.get(new URI(locn), clientHiveConf);
     fs.setPermission(new Path(locn), FsPermission.valueOf(permissions));
@@ -76,4 +88,15 @@ public class TestStorageBasedClientSideA
     assertTrue(ret.getErrorMessage().indexOf("not permitted") != -1);
   }
 
+
+  @Override
+  protected String getTestDbName(){
+    return super.getTestDbName() + "_SBAP";
+  }
+
+  @Override
+  protected String getTestTableName(){
+    return super.getTestTableName() + "_SBAP";
+  }
+
 }

Modified: hive/branches/branch-0.12/ql/src/test/org/apache/hadoop/hive/ql/security/TestStorageBasedMetastoreAuthorizationProvider.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.12/ql/src/test/org/apache/hadoop/hive/ql/security/TestStorageBasedMetastoreAuthorizationProvider.java?rev=1530770&r1=1530769&r2=1530770&view=diff
==============================================================================
--- hive/branches/branch-0.12/ql/src/test/org/apache/hadoop/hive/ql/security/TestStorageBasedMetastoreAuthorizationProvider.java (original)
+++ hive/branches/branch-0.12/ql/src/test/org/apache/hadoop/hive/ql/security/TestStorageBasedMetastoreAuthorizationProvider.java Wed Oct  9 19:22:55 2013
@@ -69,6 +69,18 @@ public class TestStorageBasedMetastoreAu
     setPermissions(location,"-r--r--r--");
   }
 
+  @Override
+  protected void allowDropOnTable(String tblName, String userName, String location)
+      throws Exception {
+    setPermissions(location,"-rwxr--r--");
+  }
+
+  @Override
+  protected void allowDropOnDb(String dbName, String userName, String location)
+      throws Exception {
+    setPermissions(location,"-rwxr--r--");
+  }
+
   private void setPermissions(String locn, String permissions) throws Exception {
     FileSystem fs = FileSystem.get(new URI(locn), clientHiveConf);
     fs.setPermission(new Path(locn), FsPermission.valueOf(permissions));
@@ -80,4 +92,14 @@ public class TestStorageBasedMetastoreAu
     assertTrue(me.getMessage().indexOf("not permitted") != -1);
   }
 
+  @Override
+  protected String getTestDbName(){
+    return super.getTestDbName() + "_SBAP";
+  }
+
+  @Override
+  protected String getTestTableName(){
+    return super.getTestTableName() + "_SBAP";
+  }
+
 }