sentry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gcha...@apache.org
Subject incubator-sentry git commit: SENTRY-1039: Sentry shell tests assume order of option group privileges (Gregory Chanan, reviewed by Lenni Kuff)
Date Tue, 02 Feb 2016 19:19:01 GMT
Repository: incubator-sentry
Updated Branches:
  refs/heads/master 39d07318d -> a442fa679


SENTRY-1039: Sentry shell tests assume order of option group privileges (Gregory Chanan, reviewed
by Lenni Kuff)


Project: http://git-wip-us.apache.org/repos/asf/incubator-sentry/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-sentry/commit/a442fa67
Tree: http://git-wip-us.apache.org/repos/asf/incubator-sentry/tree/a442fa67
Diff: http://git-wip-us.apache.org/repos/asf/incubator-sentry/diff/a442fa67

Branch: refs/heads/master
Commit: a442fa679e4070dd01aef8fead08571f5482f7fc
Parents: 39d0731
Author: Gregory Chanan <gchanan@cloudera.com>
Authored: Sat Jan 30 19:29:29 2016 -0800
Committer: Gregory Chanan <gchanan@cloudera.com>
Committed: Tue Feb 2 11:17:34 2016 -0800

----------------------------------------------------------------------
 .../db/generic/tools/TestSentryShellSolr.java   | 37 +++++++++++++++++---
 .../provider/db/tools/TestSentryShellHive.java  | 37 +++++++++++++++++---
 2 files changed, 66 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/a442fa67/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 354cf35..6405bc9 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
@@ -30,6 +30,7 @@ import java.io.File;
 import java.io.FileOutputStream;
 import java.io.PrintStream;
 import java.security.PrivilegedExceptionAction;
+import java.util.Iterator;
 import java.util.Set;
 import javax.security.auth.Subject;
 
@@ -415,10 +416,16 @@ public class TestSentryShellSolr extends SentryGenericServiceIntegrationBase
{
         // test: command option is required for shell
         args = new String[] {"-conf", confPath.getAbsolutePath() };
         sentryShell = new SentryShellSolr();
-        validateMissingParameterMsg(sentryShell, args,
-                SentryShellCommon.PREFIX_MESSAGE_MISSING_OPTION + "[-arg Add group to role,"
+
-                        " -cr Create role, -rpr Revoke privilege from role, -drg Delete group
from role," +
-                        " -lr List role, -lp List privilege, -gpr Grant privilege to role,
-dr Drop role]");
+        validateMissingParameterMsgsContains(sentryShell, args,
+                SentryShellCommon.PREFIX_MESSAGE_MISSING_OPTION + "[",
+                "-arg Add group to role",
+                "-cr Create role",
+                "-rpr Revoke privilege from role",
+                "-drg Delete group from role",
+                "-lr List role",
+                "-lp List privilege",
+                "-gpr Grant privilege to role",
+                "-dr Drop role");
 
         // clear the test data
         client.dropRole(requestorName, TEST_ROLE_NAME_1, SOLR);
@@ -443,4 +450,26 @@ public class TestSentryShellSolr extends SentryGenericServiceIntegrationBase
{
     Set<String> errorMsgs = getShellResultWithOSRedirect(sentryShell, args, false);
     assertTrue(errorMsgs.contains(exceptedErrorMsg));
   }
+
+  private void validateMissingParameterMsgsContains(SentryShellSolr sentryShell, String[]
args,
+      String ... expectedErrorMsgsContains) throws Exception {
+    Set<String> errorMsgs = getShellResultWithOSRedirect(sentryShell, args, false);
+    boolean foundAllMessages = false;
+    Iterator<String> it = errorMsgs.iterator();
+    while (it.hasNext()) {
+      String errorMessage = it.next();
+      boolean missingExpected = false;
+      for (String expectedContains : expectedErrorMsgsContains) {
+        if (!errorMessage.contains(expectedContains)) {
+          missingExpected = true;
+          break;
+        }
+      }
+      if (!missingExpected) {
+        foundAllMessages = true;
+        break;
+      }
+    }
+    assertTrue(foundAllMessages);
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/a442fa67/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/tools/TestSentryShellHive.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/tools/TestSentryShellHive.java
b/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/tools/TestSentryShellHive.java
index 3907200..7883929 100644
--- a/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/tools/TestSentryShellHive.java
+++ b/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/tools/TestSentryShellHive.java
@@ -26,6 +26,7 @@ import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.PrintStream;
+import java.util.Iterator;
 import java.util.Set;
 
 import junit.framework.Assert;
@@ -552,10 +553,16 @@ public class TestSentryShellHive extends SentryServiceIntegrationBase
{
         // test: command option is required for shell
         args = new String[] {"-conf", confPath.getAbsolutePath() };
         sentryShell = new SentryShellHive();
-        validateMissingParameterMsg(sentryShell, args,
-                SentryShellCommon.PREFIX_MESSAGE_MISSING_OPTION + "[-arg Add group to role,"
+
-                        " -cr Create role, -rpr Revoke privilege from role, -drg Delete group
from role," +
-                        " -lr List role, -lp List privilege, -gpr Grant privilege to role,
-dr Drop role]");
+        validateMissingParameterMsgsContains(sentryShell, args,
+                SentryShellCommon.PREFIX_MESSAGE_MISSING_OPTION + "[",
+                "-arg Add group to role",
+                "-cr Create role",
+                "-rpr Revoke privilege from role",
+                "-drg Delete group from role",
+                "-lr List role",
+                "-lp List privilege",
+                "-gpr Grant privilege to role",
+                "-dr Drop role");
 
         // clear the test data
         client.dropRole(requestorName, TEST_ROLE_NAME_1);
@@ -580,4 +587,26 @@ public class TestSentryShellHive extends SentryServiceIntegrationBase
{
     Set<String> errorMsgs = getShellResultWithOSRedirect(sentryShell, args, false);
     Assert.assertTrue(errorMsgs.contains(exceptedErrorMsg));
   }
+
+  private void validateMissingParameterMsgsContains(SentryShellHive sentryShell, String[]
args,
+      String ... expectedErrorMsgsContains) throws Exception {
+    Set<String> errorMsgs = getShellResultWithOSRedirect(sentryShell, args, false);
+    boolean foundAllMessages = false;
+    Iterator<String> it = errorMsgs.iterator();
+    while (it.hasNext()) {
+      String errorMessage = it.next();
+      boolean missingExpected = false;
+      for (String expectedContains : expectedErrorMsgsContains) {
+        if (!errorMessage.contains(expectedContains)) {
+          missingExpected = true;
+          break;
+        }
+      }
+      if (!missingExpected) {
+        foundAllMessages = true;
+        break;
+      }
+    }
+    assertTrue(foundAllMessages);
+  }
 }


Mime
View raw message