Class SecureTestUtil

java.lang.Object
org.apache.hadoop.hbase.security.access.SecureTestUtil
Direct Known Subclasses:
SnapshotWithAclTestBase, TestAccessControlFilter, TestAccessController, TestAccessController2, TestAccessController3, TestCellACLs, TestCellACLWithMultipleVersions, TestCoprocessorWhitelistMasterObserver, TestNamespaceCommands, TestRSGroupsWithACL, TestScanEarlyTermination, TestUnloadAccessController, TestWithDisabledAuthorization

public class SecureTestUtil extends Object
Utility methods for testing security
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
    An AccessTestAction performs an action that will be examined to confirm the results conform to expected access rights.
    static class 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final org.slf4j.Logger
     
    private static final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    checkGlobalPerms(HBaseTestingUtil testUtil, org.apache.hadoop.hbase.security.access.Permission.Action... actions)
     
    private static void
    checkPermissions(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.hbase.security.access.Permission... perms)
     
    static void
    checkTablePerms(HBaseTestingUtil testUtil, org.apache.hadoop.hbase.security.access.Permission... perms)
     
    static void
    checkTablePerms(HBaseTestingUtil testUtil, org.apache.hadoop.hbase.TableName table, byte[] family, byte[] column, org.apache.hadoop.hbase.security.access.Permission.Action... actions)
     
    static void
    configureSuperuser(org.apache.hadoop.conf.Configuration conf)
     
    static String
     
    static void
    createNamespace(HBaseTestingUtil testUtil, org.apache.hadoop.hbase.NamespaceDescriptor nsDesc)
     
    static void
    createTable(HBaseTestingUtil testUtil, org.apache.hadoop.hbase.client.Admin admin, org.apache.hadoop.hbase.client.TableDescriptor htd)
     
    static void
    createTable(HBaseTestingUtil testUtil, org.apache.hadoop.hbase.client.Admin admin, org.apache.hadoop.hbase.client.TableDescriptor htd, byte[][] splitKeys)
     
    static void
    createTable(HBaseTestingUtil testUtil, org.apache.hadoop.hbase.client.TableDescriptor htd)
     
    static void
    createTable(HBaseTestingUtil testUtil, org.apache.hadoop.hbase.client.TableDescriptor htd, byte[][] splitKeys)
     
    static void
    createTable(HBaseTestingUtil testUtil, org.apache.hadoop.hbase.security.User user, org.apache.hadoop.hbase.client.TableDescriptor htd)
     
    static void
    createTable(HBaseTestingUtil testUtil, org.apache.hadoop.hbase.security.User user, org.apache.hadoop.hbase.client.TableDescriptor htd, byte[][] splitKeys)
     
    static org.apache.hadoop.hbase.client.Table
    createTable(HBaseTestingUtil testUtil, org.apache.hadoop.hbase.TableName tableName, byte[][] families)
     
    static void
    deleteNamespace(HBaseTestingUtil testUtil, String namespace)
     
    static void
    deleteTable(HBaseTestingUtil testUtil, org.apache.hadoop.hbase.client.Admin admin, org.apache.hadoop.hbase.TableName tableName)
     
    static void
    deleteTable(HBaseTestingUtil testUtil, org.apache.hadoop.hbase.TableName tableName)
     
    static void
    disableReadOnlyMode(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.hbase.master.HMaster hMaster, org.apache.hadoop.hbase.regionserver.HRegionServer hRegionServer)
     
    static void
    enableReadOnlyMode(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.hbase.master.HMaster hMaster, org.apache.hadoop.hbase.regionserver.HRegionServer hRegionServer)
     
    static void
    enableSecurity(org.apache.hadoop.conf.Configuration conf)
     
    private static List<org.apache.hadoop.hbase.security.access.AccessController>
     
    private static Map<org.apache.hadoop.hbase.security.access.AccessController,Long>
     
    static void
    grantGlobal(HBaseTestingUtil util, String user, org.apache.hadoop.hbase.security.access.Permission.Action... actions)
    Grant permissions globally to the given user.
    static void
    grantGlobal(org.apache.hadoop.hbase.security.User caller, HBaseTestingUtil util, String user, org.apache.hadoop.hbase.security.access.Permission.Action... actions)
    Grant permissions globally to the given user.
    static void
    grantGlobalUsingAccessControlClient(HBaseTestingUtil util, org.apache.hadoop.hbase.client.Connection connection, String user, org.apache.hadoop.hbase.security.access.Permission.Action... actions)
    Grant global permissions to the given user using AccessControlClient.
    static void
    grantOnNamespace(HBaseTestingUtil util, String user, String namespace, org.apache.hadoop.hbase.security.access.Permission.Action... actions)
    Grant permissions on a namespace to the given user.
    static void
    grantOnNamespace(org.apache.hadoop.hbase.security.User caller, HBaseTestingUtil util, String user, String namespace, org.apache.hadoop.hbase.security.access.Permission.Action... actions)
    Grant permissions on a namespace to the given user.
    static void
    grantOnNamespaceUsingAccessControlClient(HBaseTestingUtil util, org.apache.hadoop.hbase.client.Connection connection, String user, String namespace, org.apache.hadoop.hbase.security.access.Permission.Action... actions)
    Grant permissions on a namespace to the given user using AccessControl Client.
    static void
    grantOnTable(HBaseTestingUtil util, String user, org.apache.hadoop.hbase.TableName table, byte[] family, byte[] qualifier, org.apache.hadoop.hbase.security.access.Permission.Action... actions)
    Grant permissions on a table to the given user.
    static void
    grantOnTable(org.apache.hadoop.hbase.security.User caller, HBaseTestingUtil util, String user, org.apache.hadoop.hbase.TableName table, byte[] family, byte[] qualifier, org.apache.hadoop.hbase.security.access.Permission.Action... actions)
    Grant permissions on a table to the given user.
    static void
    grantOnTableUsingAccessControlClient(HBaseTestingUtil util, org.apache.hadoop.hbase.client.Connection connection, String user, org.apache.hadoop.hbase.TableName table, byte[] family, byte[] qualifier, org.apache.hadoop.hbase.security.access.Permission.Action... actions)
    Grant permissions on a table to the given user using AccessControlClient.
    static void
    notifyReadOnlyObservers(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.hbase.master.HMaster hMaster, org.apache.hadoop.hbase.regionserver.HRegionServer hRegionServer)
     
    static void
    revokeFromNamespace(HBaseTestingUtil util, String user, String namespace, org.apache.hadoop.hbase.security.access.Permission.Action... actions)
    Revoke permissions on a namespace from the given user.
    static void
    revokeFromNamespace(org.apache.hadoop.hbase.security.User caller, HBaseTestingUtil util, String user, String namespace, org.apache.hadoop.hbase.security.access.Permission.Action... actions)
    Revoke permissions on a namespace from the given user.
    static void
    revokeFromNamespaceUsingAccessControlClient(HBaseTestingUtil util, org.apache.hadoop.hbase.client.Connection connection, String user, String namespace, org.apache.hadoop.hbase.security.access.Permission.Action... actions)
    Revoke permissions on a namespace from the given user using AccessControl Client.
    static void
    revokeFromTable(HBaseTestingUtil util, String user, org.apache.hadoop.hbase.TableName table, byte[] family, byte[] qualifier, org.apache.hadoop.hbase.security.access.Permission.Action... actions)
    Revoke permissions on a table from the given user.
    static void
    revokeFromTable(org.apache.hadoop.hbase.security.User caller, HBaseTestingUtil util, String user, org.apache.hadoop.hbase.TableName table, byte[] family, byte[] qualifier, org.apache.hadoop.hbase.security.access.Permission.Action... actions)
    Revoke permissions on a table from the given user.
    static void
    revokeFromTableUsingAccessControlClient(HBaseTestingUtil util, org.apache.hadoop.hbase.client.Connection connection, String user, org.apache.hadoop.hbase.TableName table, byte[] family, byte[] qualifier, org.apache.hadoop.hbase.security.access.Permission.Action... actions)
    Revoke permissions on a table from the given user using AccessControlClient.
    static void
    revokeGlobal(HBaseTestingUtil util, String user, org.apache.hadoop.hbase.security.access.Permission.Action... actions)
    Revoke permissions globally from the given user.
    static void
    revokeGlobal(org.apache.hadoop.hbase.security.User caller, HBaseTestingUtil util, String user, org.apache.hadoop.hbase.security.access.Permission.Action... actions)
    Revoke permissions globally from the given user.
    static void
    revokeGlobalUsingAccessControlClient(HBaseTestingUtil util, org.apache.hadoop.hbase.client.Connection connection, String user, org.apache.hadoop.hbase.security.access.Permission.Action... actions)
    Revoke global permissions from the given user using AccessControlClient.
    private static void
     
    static void
    verifyAllowed(SecureTestUtil.AccessTestAction action, org.apache.hadoop.hbase.security.User... users)
    This fails only in case of ADE or empty list for any of the users.
    static void
    verifyAllowed(org.apache.hadoop.hbase.security.User user, SecureTestUtil.AccessTestAction... actions)
    This fails only in case of ADE or empty list for any of the actions.
    static void
    verifyAllowed(org.apache.hadoop.hbase.security.User user, SecureTestUtil.AccessTestAction action, int count)
     
    static void
    verifyConfiguration(org.apache.hadoop.conf.Configuration conf)
     
    static void
    verifyDenied(SecureTestUtil.AccessTestAction action, org.apache.hadoop.hbase.security.User... users)
    This passes only in case of ADE for all users.
    static void
    verifyDenied(org.apache.hadoop.hbase.security.User user, SecureTestUtil.AccessTestAction... actions)
    This passes only in case of ADE for all actions.
    static void
    verifyIfEmptyList(SecureTestUtil.AccessTestAction action, org.apache.hadoop.hbase.security.User... users)
    This passes only in case of empty list for all users.
    static void
    verifyIfNull(SecureTestUtil.AccessTestAction action, org.apache.hadoop.hbase.security.User... users)
    This passes only in case of null for all users.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • configureSuperuser

      public static void configureSuperuser(org.apache.hadoop.conf.Configuration conf) throws IOException
      Throws:
      IOException
    • enableSecurity

      public static void enableSecurity(org.apache.hadoop.conf.Configuration conf) throws IOException
      Throws:
      IOException
    • verifyConfiguration

      public static void verifyConfiguration(org.apache.hadoop.conf.Configuration conf)
    • verifyAllowed

      public static void verifyAllowed(org.apache.hadoop.hbase.security.User user, SecureTestUtil.AccessTestAction... actions) throws Exception
      This fails only in case of ADE or empty list for any of the actions.
      Throws:
      Exception
    • verifyAllowed

      public static void verifyAllowed(SecureTestUtil.AccessTestAction action, org.apache.hadoop.hbase.security.User... users) throws Exception
      This fails only in case of ADE or empty list for any of the users.
      Throws:
      Exception
    • verifyAllowed

      public static void verifyAllowed(org.apache.hadoop.hbase.security.User user, SecureTestUtil.AccessTestAction action, int count) throws Exception
      Throws:
      Exception
    • verifyDenied

      public static void verifyDenied(SecureTestUtil.AccessTestAction action, org.apache.hadoop.hbase.security.User... users) throws Exception
      This passes only in case of ADE for all users.
      Throws:
      Exception
    • verifyIfEmptyList

      public static void verifyIfEmptyList(SecureTestUtil.AccessTestAction action, org.apache.hadoop.hbase.security.User... users) throws Exception
      This passes only in case of empty list for all users.
      Throws:
      Exception
    • verifyIfNull

      public static void verifyIfNull(SecureTestUtil.AccessTestAction action, org.apache.hadoop.hbase.security.User... users) throws Exception
      This passes only in case of null for all users.
      Throws:
      Exception
    • verifyDenied

      public static void verifyDenied(org.apache.hadoop.hbase.security.User user, SecureTestUtil.AccessTestAction... actions) throws Exception
      This passes only in case of ADE for all actions.
      Throws:
      Exception
    • getAccessControllers

      private static List<org.apache.hadoop.hbase.security.access.AccessController> getAccessControllers(SingleProcessHBaseCluster cluster)
    • getAuthManagerMTimes

      private static Map<org.apache.hadoop.hbase.security.access.AccessController,Long> getAuthManagerMTimes(SingleProcessHBaseCluster cluster)
    • updateACLs

      private static void updateACLs(HBaseTestingUtil util, Callable c) throws Exception
      Throws:
      Exception
    • grantGlobal

      public static void grantGlobal(HBaseTestingUtil util, String user, org.apache.hadoop.hbase.security.access.Permission.Action... actions) throws Exception
      Grant permissions globally to the given user. Will wait until all active AccessController instances have updated their permissions caches or will throw an exception upon timeout (10 seconds).
      Throws:
      Exception
    • grantGlobal

      public static void grantGlobal(org.apache.hadoop.hbase.security.User caller, HBaseTestingUtil util, String user, org.apache.hadoop.hbase.security.access.Permission.Action... actions) throws Exception
      Grant permissions globally to the given user. Will wait until all active AccessController instances have updated their permissions caches or will throw an exception upon timeout (10 seconds).
      Throws:
      Exception
    • revokeGlobal

      public static void revokeGlobal(HBaseTestingUtil util, String user, org.apache.hadoop.hbase.security.access.Permission.Action... actions) throws Exception
      Revoke permissions globally from the given user. Will wait until all active AccessController instances have updated their permissions caches or will throw an exception upon timeout (10 seconds).
      Throws:
      Exception
    • revokeGlobal

      public static void revokeGlobal(org.apache.hadoop.hbase.security.User caller, HBaseTestingUtil util, String user, org.apache.hadoop.hbase.security.access.Permission.Action... actions) throws Exception
      Revoke permissions globally from the given user. Will wait until all active AccessController instances have updated their permissions caches or will throw an exception upon timeout (10 seconds).
      Throws:
      Exception
    • grantOnNamespace

      public static void grantOnNamespace(HBaseTestingUtil util, String user, String namespace, org.apache.hadoop.hbase.security.access.Permission.Action... actions) throws Exception
      Grant permissions on a namespace to the given user. Will wait until all active AccessController instances have updated their permissions caches or will throw an exception upon timeout (10 seconds).
      Throws:
      Exception
    • grantOnNamespace

      public static void grantOnNamespace(org.apache.hadoop.hbase.security.User caller, HBaseTestingUtil util, String user, String namespace, org.apache.hadoop.hbase.security.access.Permission.Action... actions) throws Exception
      Grant permissions on a namespace to the given user. Will wait until all active AccessController instances have updated their permissions caches or will throw an exception upon timeout (10 seconds).
      Throws:
      Exception
    • grantOnNamespaceUsingAccessControlClient

      public static void grantOnNamespaceUsingAccessControlClient(HBaseTestingUtil util, org.apache.hadoop.hbase.client.Connection connection, String user, String namespace, org.apache.hadoop.hbase.security.access.Permission.Action... actions) throws Exception
      Grant permissions on a namespace to the given user using AccessControl Client. Will wait until all active AccessController instances have updated their permissions caches or will throw an exception upon timeout (10 seconds).
      Throws:
      Exception
    • revokeFromNamespaceUsingAccessControlClient

      public static void revokeFromNamespaceUsingAccessControlClient(HBaseTestingUtil util, org.apache.hadoop.hbase.client.Connection connection, String user, String namespace, org.apache.hadoop.hbase.security.access.Permission.Action... actions) throws Exception
      Revoke permissions on a namespace from the given user using AccessControl Client. Will wait until all active AccessController instances have updated their permissions caches or will throw an exception upon timeout (10 seconds).
      Throws:
      Exception
    • revokeFromNamespace

      public static void revokeFromNamespace(HBaseTestingUtil util, String user, String namespace, org.apache.hadoop.hbase.security.access.Permission.Action... actions) throws Exception
      Revoke permissions on a namespace from the given user. Will wait until all active AccessController instances have updated their permissions caches or will throw an exception upon timeout (10 seconds).
      Throws:
      Exception
    • revokeFromNamespace

      public static void revokeFromNamespace(org.apache.hadoop.hbase.security.User caller, HBaseTestingUtil util, String user, String namespace, org.apache.hadoop.hbase.security.access.Permission.Action... actions) throws Exception
      Revoke permissions on a namespace from the given user. Will wait until all active AccessController instances have updated their permissions caches or will throw an exception upon timeout (10 seconds).
      Throws:
      Exception
    • grantOnTable

      public static void grantOnTable(HBaseTestingUtil util, String user, org.apache.hadoop.hbase.TableName table, byte[] family, byte[] qualifier, org.apache.hadoop.hbase.security.access.Permission.Action... actions) throws Exception
      Grant permissions on a table to the given user. Will wait until all active AccessController instances have updated their permissions caches or will throw an exception upon timeout (10 seconds).
      Throws:
      Exception
    • grantOnTable

      public static void grantOnTable(org.apache.hadoop.hbase.security.User caller, HBaseTestingUtil util, String user, org.apache.hadoop.hbase.TableName table, byte[] family, byte[] qualifier, org.apache.hadoop.hbase.security.access.Permission.Action... actions) throws Exception
      Grant permissions on a table to the given user. Will wait until all active AccessController instances have updated their permissions caches or will throw an exception upon timeout (10 seconds).
      Throws:
      Exception
    • grantOnTableUsingAccessControlClient

      public static void grantOnTableUsingAccessControlClient(HBaseTestingUtil util, org.apache.hadoop.hbase.client.Connection connection, String user, org.apache.hadoop.hbase.TableName table, byte[] family, byte[] qualifier, org.apache.hadoop.hbase.security.access.Permission.Action... actions) throws Exception
      Grant permissions on a table to the given user using AccessControlClient. Will wait until all active AccessController instances have updated their permissions caches or will throw an exception upon timeout (10 seconds).
      Throws:
      Exception
    • grantGlobalUsingAccessControlClient

      public static void grantGlobalUsingAccessControlClient(HBaseTestingUtil util, org.apache.hadoop.hbase.client.Connection connection, String user, org.apache.hadoop.hbase.security.access.Permission.Action... actions) throws Exception
      Grant global permissions to the given user using AccessControlClient. Will wait until all active AccessController instances have updated their permissions caches or will throw an exception upon timeout (10 seconds).
      Throws:
      Exception
    • revokeFromTable

      public static void revokeFromTable(HBaseTestingUtil util, String user, org.apache.hadoop.hbase.TableName table, byte[] family, byte[] qualifier, org.apache.hadoop.hbase.security.access.Permission.Action... actions) throws Exception
      Revoke permissions on a table from the given user. Will wait until all active AccessController instances have updated their permissions caches or will throw an exception upon timeout (10 seconds).
      Throws:
      Exception
    • revokeFromTable

      public static void revokeFromTable(org.apache.hadoop.hbase.security.User caller, HBaseTestingUtil util, String user, org.apache.hadoop.hbase.TableName table, byte[] family, byte[] qualifier, org.apache.hadoop.hbase.security.access.Permission.Action... actions) throws Exception
      Revoke permissions on a table from the given user. Will wait until all active AccessController instances have updated their permissions caches or will throw an exception upon timeout (10 seconds).
      Throws:
      Exception
    • revokeFromTableUsingAccessControlClient

      public static void revokeFromTableUsingAccessControlClient(HBaseTestingUtil util, org.apache.hadoop.hbase.client.Connection connection, String user, org.apache.hadoop.hbase.TableName table, byte[] family, byte[] qualifier, org.apache.hadoop.hbase.security.access.Permission.Action... actions) throws Exception
      Revoke permissions on a table from the given user using AccessControlClient. Will wait until all active AccessController instances have updated their permissions caches or will throw an exception upon timeout (10 seconds).
      Throws:
      Exception
    • revokeGlobalUsingAccessControlClient

      public static void revokeGlobalUsingAccessControlClient(HBaseTestingUtil util, org.apache.hadoop.hbase.client.Connection connection, String user, org.apache.hadoop.hbase.security.access.Permission.Action... actions) throws Exception
      Revoke global permissions from the given user using AccessControlClient. Will wait until all active AccessController instances have updated their permissions caches or will throw an exception upon timeout (10 seconds).
      Throws:
      Exception
    • createTable

      public static org.apache.hadoop.hbase.client.Table createTable(HBaseTestingUtil testUtil, org.apache.hadoop.hbase.TableName tableName, byte[][] families) throws Exception
      Throws:
      Exception
    • createTable

      public static void createTable(HBaseTestingUtil testUtil, org.apache.hadoop.hbase.client.TableDescriptor htd) throws Exception
      Throws:
      Exception
    • createTable

      public static void createTable(HBaseTestingUtil testUtil, org.apache.hadoop.hbase.client.TableDescriptor htd, byte[][] splitKeys) throws Exception
      Throws:
      Exception
    • createTable

      public static void createTable(HBaseTestingUtil testUtil, org.apache.hadoop.hbase.client.Admin admin, org.apache.hadoop.hbase.client.TableDescriptor htd) throws Exception
      Throws:
      Exception
    • createTable

      public static void createTable(HBaseTestingUtil testUtil, org.apache.hadoop.hbase.client.Admin admin, org.apache.hadoop.hbase.client.TableDescriptor htd, byte[][] splitKeys) throws Exception
      Throws:
      Exception
    • createTable

      public static void createTable(HBaseTestingUtil testUtil, org.apache.hadoop.hbase.security.User user, org.apache.hadoop.hbase.client.TableDescriptor htd) throws Exception
      Throws:
      Exception
    • createTable

      public static void createTable(HBaseTestingUtil testUtil, org.apache.hadoop.hbase.security.User user, org.apache.hadoop.hbase.client.TableDescriptor htd, byte[][] splitKeys) throws Exception
      Throws:
      Exception
    • deleteTable

      public static void deleteTable(HBaseTestingUtil testUtil, org.apache.hadoop.hbase.TableName tableName) throws Exception
      Throws:
      Exception
    • createNamespace

      public static void createNamespace(HBaseTestingUtil testUtil, org.apache.hadoop.hbase.NamespaceDescriptor nsDesc) throws Exception
      Throws:
      Exception
    • deleteNamespace

      public static void deleteNamespace(HBaseTestingUtil testUtil, String namespace) throws Exception
      Throws:
      Exception
    • deleteTable

      public static void deleteTable(HBaseTestingUtil testUtil, org.apache.hadoop.hbase.client.Admin admin, org.apache.hadoop.hbase.TableName tableName) throws Exception
      Throws:
      Exception
    • convertToNamespace

      public static String convertToNamespace(String namespace)
    • checkGlobalPerms

      public static void checkGlobalPerms(HBaseTestingUtil testUtil, org.apache.hadoop.hbase.security.access.Permission.Action... actions) throws IOException
      Throws:
      IOException
    • checkTablePerms

      public static void checkTablePerms(HBaseTestingUtil testUtil, org.apache.hadoop.hbase.TableName table, byte[] family, byte[] column, org.apache.hadoop.hbase.security.access.Permission.Action... actions) throws IOException
      Throws:
      IOException
    • checkTablePerms

      public static void checkTablePerms(HBaseTestingUtil testUtil, org.apache.hadoop.hbase.security.access.Permission... perms) throws IOException
      Throws:
      IOException
    • checkPermissions

      private static void checkPermissions(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.hbase.security.access.Permission... perms) throws IOException
      Throws:
      IOException
    • enableReadOnlyMode

      public static void enableReadOnlyMode(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.hbase.master.HMaster hMaster, org.apache.hadoop.hbase.regionserver.HRegionServer hRegionServer)
    • disableReadOnlyMode

      public static void disableReadOnlyMode(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.hbase.master.HMaster hMaster, org.apache.hadoop.hbase.regionserver.HRegionServer hRegionServer)
    • notifyReadOnlyObservers

      public static void notifyReadOnlyObservers(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.hbase.master.HMaster hMaster, org.apache.hadoop.hbase.regionserver.HRegionServer hRegionServer)