feat: hive Authorization syntax and unit tests (#159)

Co-authored-by: zhaoge <>
This commit is contained in:
XCynthia
2023-09-12 20:10:43 +08:00
committed by GitHub
parent 6a99d63d71
commit 2ec03f1770
9 changed files with 957 additions and 903 deletions

View File

@ -0,0 +1,16 @@
import HiveSQL from '../../../../src/parser/hive';
import { readSQL } from '../../../helper';
const parser = new HiveSQL();
const features = {
manageRoles: readSQL(__dirname, 'authorization.sql'),
};
describe('HiveSQL Related To Authorization Tests', () => {
features.manageRoles.forEach((manageRole) => {
it(manageRole, () => {
expect(parser.validate(manageRole).length).toBe(0);
});
});
});

View File

@ -0,0 +1,34 @@
-- SQL Standards Based Hive Authorization
-- Role Management Commands -- Set Role
SET ROLE `admin`;
SET ROLE ALL;
SET ROLE NONE;
-- Role Management Commands -- Grant Role
GRANT role_name TO USER user_name;
GRANT role_name, role_name TO USER user1, ROLE role2 WITH ADMIN OPTION ;
-- Role Management Commands -- Revoke Role
REVOKE role_name FROM USER `user`;
REVOKE ADMIN OPTION FOR role_name, role_name FROM USER `user`, ROLE `role`;
-- Managing Object Privileges -- Object Privilege Commands
GRANT
INSERT
ON table_or_view_name
TO USER `user`;
GRANT INSERT, SELECT, UPDATE, DELETE, ALL ON table_or_view_name1 TO USER `user`, ROLE `role` WITH GRANT OPTION;
REVOKE INSERT
ON table_or_view_name
FROM USER `user`;
REVOKE GRANT OPTION FOR ALL, ALTER, UPDATE, CREATE, DROP, INDEX, LOCK, SELECT, SHOW_DATABASE
ON table_or_view_name
FROM USER `user`, ROLE `role`;

View File

@ -93,6 +93,8 @@ SHOW CURRENT ROLES;
-- Show Role Grant
SHOW ROLE GRANT USER user1;
SHOW ROLE GRANT ROLE `role`;
-- Show Principals
SHOW PRINCIPALS role1;