Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Apr 14, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion hbase-shell/src/main/ruby/hbase/security.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def user_permission(table_regex = nil)
if !table_regex.nil? && isNamespace?(table_regex)
nsPerm = permission.to_java(org.apache.hadoop.hbase.security.access.NamespacePermission)
namespace = nsPerm.getNamespace
elsif !table_regex.nil?
elsif !table_regex.nil? && isTablePermission?(permission)
tblPerm = permission.to_java(org.apache.hadoop.hbase.security.access.TablePermission)
namespace = tblPerm.getNamespace
table = !tblPerm.getTableName.nil? ? tblPerm.getTableName.getNameAsString : ''
Expand Down Expand Up @@ -183,6 +183,10 @@ def isNamespace?(table_name)
table_name.start_with?('@')
end

def isTablePermission?(permission)
permission.java_kind_of?(org.apache.hadoop.hbase.security.access.TablePermission)
end

# Does Namespace exist
def namespace_exists?(namespace_name)
return [email protected](namespace_name).nil?
Expand Down
8 changes: 8 additions & 0 deletions hbase-shell/src/test/ruby/hbase/security_admin_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ def teardown
end
assert(found_permission, 'Permission for user ' + global_user_name + ' was not found.')

security_admin.user_permission('.*') do |user, permission|
songxincun marked this conversation as resolved.
Show resolved Hide resolved
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
security_admin.revoke(global_user_name)
security_admin.user_permission do |user, _|
Expand Down