@Test public void testGrantRevokePrivilegeWithLongOption() throws Exception { runTestAsSubject(new TestOperation() { @Override public void runTestAsSubject() throws Exception { client.createRole(requestorName, TEST_ROLE_NAME_1); client.createRole(requestorName, TEST_ROLE_NAME_2); String[] args = { "--grant_privilege_role", "-r", TEST_ROLE_NAME_1, "-p", "server=server1->action=*", "-conf", confPath.getAbsolutePath() }; SentryShellHive.main(args); args = new String[] { "--grant_privilege_role", "-r", TEST_ROLE_NAME_1, "-p", "server=server1->db=db1->action=select", "-conf", confPath.getAbsolutePath() }; SentryShellHive.main(args); args = new String[] { "--grant_privilege_role", "-r", TEST_ROLE_NAME_1, "-p", "server=server1->db=db1->table=tbl1->action=insert", "-conf", confPath.getAbsolutePath() }; SentryShellHive.main(args); args = new String[] { "--grant_privilege_role", "-r", TEST_ROLE_NAME_1, "-p", "server=server1->db=db1->table=tbl1->column=col1->action=insert", "-conf", confPath.getAbsolutePath() }; SentryShellHive.main(args); args = new String[] { "--grant_privilege_role", "-r", TEST_ROLE_NAME_1, "-p", "server=server1->db=db1->table=tbl1->column=col2->action=insert->grantoption=true", "-conf", confPath.getAbsolutePath() }; SentryShellHive.main(args); args = new String[] { "--grant_privilege_role", "-r", TEST_ROLE_NAME_1, "-p", "server=server1->uri=hdfs: SentryShellHive.main(args); args = new String[] { "--list_privilege", "-r", TEST_ROLE_NAME_1, "-conf", confPath.getAbsolutePath() }; SentryShellHive sentryShell = new SentryShellHive(); Set<String> privilegeStrs = getShellResultWithOSRedirect(sentryShell, args, true); assertEquals("Incorrect number of privileges", 6, privilegeStrs.size()); assertTrue(privilegeStrs.contains("server=server1->action=*")); assertTrue(privilegeStrs.contains("server=server1->db=db1->action=select")); assertTrue(privilegeStrs.contains("server=server1->db=db1->table=tbl1->action=insert")); assertTrue(privilegeStrs .contains("server=server1->db=db1->table=tbl1->column=col1->action=insert")); assertTrue(privilegeStrs .contains("server=server1->db=db1->table=tbl1->column=col2->action=insert->grantoption=true")); assertTrue(privilegeStrs.contains("server=server1->uri=hdfs: args = new String[] { "--revoke_privilege_role", "-r", TEST_ROLE_NAME_1, "-p", "server=server1->db=db1->table=tbl1->column=col1->action=insert", "-conf", confPath.getAbsolutePath() }; SentryShellHive.main(args); Set<TSentryPrivilege> privileges = client.listAllPrivilegesByRoleName(requestorName, TEST_ROLE_NAME_1); assertEquals("Incorrect number of privileges", 5, privileges.size()); args = new String[] { "--revoke_privilege_role", "-r", TEST_ROLE_NAME_1, "-p", "server=server1->db=db1->table=tbl1->column=col2->action=insert->grantoption=true", "-conf", confPath.getAbsolutePath() }; SentryShellHive.main(args); privileges = client.listAllPrivilegesByRoleName(requestorName, TEST_ROLE_NAME_1); assertEquals("Incorrect number of privileges", 4, privileges.size()); args = new String[] { "--revoke_privilege_role", "-r", TEST_ROLE_NAME_1, "-p", "server=server1->uri=hdfs: SentryShellHive.main(args); privileges = client.listAllPrivilegesByRoleName(requestorName, TEST_ROLE_NAME_1); assertEquals("Incorrect number of privileges", 3, privileges.size()); args = new String[] { "--revoke_privilege_role", "-r", TEST_ROLE_NAME_1, "-p", "server=server1->db=db1->table=tbl1->action=insert", "-conf", confPath.getAbsolutePath() }; SentryShellHive.main(args); privileges = client.listAllPrivilegesByRoleName(requestorName, TEST_ROLE_NAME_1); assertEquals("Incorrect number of privileges", 2, privileges.size()); args = new String[] { "--revoke_privilege_role", "-r", TEST_ROLE_NAME_1, "-p", "server=server1->db=db1->action=select", "-conf", confPath.getAbsolutePath() }; SentryShellHive.main(args); privileges = client.listAllPrivilegesByRoleName(requestorName, TEST_ROLE_NAME_1); assertEquals("Incorrect number of privileges", 1, privileges.size()); args = new String[] { "--revoke_privilege_role", "-r", TEST_ROLE_NAME_1, "-p", "server=server1->action=*", "-conf", confPath.getAbsolutePath() }; SentryShellHive.main(args); privileges = client.listAllPrivilegesByRoleName(requestorName, TEST_ROLE_NAME_1); assertEquals("Incorrect number of privileges", 0, privileges.size()); client.dropRole(requestorName, TEST_ROLE_NAME_1); client.dropRole(requestorName, TEST_ROLE_NAME_2); } }); }
public static void main(String[] args) throws Exception { SentryShellHive sentryShell = new SentryShellHive(); try { sentryShell.executeShell(args); } catch (Exception e) { LOGGER.error(e.getMessage(), e); Throwable current = e; while (current != null && current.getMessage() == null) { current = current.getCause(); } System.out.println("The operation failed." + (current.getMessage() == null ? "" : " Message: " + current.getMessage())); } }
SentryShellHive extends SentryShellCommon { public static void main(String[] args) throws Exception { SentryShellHive sentryShell = new SentryShellHive(); try { sentryShell.executeShell(args); } catch (Exception e) { LOGGER.error(e.getMessage(), e); Throwable current = e; while (current != null && current.getMessage() == null) { current = current.getCause(); } System.out.println("The operation failed." + (current.getMessage() == null ? "" : " Message: " + current.getMessage())); } } }
SentryShellHive extends SentryShellCommon { public static void main(String[] args) throws Exception { SentryShellHive sentryShell = new SentryShellHive(); try { sentryShell.executeShell(args); } catch (Exception e) { LOGGER.error(e.getMessage(), e); Throwable current = e; while (current != null && current.getMessage() == null) { current = current.getCause(); } System.out.println("The operation failed." + (current.getMessage() == null ? "" : " Message: " + current.getMessage())); } }  }
SentryShellHive extends SentryShellCommon { public static void main(String[] args) throws Exception { SentryShellHive sentryShell = new SentryShellHive(); try { sentryShell.executeShell(args); } catch (Exception e) { LOGGER.error(e.getMessage(), e); Throwable current = e; while (current != null && current.getMessage() == null) { current = current.getCause(); } System.out.println("The operation failed." + (current.getMessage() == null ? "" : " Message: " + current.getMessage())); } }  void run(); static void main(String[] args); }
SentryShellHive extends SentryShellCommon { public static void main(String[] args) throws Exception { SentryShellHive sentryShell = new SentryShellHive(); try { sentryShell.executeShell(args); } catch (Exception e) { LOGGER.error(e.getMessage(), e); Throwable current = e; while (current != null && current.getMessage() == null) { current = current.getCause(); } System.out.println("The operation failed." + (current.getMessage() == null ? "" : " Message: " + current.getMessage())); } }  void run(); static void main(String[] args);  }