You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by me...@apache.org on 2019/08/21 02:00:11 UTC
[hbase] branch branch-2 updated: HBASE-22879 user_permission
command failed to show global permission (#511)
This is an automated email from the ASF dual-hosted git repository.
meiyi pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2 by this push:
new 9d178cf HBASE-22879 user_permission command failed to show global permission (#511)
9d178cf is described below
commit 9d178cf5757e91968bd1a72d33518c16d96d2e7f
Author: meiyi <my...@gmail.com>
AuthorDate: Wed Aug 21 09:29:31 2019 +0800
HBASE-22879 user_permission command failed to show global permission (#511)
---
hbase-shell/src/main/ruby/hbase/security.rb | 2 +-
.../org/apache/hadoop/hbase/client/TestShell.java | 2 +-
.../src/test/ruby/hbase/security_admin_test.rb | 20 ++++++++++++++++++++
3 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/hbase-shell/src/main/ruby/hbase/security.rb b/hbase-shell/src/main/ruby/hbase/security.rb
index baea21e..570cdeb 100644
--- a/hbase-shell/src/main/ruby/hbase/security.rb
+++ b/hbase-shell/src/main/ruby/hbase/security.rb
@@ -150,7 +150,7 @@ module Hbase
if !table_regex.nil? && isNamespace?(table_regex)
nsPerm = permission.to_java(org.apache.hadoop.hbase.security.access.NamespacePermission)
namespace = nsPerm.getNamespace
- else
+ elsif !table_regex.nil?
tblPerm = permission.to_java(org.apache.hadoop.hbase.security.access.TablePermission)
namespace = tblPerm.getNamespace
table = !tblPerm.getTableName.nil? ? tblPerm.getTableName.getNameAsString : ''
diff --git a/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestShell.java b/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestShell.java
index 9bb8eac..8f3aefb 100644
--- a/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestShell.java
+++ b/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestShell.java
@@ -35,7 +35,7 @@ public class TestShell extends AbstractTestShell {
@Test
public void testRunShellTests() throws IOException {
System.setProperty("shell.test.exclude", "replication_admin_test.rb,rsgroup_shell_test.rb," +
- "admin_test.rb,table_test.rb,quotas_test.rb");
+ "admin_test.rb,table_test.rb,quotas_test.rb,admin2_test.rb");
// Start all ruby tests
jruby.runScriptlet(PathType.ABSOLUTE, "src/test/ruby/tests_runner.rb");
}
diff --git a/hbase-shell/src/test/ruby/hbase/security_admin_test.rb b/hbase-shell/src/test/ruby/hbase/security_admin_test.rb
index fd8f6ad..e19c22c 100644
--- a/hbase-shell/src/test/ruby/hbase/security_admin_test.rb
+++ b/hbase-shell/src/test/ruby/hbase/security_admin_test.rb
@@ -78,5 +78,25 @@ module Hbase
end
assert(found_permission, "Permission for user test_grant_revoke was not found.")
end
+
+ define_test 'Grant and revoke global permission should set access rights appropriately' do
+ global_user_name = 'test_grant_revoke_global'
+ security_admin.grant(global_user_name, 'W')
+ 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
+ security_admin.revoke(global_user_name)
+ security_admin.user_permission do |user, _|
+ found_permission = true if user == global_user_name
+ end
+ assert(!found_permission, 'Permission for user ' + global_user_name + ' was found.')
+ end
end
end