sentry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject [1/2] sentry git commit: Revert "SENTRY-2012 - Make SentryShellGeneric extendible. Mano Kovacs, reviewed by Colm O hEigeartaigh."
Date Fri, 17 Nov 2017 13:12:40 GMT
Repository: sentry
Updated Branches:
  refs/heads/master 2314e4654 -> 5fc1e9779


http://git-wip-us.apache.org/repos/asf/sentry/blob/5fc1e977/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/generic/tools/TestSentryShellSolr.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/generic/tools/TestSentryShellSolr.java b/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/generic/tools/TestSentryShellSolr.java
index 40e7555..0f4bb62 100644
--- a/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/generic/tools/TestSentryShellSolr.java
+++ b/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/generic/tools/TestSentryShellSolr.java
@@ -18,17 +18,12 @@
 
 package org.apache.sentry.provider.db.generic.tools;
 
-import com.google.common.collect.Sets;
 import com.google.common.io.Files;
-import org.apache.commons.io.FileUtils;
-import org.apache.sentry.core.common.exception.SentryUserException;
-import org.apache.sentry.provider.db.generic.service.thrift.SentryGenericServiceIntegrationBase;
-import org.apache.sentry.provider.db.generic.service.thrift.TSentryPrivilege;
-import org.apache.sentry.provider.db.generic.service.thrift.TSentryRole;
-import org.apache.sentry.provider.db.tools.SentryShellCommon;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import com.google.common.collect.Sets;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 import java.io.ByteArrayOutputStream;
 import java.io.File;
@@ -38,7 +33,16 @@ import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;
 
-import static org.junit.Assert.*;
+import org.apache.commons.io.FileUtils;
+import org.apache.sentry.core.common.exception.SentryUserException;
+import org.apache.sentry.provider.db.generic.service.thrift.SentryGenericServiceIntegrationBase;
+import org.apache.sentry.provider.db.generic.service.thrift.TSentryRole;
+import org.apache.sentry.provider.db.generic.service.thrift.TSentryPrivilege;
+import org.apache.sentry.provider.db.tools.SentryShellCommon;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
 
 public class TestSentryShellSolr extends SentryGenericServiceIntegrationBase {
   private File confDir;
@@ -76,32 +80,32 @@ public class TestSentryShellSolr extends SentryGenericServiceIntegrationBase {
       @Override
       public void runTestAsSubject() throws Exception {
         // test: create role with -cr
-        String[] args = { "-cr", "-r", TEST_ROLE_NAME_1, "-conf", confPath.getAbsolutePath() };
-        SentryShellSolr.main(args);
+        String[] args = { "-cr", "-r", TEST_ROLE_NAME_1, "-conf", confPath.getAbsolutePath(), "-t", "solr" };
+        SentryShellGeneric.main(args);
         // test: create role with --create_role
         args = new String[] { "--create_role", "-r", TEST_ROLE_NAME_2, "-conf",
-                confPath.getAbsolutePath() };
-        SentryShellSolr.main(args);
+            confPath.getAbsolutePath(), "-t", "solr" };
+        SentryShellGeneric.main(args);
 
         // validate the result, list roles with -lr
-        args = new String[] { "-lr", "-conf", confPath.getAbsolutePath() };
-        SentryShellSolr sentryShell = new SentryShellSolr();
+        args = new String[] { "-lr", "-conf", confPath.getAbsolutePath(), "-t", "solr" };
+        SentryShellGeneric sentryShell = new SentryShellGeneric();
         Set<String> roleNames = getShellResultWithOSRedirect(sentryShell, args, true);
         validateRoleNames(roleNames, TEST_ROLE_NAME_1, TEST_ROLE_NAME_2);
 
         // validate the result, list roles with --list_role
-        args = new String[] { "--list_role", "-conf", confPath.getAbsolutePath() };
-        sentryShell = new SentryShellSolr();
+        args = new String[] { "--list_role", "-conf", confPath.getAbsolutePath(), "-t", "solr" };
+        sentryShell = new SentryShellGeneric();
         roleNames = getShellResultWithOSRedirect(sentryShell, args, true);
         validateRoleNames(roleNames, TEST_ROLE_NAME_1, TEST_ROLE_NAME_2);
 
         // test: drop role with -dr
-        args = new String[] { "-dr", "-r", TEST_ROLE_NAME_1, "-conf", confPath.getAbsolutePath() };
-        SentryShellSolr.main(args);
+        args = new String[] { "-dr", "-r", TEST_ROLE_NAME_1, "-conf", confPath.getAbsolutePath(), "-t", "solr" };
+        SentryShellGeneric.main(args);
         // test: drop role with --drop_role
         args = new String[] { "--drop_role", "-r", TEST_ROLE_NAME_2, "-conf",
-                confPath.getAbsolutePath() };
-        SentryShellSolr.main(args);
+            confPath.getAbsolutePath(), "-t", "solr" };
+        SentryShellGeneric.main(args);
 
         // validate the result
         Set<TSentryRole> roles = client.listAllRoles(requestorName, SOLR);
@@ -125,41 +129,41 @@ public class TestSentryShellSolr extends SentryGenericServiceIntegrationBase {
         client.createRole(requestorName, TEST_ROLE_NAME_2, SOLR);
         // test: add role to group with -arg
         String[] args = { "-arg", "-r", TEST_ROLE_NAME_1, "-g", TEST_GROUP_1, "-conf",
-                confPath.getAbsolutePath() };
-        SentryShellSolr.main(args);
+            confPath.getAbsolutePath(), "-t", "solr" };
+        SentryShellGeneric.main(args);
         // test: add role to multiple groups
         args = new String[] { "-arg", "-r", TEST_ROLE_NAME_1, "-g", TEST_GROUP_2 + "," + TEST_GROUP_3,
-                "-conf",
-                confPath.getAbsolutePath() };
-        SentryShellSolr.main(args);
+            "-conf",
+            confPath.getAbsolutePath(), "-t", "solr" };
+        SentryShellGeneric.main(args);
         // test: add role to group with --add_role_group
         args = new String[] { "--add_role_group", "-r", TEST_ROLE_NAME_2, "-g", TEST_GROUP_1,
-                "-conf",
-                confPath.getAbsolutePath() };
-        SentryShellSolr.main(args);
+            "-conf",
+            confPath.getAbsolutePath(), "-t", "solr" };
+        SentryShellGeneric.main(args);
 
         // validate the result list roles with -lr and -g
-        args = new String[] { "-lr", "-g", TEST_GROUP_1, "-conf", confPath.getAbsolutePath() };
-        SentryShellSolr sentryShell = new SentryShellSolr();
+        args = new String[] { "-lr", "-g", TEST_GROUP_1, "-conf", confPath.getAbsolutePath(), "-t", "solr" };
+        SentryShellGeneric sentryShell = new SentryShellGeneric();
         Set<String> roleNames = getShellResultWithOSRedirect(sentryShell, args, true);
         validateRoleNames(roleNames, TEST_ROLE_NAME_1, TEST_ROLE_NAME_2);
 
         // list roles with --list_role and -g
         args = new String[] { "--list_role", "-g", TEST_GROUP_2, "-conf",
-                confPath.getAbsolutePath() };
-        sentryShell = new SentryShellSolr();
+            confPath.getAbsolutePath(), "-t", "solr" };
+        sentryShell = new SentryShellGeneric();
         roleNames = getShellResultWithOSRedirect(sentryShell, args, true);
         validateRoleNames(roleNames, TEST_ROLE_NAME_1);
 
         args = new String[] { "--list_role", "-g", TEST_GROUP_3, "-conf",
-                confPath.getAbsolutePath() };
-        sentryShell = new SentryShellSolr();
+            confPath.getAbsolutePath(), "-t", "solr" };
+        sentryShell = new SentryShellGeneric();
         roleNames = getShellResultWithOSRedirect(sentryShell, args, true);
         validateRoleNames(roleNames, TEST_ROLE_NAME_1);
 
         // List the groups and roles via listGroups
-        args = new String[] { "--list_group", "-conf", confPath.getAbsolutePath()};
-        sentryShell = new SentryShellSolr();
+        args = new String[] { "--list_group", "-conf", confPath.getAbsolutePath(), "-t", "solr" };
+        sentryShell = new SentryShellGeneric();
         Set<String> groups = getShellResultWithOSRedirect(sentryShell, args, true);
         assertEquals(3, groups.size());
         assertTrue(groups.contains("testGroup3 = testrole1"));
@@ -168,17 +172,17 @@ public class TestSentryShellSolr extends SentryGenericServiceIntegrationBase {
 
         // test: delete role from group with -drg
         args = new String[] { "-drg", "-r", TEST_ROLE_NAME_1, "-g", TEST_GROUP_1, "-conf",
-                confPath.getAbsolutePath() };
-        SentryShellSolr.main(args);
+            confPath.getAbsolutePath(), "-t", "solr" };
+        SentryShellGeneric.main(args);
         // test: delete role to multiple groups
         args = new String[] { "-drg", "-r", TEST_ROLE_NAME_1, "-g", TEST_GROUP_2 + "," + TEST_GROUP_3,
-                "-conf",
-                confPath.getAbsolutePath() };
-        SentryShellSolr.main(args);
+            "-conf",
+            confPath.getAbsolutePath(), "-t", "solr" };
+        SentryShellGeneric.main(args);
         // test: delete role from group with --delete_role_group
         args = new String[] { "--delete_role_group", "-r", TEST_ROLE_NAME_2, "-g", TEST_GROUP_1,
-                "-conf", confPath.getAbsolutePath() };
-        SentryShellSolr.main(args);
+            "-conf", confPath.getAbsolutePath(), "-t", "solr" };
+        SentryShellGeneric.main(args);
 
         // validate the result
         Set<TSentryRole> roles = client.listRolesByGroupName(requestorName, TEST_GROUP_1, SOLR);
@@ -204,22 +208,22 @@ public class TestSentryShellSolr extends SentryGenericServiceIntegrationBase {
         client.createRole(requestorName, TEST_ROLE_NAME_1, SOLR);
         // add role to a group (lower case)
         String[] args = { "-arg", "-r", TEST_ROLE_NAME_1, "-g", "group1", "-conf",
-                confPath.getAbsolutePath() };
-        SentryShellSolr.main(args);
+            confPath.getAbsolutePath(), "-t", "solr" };
+        SentryShellGeneric.main(args);
 
         // validate the roles when group name is same case as above
-        args = new String[] { "-lr", "-g", "group1", "-conf", confPath.getAbsolutePath() };
-        SentryShellSolr sentryShell = new SentryShellSolr();
+        args = new String[] { "-lr", "-g", "group1", "-conf", confPath.getAbsolutePath(), "-t", "solr" };
+        SentryShellGeneric sentryShell = new SentryShellGeneric();
         Set<String> roleNames = getShellResultWithOSRedirect(sentryShell, args, true);
         validateRoleNames(roleNames, TEST_ROLE_NAME_1);
 
         // roles should be empty when group name is different case than above
-        args = new String[] { "-lr", "-g", "GROUP1", "-conf", confPath.getAbsolutePath() };
+        args = new String[] { "-lr", "-g", "GROUP1", "-conf", confPath.getAbsolutePath(), "-t", "solr" };
         roleNames = getShellResultWithOSRedirect(sentryShell, args, true);
         validateRoleNames(roleNames);
       }
-    });
-  }
+      });
+    }
 
   public static String grant(boolean shortOption) {
     return shortOption ? "-gpr" : "--grant_privilege_role";
@@ -242,21 +246,21 @@ public class TestSentryShellSolr extends SentryGenericServiceIntegrationBase {
         client.createRole(requestorName, TEST_ROLE_NAME_2, SOLR);
 
         String [] privs = {
-                "Collection=*->action=*",
-                "Collection=collection2->action=update",
-                "Collection=collection3->action=query",
+          "Collection=*->action=*",
+          "Collection=collection2->action=update",
+          "Collection=collection3->action=query",
         };
         for (int i = 0; i < privs.length; ++i) {
           // test: grant privilege to role
           String [] args = new String [] { grant(shortOption), "-r", TEST_ROLE_NAME_1, "-p",
-                  privs[ i ],
-                  "-conf", confPath.getAbsolutePath() };
-          SentryShellSolr.main(args);
+            privs[ i ],
+            "-conf", confPath.getAbsolutePath(), "-t", "solr" };
+          SentryShellGeneric.main(args);
         }
 
         // test the list privilege
-        String [] args = new String[] { list(shortOption), "-r", TEST_ROLE_NAME_1, "-conf", confPath.getAbsolutePath() };
-        SentryShellSolr sentryShell = new SentryShellSolr();
+        String [] args = new String[] { list(shortOption), "-r", TEST_ROLE_NAME_1, "-conf", confPath.getAbsolutePath(), "-t", "solr" };
+        SentryShellGeneric sentryShell = new SentryShellGeneric();
         Set<String> privilegeStrs = getShellResultWithOSRedirect(sentryShell, args, true);
         assertEquals("Incorrect number of privileges", privs.length, privilegeStrs.size());
         for (int i = 0; i < privs.length; ++i) {
@@ -266,8 +270,8 @@ public class TestSentryShellSolr extends SentryGenericServiceIntegrationBase {
         for (int i = 0; i < privs.length; ++i) {
           args = new String[] { revoke(shortOption), "-r", TEST_ROLE_NAME_1, "-p",
             privs[ i ], "-conf",
-            confPath.getAbsolutePath()};
-          SentryShellSolr.main(args);
+            confPath.getAbsolutePath(), "-t", "solr" };
+          SentryShellGeneric.main(args);
           Set<TSentryPrivilege> privileges = client.listAllPrivilegesByRoleName(requestorName,
             TEST_ROLE_NAME_1, SOLR, service);
           assertEquals("Incorrect number of privileges", privs.length - (i + 1), privileges.size());
@@ -299,8 +303,8 @@ public class TestSentryShellSolr extends SentryGenericServiceIntegrationBase {
       public void runTestAsSubject() throws Exception {
         client.createRole(requestorName, TEST_ROLE_NAME_1, SOLR);
         // test: create duplicate role with -cr
-        String[] args = { "-cr", "-r", TEST_ROLE_NAME_1, "-conf", confPath.getAbsolutePath() };
-        SentryShellSolr sentryShell = new SentryShellSolr();
+        String[] args = { "-cr", "-r", TEST_ROLE_NAME_1, "-conf", confPath.getAbsolutePath(), "-t", "solr" };
+        SentryShellGeneric sentryShell = new SentryShellGeneric();
         try {
           sentryShell.executeShell(args);
           fail("Exception should be thrown for creating duplicate role");
@@ -309,8 +313,8 @@ public class TestSentryShellSolr extends SentryGenericServiceIntegrationBase {
         }
 
         // test: drop non-exist role with -dr
-        args = new String[] { "-dr", "-r", TEST_ROLE_NAME_2, "-conf", confPath.getAbsolutePath() };
-        sentryShell = new SentryShellSolr();
+        args = new String[] { "-dr", "-r", TEST_ROLE_NAME_2, "-conf", confPath.getAbsolutePath(), "-t", "solr" };
+        sentryShell = new SentryShellGeneric();
         try {
           sentryShell.executeShell(args);
           fail("Exception should be thrown for dropping non-exist role");
@@ -320,8 +324,8 @@ public class TestSentryShellSolr extends SentryGenericServiceIntegrationBase {
 
         // test: add non-exist role to group with -arg
         args = new String[] { "-arg", "-r", TEST_ROLE_NAME_2, "-g", "testGroup1", "-conf",
-                confPath.getAbsolutePath() };
-        sentryShell = new SentryShellSolr();
+            confPath.getAbsolutePath(), "-t", "solr" };
+        sentryShell = new SentryShellGeneric();
         try {
           sentryShell.executeShell(args);
           fail("Exception should be thrown for granting non-exist role to group");
@@ -331,8 +335,8 @@ public class TestSentryShellSolr extends SentryGenericServiceIntegrationBase {
 
         // test: drop group from non-exist role with -drg
         args = new String[] { "-drg", "-r", TEST_ROLE_NAME_2, "-g", "testGroup1", "-conf",
-                confPath.getAbsolutePath() };
-        sentryShell = new SentryShellSolr();
+            confPath.getAbsolutePath(), "-t", "solr" };
+        sentryShell = new SentryShellGeneric();
         try {
           sentryShell.executeShell(args);
           fail("Exception should be thrown for drop group from non-exist role");
@@ -342,8 +346,8 @@ public class TestSentryShellSolr extends SentryGenericServiceIntegrationBase {
 
         // test: grant privilege to role with the error privilege format
         args = new String[] { "-gpr", "-r", TEST_ROLE_NAME_1, "-p", "serverserver1->action=*",
-                "-conf", confPath.getAbsolutePath() };
-        sentryShell = new SentryShellSolr();
+            "-conf", confPath.getAbsolutePath(), "-t", "solr" };
+        sentryShell = new SentryShellGeneric();
         try {
           sentryShell.executeShell(args);
           fail("Exception should be thrown for the error privilege format, invalid key value.");
@@ -353,9 +357,9 @@ public class TestSentryShellSolr extends SentryGenericServiceIntegrationBase {
 
         // test: grant privilege to role with the error privilege hierarchy
         args = new String[] { "-gpr", "-r", TEST_ROLE_NAME_1, "-p",
-                "server=server1->table=tbl1->column=col2->action=insert", "-conf",
-                confPath.getAbsolutePath() };
-        sentryShell = new SentryShellSolr();
+            "server=server1->table=tbl1->column=col2->action=insert", "-conf",
+            confPath.getAbsolutePath(), "-t", "solr" };
+        sentryShell = new SentryShellGeneric();
         try {
           sentryShell.executeShell(args);
           fail("Exception should be thrown for the error privilege format, invalid key value.");
@@ -377,63 +381,63 @@ public class TestSentryShellSolr extends SentryGenericServiceIntegrationBase {
         String strOptionConf = "conf";
         client.createRole(requestorName, TEST_ROLE_NAME_1, SOLR);
         // test: the conf is required argument
-        String[] args = { "-cr", "-r", TEST_ROLE_NAME_1 };
-        SentryShellSolr sentryShell = new SentryShellSolr();
+        String[] args = { "-cr", "-r", TEST_ROLE_NAME_1, "-t", "solr" };
+        SentryShellGeneric sentryShell = new SentryShellGeneric();
         validateMissingParameterMsg(sentryShell, args,
                 SentryShellCommon.PREFIX_MESSAGE_MISSING_OPTION + strOptionConf);
 
         // test: -r is required when create role
-        args = new String[] { "-cr", "-conf", confPath.getAbsolutePath() };
-        sentryShell = new SentryShellSolr();
+        args = new String[] { "-cr", "-conf", confPath.getAbsolutePath(), "-t", "solr" };
+        sentryShell = new SentryShellGeneric();
         validateMissingParameterMsg(sentryShell, args,
                 SentryShellCommon.PREFIX_MESSAGE_MISSING_OPTION + SentryShellCommon.OPTION_DESC_ROLE_NAME);
 
         // test: -r is required when drop role
-        args = new String[] { "-dr", "-conf", confPath.getAbsolutePath() };
-        sentryShell = new SentryShellSolr();
+        args = new String[] { "-dr", "-conf", confPath.getAbsolutePath(), "-t", "solr" };
+        sentryShell = new SentryShellGeneric();
         validateMissingParameterMsg(sentryShell, args,
                 SentryShellCommon.PREFIX_MESSAGE_MISSING_OPTION + SentryShellCommon.OPTION_DESC_ROLE_NAME);
 
         // test: -r is required when add role to group
-        args = new String[] { "-arg", "-g", "testGroup1", "-conf", confPath.getAbsolutePath() };
-        sentryShell = new SentryShellSolr();
+        args = new String[] { "-arg", "-g", "testGroup1", "-conf", confPath.getAbsolutePath(), "-t", "solr" };
+        sentryShell = new SentryShellGeneric();
         validateMissingParameterMsg(sentryShell, args,
                 SentryShellCommon.PREFIX_MESSAGE_MISSING_OPTION + SentryShellCommon.OPTION_DESC_ROLE_NAME);
 
         // test: -g is required when add role to group
-        args = new String[] { "-arg", "-r", TEST_ROLE_NAME_2, "-conf", confPath.getAbsolutePath() };
-        sentryShell = new SentryShellSolr();
+        args = new String[] { "-arg", "-r", TEST_ROLE_NAME_2, "-conf", confPath.getAbsolutePath(), "-t", "solr" };
+        sentryShell = new SentryShellGeneric();
         validateMissingParameterMsg(sentryShell, args,
                 SentryShellCommon.PREFIX_MESSAGE_MISSING_OPTION + SentryShellCommon.OPTION_DESC_GROUP_NAME);
 
         // test: -r is required when delete role from group
-        args = new String[] { "-drg", "-g", "testGroup1", "-conf", confPath.getAbsolutePath() };
-        sentryShell = new SentryShellSolr();
+        args = new String[] { "-drg", "-g", "testGroup1", "-conf", confPath.getAbsolutePath(), "-t", "solr" };
+        sentryShell = new SentryShellGeneric();
         validateMissingParameterMsg(sentryShell, args,
                 SentryShellCommon.PREFIX_MESSAGE_MISSING_OPTION + SentryShellCommon.OPTION_DESC_ROLE_NAME);
 
         // test: -g is required when delete role from group
-        args = new String[] { "-drg", "-r", TEST_ROLE_NAME_2, "-conf", confPath.getAbsolutePath() };
-        sentryShell = new SentryShellSolr();
+        args = new String[] { "-drg", "-r", TEST_ROLE_NAME_2, "-conf", confPath.getAbsolutePath(), "-t", "solr" };
+        sentryShell = new SentryShellGeneric();
         validateMissingParameterMsg(sentryShell, args,
                 SentryShellCommon.PREFIX_MESSAGE_MISSING_OPTION + SentryShellCommon.OPTION_DESC_GROUP_NAME);
 
         // test: -r is required when grant privilege to role
-        args = new String[] { "-gpr", "-p", "server=server1", "-conf", confPath.getAbsolutePath() };
-        sentryShell = new SentryShellSolr();
+        args = new String[] { "-gpr", "-p", "server=server1", "-conf", confPath.getAbsolutePath(), "-t", "solr" };
+        sentryShell = new SentryShellGeneric();
         validateMissingParameterMsg(sentryShell, args,
                 SentryShellCommon.PREFIX_MESSAGE_MISSING_OPTION + SentryShellCommon.OPTION_DESC_ROLE_NAME);
 
         // test: -p is required when grant privilege to role
-        args = new String[] { "-gpr", "-r", TEST_ROLE_NAME_1, "-conf", confPath.getAbsolutePath() };
-        sentryShell = new SentryShellSolr();
+        args = new String[] { "-gpr", "-r", TEST_ROLE_NAME_1, "-conf", confPath.getAbsolutePath(), "-t", "solr" };
+        sentryShell = new SentryShellGeneric();
         validateMissingParameterMsg(sentryShell, args,
                 SentryShellCommon.PREFIX_MESSAGE_MISSING_OPTION + SentryShellCommon.OPTION_DESC_PRIVILEGE);
 
         // test: action is required in privilege
-        args = new String[] { "-gpr", "-r", TEST_ROLE_NAME_1, "-conf", confPath.getAbsolutePath(), "-p", "collection=collection1" };
-        sentryShell = new SentryShellSolr();
-        try {
+        args = new String[] { "-gpr", "-r", TEST_ROLE_NAME_1, "-conf", confPath.getAbsolutePath(), "-p", "collection=collection1", "-t", "solr" };
+        sentryShell = new SentryShellGeneric();
+         try {
           getShellResultWithOSRedirect(sentryShell, args, false);
           fail("Expected IllegalArgumentException");
         } catch (IllegalArgumentException e) {
@@ -441,20 +445,20 @@ public class TestSentryShellSolr extends SentryGenericServiceIntegrationBase {
         }
 
         // test: -r is required when revoke privilege from role
-        args = new String[] { "-rpr", "-p", "server=server1", "-conf", confPath.getAbsolutePath() };
-        sentryShell = new SentryShellSolr();
+        args = new String[] { "-rpr", "-p", "server=server1", "-conf", confPath.getAbsolutePath(), "-t", "solr" };
+        sentryShell = new SentryShellGeneric();
         validateMissingParameterMsg(sentryShell, args,
                 SentryShellCommon.PREFIX_MESSAGE_MISSING_OPTION + SentryShellCommon.OPTION_DESC_ROLE_NAME);
 
         // test: -p is required when revoke privilege from role
-        args = new String[] { "-rpr", "-r", TEST_ROLE_NAME_1, "-conf", confPath.getAbsolutePath() };
-        sentryShell = new SentryShellSolr();
+        args = new String[] { "-rpr", "-r", TEST_ROLE_NAME_1, "-conf", confPath.getAbsolutePath(), "-t", "solr" };
+        sentryShell = new SentryShellGeneric();
         validateMissingParameterMsg(sentryShell, args,
                 SentryShellCommon.PREFIX_MESSAGE_MISSING_OPTION + SentryShellCommon.OPTION_DESC_PRIVILEGE);
 
         // test: command option is required for shell
         args = new String[] {"-conf", confPath.getAbsolutePath() };
-        sentryShell = new SentryShellSolr();
+        sentryShell = new SentryShellGeneric();
         validateMissingParameterMsgsContains(sentryShell, args,
                 SentryShellCommon.PREFIX_MESSAGE_MISSING_OPTION + "[",
                 "-arg Add role to group",
@@ -473,8 +477,8 @@ public class TestSentryShellSolr extends SentryGenericServiceIntegrationBase {
   }
 
   // redirect the System.out to ByteArrayOutputStream, then execute the command and parse the result.
-  private Set<String> getShellResultWithOSRedirect(SentryShellSolr sentryShell,
-                                                   String[] args, boolean expectedExecuteResult) throws Exception {
+  private Set<String> getShellResultWithOSRedirect(SentryShellGeneric sentryShell,
+      String[] args, boolean expectedExecuteResult) throws Exception {
     PrintStream oldOut = System.out;
     ByteArrayOutputStream outContent = new ByteArrayOutputStream();
     System.setOut(new PrintStream(outContent));
@@ -487,7 +491,7 @@ public class TestSentryShellSolr extends SentryGenericServiceIntegrationBase {
   private void validateRoleNames(Set<String> roleNames, String ... expectedRoleNames) {
     if (expectedRoleNames != null && expectedRoleNames.length > 0) {
       assertEquals("Found: " + roleNames.size() + " roles, expected: " + expectedRoleNames.length,
-              expectedRoleNames.length, roleNames.size());
+          expectedRoleNames.length, roleNames.size());
       Set<String> lowerCaseRoles = new HashSet<String>();
       for (String role : roleNames) {
         lowerCaseRoles.add(role.toLowerCase());
@@ -495,19 +499,19 @@ public class TestSentryShellSolr extends SentryGenericServiceIntegrationBase {
 
       for (String expectedRole : expectedRoleNames) {
         assertTrue("Expected role: " + expectedRole,
-                lowerCaseRoles.contains(expectedRole.toLowerCase()));
+            lowerCaseRoles.contains(expectedRole.toLowerCase()));
       }
     }
   }
 
-  private void validateMissingParameterMsg(SentryShellSolr sentryShell, String[] args,
-                                           String expectedErrorMsg) throws Exception {
+  private void validateMissingParameterMsg(SentryShellGeneric sentryShell, String[] args,
+      String expectedErrorMsg) throws Exception {
     Set<String> errorMsgs = getShellResultWithOSRedirect(sentryShell, args, false);
     assertTrue("Expected error message: " + expectedErrorMsg, errorMsgs.contains(expectedErrorMsg));
   }
 
-  private void validateMissingParameterMsgsContains(SentryShellSolr sentryShell, String[] args,
-                                                    String ... expectedErrorMsgsContains) throws Exception {
+  private void validateMissingParameterMsgsContains(SentryShellGeneric sentryShell, String[] args,
+      String ... expectedErrorMsgsContains) throws Exception {
     Set<String> errorMsgs = getShellResultWithOSRedirect(sentryShell, args, false);
     boolean foundAllMessages = false;
     Iterator<String> it = errorMsgs.iterator();

http://git-wip-us.apache.org/repos/asf/sentry/blob/5fc1e977/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/generic/tools/TestSentryShellSqoop.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/generic/tools/TestSentryShellSqoop.java b/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/generic/tools/TestSentryShellSqoop.java
index 27614eb..cdba442 100644
--- a/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/generic/tools/TestSentryShellSqoop.java
+++ b/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/generic/tools/TestSentryShellSqoop.java
@@ -78,32 +78,32 @@ public class TestSentryShellSqoop extends SentryGenericServiceIntegrationBase {
       @Override
       public void runTestAsSubject() throws Exception {
         // test: create role with -cr
-        String[] args = { "-cr", "-r", TEST_ROLE_NAME_1, "-conf", confPath.getAbsolutePath() };
-        SentryShellSqoop.main(args);
+        String[] args = { "-cr", "-r", TEST_ROLE_NAME_1, "-conf", confPath.getAbsolutePath(), "-t", "sqoop" };
+        SentryShellGeneric.main(args);
         // test: create role with --create_role
         args = new String[] { "--create_role", "-r", TEST_ROLE_NAME_2, "-conf",
-            confPath.getAbsolutePath() };
-        SentryShellSqoop.main(args);
+            confPath.getAbsolutePath(), "-t", "sqoop" };
+        SentryShellGeneric.main(args);
 
         // validate the result, list roles with -lr
-        args = new String[] { "-lr", "-conf", confPath.getAbsolutePath() };
-        SentryShellSqoop sentryShell = new SentryShellSqoop();
+        args = new String[] { "-lr", "-conf", confPath.getAbsolutePath(), "-t", "sqoop" };
+        SentryShellGeneric sentryShell = new SentryShellGeneric();
         Set<String> roleNames = getShellResultWithOSRedirect(sentryShell, args, true);
         validateRoleNames(roleNames, TEST_ROLE_NAME_1, TEST_ROLE_NAME_2);
 
         // validate the result, list roles with --list_role
-        args = new String[] { "--list_role", "-conf", confPath.getAbsolutePath() };
-        sentryShell = new SentryShellSqoop();
+        args = new String[] { "--list_role", "-conf", confPath.getAbsolutePath(), "-t", "sqoop" };
+        sentryShell = new SentryShellGeneric();
         roleNames = getShellResultWithOSRedirect(sentryShell, args, true);
         validateRoleNames(roleNames, TEST_ROLE_NAME_1, TEST_ROLE_NAME_2);
 
         // test: drop role with -dr
-        args = new String[] { "-dr", "-r", TEST_ROLE_NAME_1, "-conf", confPath.getAbsolutePath() };
-        SentryShellSqoop.main(args);
+        args = new String[] { "-dr", "-r", TEST_ROLE_NAME_1, "-conf", confPath.getAbsolutePath(), "-t", "sqoop" };
+        SentryShellGeneric.main(args);
         // test: drop role with --drop_role
         args = new String[] { "--drop_role", "-r", TEST_ROLE_NAME_2, "-conf",
-            confPath.getAbsolutePath() };
-        SentryShellSqoop.main(args);
+            confPath.getAbsolutePath(), "-t", "sqoop" };
+        SentryShellGeneric.main(args);
 
         // validate the result
         Set<TSentryRole> roles = client.listAllRoles(requestorName, AuthorizationComponent.SQOOP);
@@ -127,41 +127,41 @@ public class TestSentryShellSqoop extends SentryGenericServiceIntegrationBase {
         client.createRole(requestorName, TEST_ROLE_NAME_2, AuthorizationComponent.SQOOP);
         // test: add role to group with -arg
         String[] args = { "-arg", "-r", TEST_ROLE_NAME_1, "-g", TEST_GROUP_1, "-conf",
-            confPath.getAbsolutePath() };
-        SentryShellSqoop.main(args);
+            confPath.getAbsolutePath(), "-t", "sqoop" };
+        SentryShellGeneric.main(args);
         // test: add role to multiple groups
         args = new String[] { "-arg", "-r", TEST_ROLE_NAME_1, "-g", TEST_GROUP_2 + "," + TEST_GROUP_3,
             "-conf",
-            confPath.getAbsolutePath() };
-        SentryShellSqoop.main(args);
+            confPath.getAbsolutePath(), "-t", "sqoop" };
+        SentryShellGeneric.main(args);
         // test: add role to group with --add_role_group
         args = new String[] { "--add_role_group", "-r", TEST_ROLE_NAME_2, "-g", TEST_GROUP_1,
             "-conf",
-            confPath.getAbsolutePath() };
-        SentryShellSqoop.main(args);
+            confPath.getAbsolutePath(), "-t", "sqoop" };
+        SentryShellGeneric.main(args);
 
         // validate the result list roles with -lr and -g
-        args = new String[] { "-lr", "-g", TEST_GROUP_1, "-conf", confPath.getAbsolutePath() };
-        SentryShellSqoop sentryShell = new SentryShellSqoop();
+        args = new String[] { "-lr", "-g", TEST_GROUP_1, "-conf", confPath.getAbsolutePath(), "-t", "sqoop" };
+        SentryShellGeneric sentryShell = new SentryShellGeneric();
         Set<String> roleNames = getShellResultWithOSRedirect(sentryShell, args, true);
         validateRoleNames(roleNames, TEST_ROLE_NAME_1, TEST_ROLE_NAME_2);
 
         // list roles with --list_role and -g
         args = new String[] { "--list_role", "-g", TEST_GROUP_2, "-conf",
-            confPath.getAbsolutePath() };
-        sentryShell = new SentryShellSqoop();
+            confPath.getAbsolutePath(), "-t", "sqoop" };
+        sentryShell = new SentryShellGeneric();
         roleNames = getShellResultWithOSRedirect(sentryShell, args, true);
         validateRoleNames(roleNames, TEST_ROLE_NAME_1);
 
         args = new String[] { "--list_role", "-g", TEST_GROUP_3, "-conf",
-            confPath.getAbsolutePath() };
-        sentryShell = new SentryShellSqoop();
+            confPath.getAbsolutePath(), "-t", "sqoop" };
+        sentryShell = new SentryShellGeneric();
         roleNames = getShellResultWithOSRedirect(sentryShell, args, true);
         validateRoleNames(roleNames, TEST_ROLE_NAME_1);
 
         // List the groups and roles via listGroups
-        args = new String[] { "--list_group", "-conf", confPath.getAbsolutePath()};
-        sentryShell = new SentryShellSqoop();
+        args = new String[] { "--list_group", "-conf", confPath.getAbsolutePath(), "-t", "sqoop" };
+        sentryShell = new SentryShellGeneric();
         Set<String> groups = getShellResultWithOSRedirect(sentryShell, args, true);
         assertEquals(3, groups.size());
         assertTrue(groups.contains("testGroup3 = testrole1"));
@@ -170,17 +170,17 @@ public class TestSentryShellSqoop extends SentryGenericServiceIntegrationBase {
 
         // test: delete role from group with -drg
         args = new String[] { "-drg", "-r", TEST_ROLE_NAME_1, "-g", TEST_GROUP_1, "-conf",
-            confPath.getAbsolutePath() };
-        SentryShellSqoop.main(args);
+            confPath.getAbsolutePath(), "-t", "sqoop" };
+        SentryShellGeneric.main(args);
         // test: delete role to multiple groups
         args = new String[] { "-drg", "-r", TEST_ROLE_NAME_1, "-g", TEST_GROUP_2 + "," + TEST_GROUP_3,
             "-conf",
-            confPath.getAbsolutePath() };
-        SentryShellSqoop.main(args);
+            confPath.getAbsolutePath(), "-t", "sqoop" };
+        SentryShellGeneric.main(args);
         // test: delete role from group with --delete_role_group
         args = new String[] { "--delete_role_group", "-r", TEST_ROLE_NAME_2, "-g", TEST_GROUP_1,
-            "-conf", confPath.getAbsolutePath() };
-        SentryShellSqoop.main(args);
+            "-conf", confPath.getAbsolutePath(), "-t", "sqoop" };
+        SentryShellGeneric.main(args);
 
         // validate the result
         Set<TSentryRole> roles = client.listRolesByGroupName(requestorName, TEST_GROUP_1, AuthorizationComponent.SQOOP);
@@ -206,17 +206,17 @@ public class TestSentryShellSqoop extends SentryGenericServiceIntegrationBase {
         client.createRole(requestorName, TEST_ROLE_NAME_1, AuthorizationComponent.SQOOP);
         // add role to a group (lower case)
         String[] args = {"-arg", "-r", TEST_ROLE_NAME_1, "-g", "group1", "-conf",
-            confPath.getAbsolutePath()};
-        SentryShellSqoop.main(args);
+            confPath.getAbsolutePath(), "-t", "sqoop"};
+        SentryShellGeneric.main(args);
 
         // validate the roles when group name is same case as above
-        args = new String[]{"-lr", "-g", "group1", "-conf", confPath.getAbsolutePath()};
-        SentryShellSqoop sentryShell = new SentryShellSqoop();
+        args = new String[]{"-lr", "-g", "group1", "-conf", confPath.getAbsolutePath(), "-t", "sqoop"};
+        SentryShellGeneric sentryShell = new SentryShellGeneric();
         Set<String> roleNames = getShellResultWithOSRedirect(sentryShell, args, true);
         validateRoleNames(roleNames, TEST_ROLE_NAME_1);
 
         // roles should be empty when group name is different case than above
-        args = new String[]{"-lr", "-g", "GROUP1", "-conf", confPath.getAbsolutePath()};
+        args = new String[]{"-lr", "-g", "GROUP1", "-conf", confPath.getAbsolutePath(), "-t", "sqoop"};
         roleNames = getShellResultWithOSRedirect(sentryShell, args, true);
         validateRoleNames(roleNames);
       }
@@ -252,13 +252,13 @@ public class TestSentryShellSqoop extends SentryGenericServiceIntegrationBase {
           // test: grant privilege to role
           String [] args = new String [] { grant(shortOption), "-r", TEST_ROLE_NAME_1, "-p",
             privs[ i ],
-            "-conf", confPath.getAbsolutePath() };
-          SentryShellSqoop.main(args);
+            "-conf", confPath.getAbsolutePath(), "-t", "sqoop" };
+          SentryShellGeneric.main(args);
         }
 
         // test the list privilege
-        String [] args = new String[] { list(shortOption), "-r", TEST_ROLE_NAME_1, "-conf", confPath.getAbsolutePath() };
-        SentryShellSqoop sentryShell = new SentryShellSqoop();
+        String [] args = new String[] { list(shortOption), "-r", TEST_ROLE_NAME_1, "-conf", confPath.getAbsolutePath(), "-t", "sqoop" };
+        SentryShellGeneric sentryShell = new SentryShellGeneric();
         Set<String> privilegeStrs = getShellResultWithOSRedirect(sentryShell, args, true);
 
         assertEquals("Incorrect number of privileges", privs.length, privilegeStrs.size());
@@ -269,8 +269,8 @@ public class TestSentryShellSqoop extends SentryGenericServiceIntegrationBase {
         for (int i = 0; i < privs.length; ++i) {
           args = new String[] { revoke(shortOption), "-r", TEST_ROLE_NAME_1, "-p",
             privs[ i ], "-conf",
-            confPath.getAbsolutePath()};
-          SentryShellSqoop.main(args);
+            confPath.getAbsolutePath(), "-t", "sqoop" };
+          SentryShellGeneric.main(args);
           Set<TSentryPrivilege> privileges = client.listAllPrivilegesByRoleName(requestorName,
             TEST_ROLE_NAME_1, AuthorizationComponent.SQOOP, service);
           assertEquals("Incorrect number of privileges. Received privileges: " + Arrays.toString(privileges.toArray()), privs.length - (i + 1), privileges.size());
@@ -301,8 +301,8 @@ public class TestSentryShellSqoop extends SentryGenericServiceIntegrationBase {
       public void runTestAsSubject() throws Exception {
         client.createRole(requestorName, TEST_ROLE_NAME_1, AuthorizationComponent.SQOOP);
         // test: create duplicate role with -cr
-        String[] args = { "-cr", "-r", TEST_ROLE_NAME_1, "-conf", confPath.getAbsolutePath() };
-        SentryShellSqoop sentryShell = new SentryShellSqoop();
+        String[] args = { "-cr", "-r", TEST_ROLE_NAME_1, "-conf", confPath.getAbsolutePath(), "-t", "sqoop" };
+        SentryShellGeneric sentryShell = new SentryShellGeneric();
         try {
           sentryShell.executeShell(args);
           fail("Exception should be thrown for creating duplicate role");
@@ -313,8 +313,8 @@ public class TestSentryShellSqoop extends SentryGenericServiceIntegrationBase {
         }
 
         // test: drop non-exist role with -dr
-        args = new String[] { "-dr", "-r", TEST_ROLE_NAME_2, "-conf", confPath.getAbsolutePath() };
-        sentryShell = new SentryShellSqoop();
+        args = new String[] { "-dr", "-r", TEST_ROLE_NAME_2, "-conf", confPath.getAbsolutePath(), "-t", "sqoop" };
+        sentryShell = new SentryShellGeneric();
         try {
           sentryShell.executeShell(args);
           fail("Exception should be thrown for dropping non-exist role");
@@ -326,8 +326,8 @@ public class TestSentryShellSqoop extends SentryGenericServiceIntegrationBase {
 
         // test: add non-exist role to group with -arg
         args = new String[] { "-arg", "-r", TEST_ROLE_NAME_2, "-g", "testGroup1", "-conf",
-            confPath.getAbsolutePath() };
-        sentryShell = new SentryShellSqoop();
+            confPath.getAbsolutePath(), "-t", "sqoop" };
+        sentryShell = new SentryShellGeneric();
         try {
           sentryShell.executeShell(args);
           fail("Exception should be thrown for granting non-exist role to group");
@@ -339,8 +339,8 @@ public class TestSentryShellSqoop extends SentryGenericServiceIntegrationBase {
 
         // test: drop group from non-exist role with -drg
         args = new String[] { "-drg", "-r", TEST_ROLE_NAME_2, "-g", "testGroup1", "-conf",
-            confPath.getAbsolutePath() };
-        sentryShell = new SentryShellSqoop();
+            confPath.getAbsolutePath(), "-t", "sqoop" };
+        sentryShell = new SentryShellGeneric();
         try {
           sentryShell.executeShell(args);
           fail("Exception should be thrown for drop group from non-exist role");
@@ -352,8 +352,8 @@ public class TestSentryShellSqoop extends SentryGenericServiceIntegrationBase {
 
         // test: grant privilege to role with the error privilege format
         args = new String[] { "-gpr", "-r", TEST_ROLE_NAME_1, "-p", "serverserver1->action=all",
-            "-conf", confPath.getAbsolutePath() };
-        sentryShell = new SentryShellSqoop();
+            "-conf", confPath.getAbsolutePath(), "-t", "sqoop" };
+        sentryShell = new SentryShellGeneric();
         try {
           sentryShell.executeShell(args);
           fail("Exception should be thrown for the error privilege format, invalid key value.");
@@ -377,62 +377,62 @@ public class TestSentryShellSqoop extends SentryGenericServiceIntegrationBase {
         String strOptionConf = "conf";
         client.createRole(requestorName, TEST_ROLE_NAME_1, AuthorizationComponent.SQOOP);
         // test: the conf is required argument
-        String[] args = { "-cr", "-r", TEST_ROLE_NAME_1 };
-        SentryShellSqoop sentryShell = new SentryShellSqoop();
+        String[] args = { "-cr", "-r", TEST_ROLE_NAME_1, "-t", "sqoop" };
+        SentryShellGeneric sentryShell = new SentryShellGeneric();
         validateMissingParameterMsg(sentryShell, args,
                 SentryShellCommon.PREFIX_MESSAGE_MISSING_OPTION + strOptionConf);
 
         // test: -r is required when create role
-        args = new String[] { "-cr", "-conf", confPath.getAbsolutePath() };
-        sentryShell = new SentryShellSqoop();
+        args = new String[] { "-cr", "-conf", confPath.getAbsolutePath(), "-t", "sqoop" };
+        sentryShell = new SentryShellGeneric();
         validateMissingParameterMsg(sentryShell, args,
                 SentryShellCommon.PREFIX_MESSAGE_MISSING_OPTION + SentryShellCommon.OPTION_DESC_ROLE_NAME);
 
         // test: -r is required when drop role
-        args = new String[] { "-dr", "-conf", confPath.getAbsolutePath() };
-        sentryShell = new SentryShellSqoop();
+        args = new String[] { "-dr", "-conf", confPath.getAbsolutePath(), "-t", "sqoop" };
+        sentryShell = new SentryShellGeneric();
         validateMissingParameterMsg(sentryShell, args,
                 SentryShellCommon.PREFIX_MESSAGE_MISSING_OPTION + SentryShellCommon.OPTION_DESC_ROLE_NAME);
 
         // test: -r is required when add role to group
-        args = new String[] { "-arg", "-g", "testGroup1", "-conf", confPath.getAbsolutePath() };
-        sentryShell = new SentryShellSqoop();
+        args = new String[] { "-arg", "-g", "testGroup1", "-conf", confPath.getAbsolutePath(), "-t", "sqoop" };
+        sentryShell = new SentryShellGeneric();
         validateMissingParameterMsg(sentryShell, args,
                 SentryShellCommon.PREFIX_MESSAGE_MISSING_OPTION + SentryShellCommon.OPTION_DESC_ROLE_NAME);
 
         // test: -g is required when add role to group
-        args = new String[] { "-arg", "-r", TEST_ROLE_NAME_2, "-conf", confPath.getAbsolutePath() };
-        sentryShell = new SentryShellSqoop();
+        args = new String[] { "-arg", "-r", TEST_ROLE_NAME_2, "-conf", confPath.getAbsolutePath(), "-t", "sqoop" };
+        sentryShell = new SentryShellGeneric();
         validateMissingParameterMsg(sentryShell, args,
                 SentryShellCommon.PREFIX_MESSAGE_MISSING_OPTION + SentryShellCommon.OPTION_DESC_GROUP_NAME);
 
         // test: -r is required when delete role from group
-        args = new String[] { "-drg", "-g", "testGroup1", "-conf", confPath.getAbsolutePath() };
-        sentryShell = new SentryShellSqoop();
+        args = new String[] { "-drg", "-g", "testGroup1", "-conf", confPath.getAbsolutePath(), "-t", "sqoop" };
+        sentryShell = new SentryShellGeneric();
         validateMissingParameterMsg(sentryShell, args,
                 SentryShellCommon.PREFIX_MESSAGE_MISSING_OPTION + SentryShellCommon.OPTION_DESC_ROLE_NAME);
 
         // test: -g is required when delete role from group
-        args = new String[] { "-drg", "-r", TEST_ROLE_NAME_2, "-conf", confPath.getAbsolutePath() };
-        sentryShell = new SentryShellSqoop();
+        args = new String[] { "-drg", "-r", TEST_ROLE_NAME_2, "-conf", confPath.getAbsolutePath(), "-t", "sqoop" };
+        sentryShell = new SentryShellGeneric();
         validateMissingParameterMsg(sentryShell, args,
                 SentryShellCommon.PREFIX_MESSAGE_MISSING_OPTION + SentryShellCommon.OPTION_DESC_GROUP_NAME);
 
         // test: -r is required when grant privilege to role
-        args = new String[] { "-gpr", "-p", "server=server1", "-conf", confPath.getAbsolutePath() };
-        sentryShell = new SentryShellSqoop();
+        args = new String[] { "-gpr", "-p", "server=server1", "-conf", confPath.getAbsolutePath(), "-t", "sqoop" };
+        sentryShell = new SentryShellGeneric();
         validateMissingParameterMsg(sentryShell, args,
                 SentryShellCommon.PREFIX_MESSAGE_MISSING_OPTION + SentryShellCommon.OPTION_DESC_ROLE_NAME);
 
         // test: -p is required when grant privilege to role
-        args = new String[] { "-gpr", "-r", TEST_ROLE_NAME_1, "-conf", confPath.getAbsolutePath() };
-        sentryShell = new SentryShellSqoop();
+        args = new String[] { "-gpr", "-r", TEST_ROLE_NAME_1, "-conf", confPath.getAbsolutePath(), "-t", "sqoop" };
+        sentryShell = new SentryShellGeneric();
         validateMissingParameterMsg(sentryShell, args,
                 SentryShellCommon.PREFIX_MESSAGE_MISSING_OPTION + SentryShellCommon.OPTION_DESC_PRIVILEGE);
 
         // test: action is required in privilege
-        args = new String[] { "-gpr", "-r", TEST_ROLE_NAME_1, "-conf", confPath.getAbsolutePath(), "-p", "Server=sqoopServer1->Connector" };
-        sentryShell = new SentryShellSqoop();
+        args = new String[] { "-gpr", "-r", TEST_ROLE_NAME_1, "-conf", confPath.getAbsolutePath(), "-p", "Server=sqoopServer1->Connector", "-t", "sqoop" };
+        sentryShell = new SentryShellGeneric();
          try {
           getShellResultWithOSRedirect(sentryShell, args, false);
           fail("Expected IllegalArgumentException");
@@ -443,20 +443,20 @@ public class TestSentryShellSqoop extends SentryGenericServiceIntegrationBase {
          }
 
         // test: -r is required when revoke privilege from role
-        args = new String[] { "-rpr", "-p", "Server=sqoopServer1->Connector->action=*", "-conf", confPath.getAbsolutePath() };
-        sentryShell = new SentryShellSqoop();
+        args = new String[] { "-rpr", "-p", "Server=sqoopServer1->Connector->action=*", "-conf", confPath.getAbsolutePath(), "-t", "sqoop" };
+        sentryShell = new SentryShellGeneric();
         validateMissingParameterMsg(sentryShell, args,
                 SentryShellCommon.PREFIX_MESSAGE_MISSING_OPTION + SentryShellCommon.OPTION_DESC_ROLE_NAME);
 
         // test: -p is required when revoke privilege from role
-        args = new String[] { "-rpr", "-r", TEST_ROLE_NAME_1, "-conf", confPath.getAbsolutePath() };
-        sentryShell = new SentryShellSqoop();
+        args = new String[] { "-rpr", "-r", TEST_ROLE_NAME_1, "-conf", confPath.getAbsolutePath(), "-t", "sqoop" };
+        sentryShell = new SentryShellGeneric();
         validateMissingParameterMsg(sentryShell, args,
                 SentryShellCommon.PREFIX_MESSAGE_MISSING_OPTION + SentryShellCommon.OPTION_DESC_PRIVILEGE);
 
         // test: command option is required for shell
-        args = new String[] {"-conf", confPath.getAbsolutePath() };
-        sentryShell = new SentryShellSqoop();
+        args = new String[] {"-conf", confPath.getAbsolutePath(), "-t", "sqoop" };
+        sentryShell = new SentryShellGeneric();
         validateMissingParameterMsgsContains(sentryShell, args,
                 SentryShellCommon.PREFIX_MESSAGE_MISSING_OPTION + "[",
                 "-arg Add role to group",
@@ -475,7 +475,7 @@ public class TestSentryShellSqoop extends SentryGenericServiceIntegrationBase {
   }
 
   // redirect the System.out to ByteArrayOutputStream, then execute the command and parse the result.
-  private Set<String> getShellResultWithOSRedirect(SentryShellSqoop sentryShell,
+  private Set<String> getShellResultWithOSRedirect(SentryShellGeneric sentryShell,
       String[] args, boolean expectedExecuteResult) throws Exception {
     PrintStream oldOut = System.out;
     ByteArrayOutputStream outContent = new ByteArrayOutputStream();
@@ -502,13 +502,13 @@ public class TestSentryShellSqoop extends SentryGenericServiceIntegrationBase {
     }
   }
 
-  private void validateMissingParameterMsg(SentryShellSqoop sentryShell, String[] args,
+  private void validateMissingParameterMsg(SentryShellGeneric sentryShell, String[] args,
       String expectedErrorMsg) throws Exception {
     Set<String> errorMsgs = getShellResultWithOSRedirect(sentryShell, args, false);
     assertTrue("Expected error message: " + expectedErrorMsg, errorMsgs.contains(expectedErrorMsg));
   }
 
-  private void validateMissingParameterMsgsContains(SentryShellSqoop sentryShell, String[] args,
+  private void validateMissingParameterMsgsContains(SentryShellGeneric sentryShell, String[] args,
       String ... expectedErrorMsgsContains) throws Exception {
     Set<String> errorMsgs = getShellResultWithOSRedirect(sentryShell, args, false);
     boolean foundAllMessages = false;


Mime
View raw message