HBASE-24176 user_permission '.*' command failed to show all table permissions (#1499)

* user_permission failed when show table permissions with '.*' argument

Signed-off-by: Guangxu Cheng <gxcheng@apache.org>
This commit is contained in:
EEPROM 2020-04-14 10:14:21 +08:00 committed by GitHub
parent c2f2553490
commit 35ea4acf48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -150,7 +150,7 @@ module Hbase
if !table_regex.nil? && isNamespace?(table_regex) if !table_regex.nil? && isNamespace?(table_regex)
nsPerm = permission.to_java(org.apache.hadoop.hbase.security.access.NamespacePermission) nsPerm = permission.to_java(org.apache.hadoop.hbase.security.access.NamespacePermission)
namespace = nsPerm.getNamespace namespace = nsPerm.getNamespace
elsif !table_regex.nil? elsif !table_regex.nil? && isTablePermission?(permission)
tblPerm = permission.to_java(org.apache.hadoop.hbase.security.access.TablePermission) tblPerm = permission.to_java(org.apache.hadoop.hbase.security.access.TablePermission)
namespace = tblPerm.getNamespace namespace = tblPerm.getNamespace
table = !tblPerm.getTableName.nil? ? tblPerm.getTableName.getNameAsString : '' table = !tblPerm.getTableName.nil? ? tblPerm.getTableName.getNameAsString : ''
@ -183,6 +183,10 @@ module Hbase
table_name.start_with?('@') table_name.start_with?('@')
end end
def isTablePermission?(permission)
permission.java_kind_of?(org.apache.hadoop.hbase.security.access.TablePermission)
end
# Does Namespace exist # Does Namespace exist
def namespace_exists?(namespace_name) def namespace_exists?(namespace_name)
return !@admin.getNamespaceDescriptor(namespace_name).nil? return !@admin.getNamespaceDescriptor(namespace_name).nil?

View File

@ -91,6 +91,15 @@ module Hbase
end end
assert(found_permission, 'Permission for user ' + global_user_name + ' was not found.') assert(found_permission, 'Permission for user ' + global_user_name + ' was not found.')
found_permission = false
security_admin.user_permission('.*') do |user, permission|
if user == global_user_name
assert_match(/WRITE/, permission.to_s)
found_permission = true
end
end
assert(found_permission, 'Permission for user ' + global_user_name + ' was not found.')
found_permission = false found_permission = false
security_admin.revoke(global_user_name) security_admin.revoke(global_user_name)
security_admin.user_permission do |user, _| security_admin.user_permission do |user, _|