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-22879 user_permission command failed to show global permission #511

Merged
merged 1 commit into from
Aug 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 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
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 : ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the story of admin2_test.rb, why is it related to this fix?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not related to this fix. But admin2_test.rb is already tested in TestAdminShell2, TestShell can skip it rather than test it twice?

// Start all ruby tests
jruby.runScriptlet(PathType.ABSOLUTE, "src/test/ruby/tests_runner.rb");
}
Expand Down
20 changes: 20 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 @@ -78,5 +78,25 @@ def teardown
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