-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bcadcbc
commit c405d7f
Showing
9 changed files
with
186 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
-- name: test_security_view | ||
create table t1(c1 bigint, c2 bigint); | ||
-- result: | ||
-- !result | ||
create table t2(c3 bigint, c4 bigint); | ||
-- result: | ||
-- !result | ||
create view v1 as select * from t1, t2; | ||
-- result: | ||
-- !result | ||
create view v2 security invoker as select * from t1, t2; | ||
-- result: | ||
-- !result | ||
create user if not exists u1; | ||
-- result: | ||
-- !result | ||
grant impersonate on user root to u1; | ||
-- result: | ||
-- !result | ||
grant select on view v1 to user u1; | ||
-- result: | ||
-- !result | ||
grant select on view v2 to user u1; | ||
-- result: | ||
-- !result | ||
create user if not exists u2; | ||
-- result: | ||
-- !result | ||
grant impersonate on user root to u2; | ||
-- result: | ||
-- !result | ||
grant select on table t1 to user u2; | ||
-- result: | ||
-- !result | ||
grant select on table t2 to user u2; | ||
-- result: | ||
-- !result | ||
grant select on view v1 to user u2; | ||
-- result: | ||
-- !result | ||
grant select on view v2 to user u2; | ||
-- result: | ||
-- !result | ||
execute as u1 with no revert; | ||
-- result: | ||
-- !result | ||
select * from v1; | ||
-- result: | ||
-- !result | ||
select * from v2; | ||
-- result: | ||
E: (5203, 'Access denied; you need (at least one of) the SELECT privilege(s) on VIEW v2 for this operation. Please ask the admin to grant permission(s) or try activating existing roles using <set [default] role>. Current role(s): NONE. Inactivated role(s): NONE.') | ||
-- !result | ||
execute as root with no revert; | ||
-- result: | ||
-- !result | ||
execute as u2 with no revert; | ||
-- result: | ||
-- !result | ||
select * from v1; | ||
-- result: | ||
-- !result | ||
select * from v2; | ||
-- result: | ||
-- !result | ||
execute as root with no revert; | ||
-- result: | ||
-- !result | ||
alter view v1 set security invoker; | ||
-- result: | ||
-- !result | ||
alter view v2 set security none; | ||
-- result: | ||
-- !result | ||
execute as u1 with no revert; | ||
-- result: | ||
-- !result | ||
select * from v1; | ||
-- result: | ||
E: (5203, 'Access denied; you need (at least one of) the SELECT privilege(s) on VIEW v1 for this operation. Please ask the admin to grant permission(s) or try activating existing roles using <set [default] role>. Current role(s): NONE. Inactivated role(s): NONE.') | ||
-- !result | ||
select * from v2; | ||
-- result: | ||
-- !result | ||
execute as root with no revert; | ||
-- result: | ||
-- !result | ||
execute as u2 with no revert; | ||
-- result: | ||
-- !result | ||
select * from v1; | ||
-- result: | ||
-- !result | ||
select * from v2; | ||
-- result: | ||
-- !result | ||
execute as root with no revert; | ||
-- result: | ||
-- !result | ||
drop user u1; | ||
-- result: | ||
-- !result | ||
drop user u2; | ||
-- result: | ||
-- !result |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
-- name: test_security_view | ||
|
||
create table t1(c1 bigint, c2 bigint); | ||
create table t2(c3 bigint, c4 bigint); | ||
|
||
create view v1 as select * from t1, t2; | ||
create view v2 security invoker as select * from t1, t2; | ||
|
||
create user if not exists u1; | ||
grant impersonate on user root to u1; | ||
grant select on view v1 to user u1; | ||
grant select on view v2 to user u1; | ||
|
||
create user if not exists u2; | ||
grant impersonate on user root to u2; | ||
grant select on table t1 to user u2; | ||
grant select on table t2 to user u2; | ||
grant select on view v1 to user u2; | ||
grant select on view v2 to user u2; | ||
|
||
execute as u1 with no revert; | ||
select * from v1; | ||
select * from v2; | ||
execute as root with no revert; | ||
|
||
execute as u2 with no revert; | ||
select * from v1; | ||
select * from v2; | ||
execute as root with no revert; | ||
|
||
alter view v1 set security invoker; | ||
alter view v2 set security none; | ||
|
||
execute as u1 with no revert; | ||
select * from v1; | ||
select * from v2; | ||
execute as root with no revert; | ||
|
||
execute as u2 with no revert; | ||
select * from v1; | ||
select * from v2; | ||
execute as root with no revert; | ||
|
||
drop user u1; | ||
drop user u2; |