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
Utility methods for testing security
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
An AccessTestAction performs an action that will be examined to confirm the results conform to expected access rights.static class
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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
convertToNamespace
(String namespace) 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
enableSecurity
(org.apache.hadoop.conf.Configuration conf) private static List<org.apache.hadoop.hbase.security.access.AccessController>
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
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
updateACLs
(HBaseTestingUtil util, Callable c) 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.
-
Field Details
-
LOG
-
WAIT_TIME
- See Also:
-
-
Constructor Details
-
SecureTestUtil
public SecureTestUtil()
-
-
Method Details
-
configureSuperuser
- Throws:
IOException
-
enableSecurity
- Throws:
IOException
-
verifyConfiguration
-
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
- 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
- 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
-
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
-