feat: hive Authorization syntax and unit tests (#159)
Co-authored-by: zhaoge <>
This commit is contained in:
16
test/parser/hive/syntax/authorizationStatement.test.ts
Normal file
16
test/parser/hive/syntax/authorizationStatement.test.ts
Normal 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);
|
||||
});
|
||||
});
|
||||
});
|
34
test/parser/hive/syntax/fixtures/authorization.sql
Normal file
34
test/parser/hive/syntax/fixtures/authorization.sql
Normal 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`;
|
||||
|
@ -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;
|
||||
|
||||
|
Reference in New Issue
Block a user