Skip to content

Commit

Permalink
Adding test cases for redundanct schema permission
Browse files Browse the repository at this point in the history
Signed-off-by: Tanya Gupta <[email protected]>
  • Loading branch information
Tanya Gupta committed Sep 25, 2024
1 parent b4ea881 commit c152e39
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1890,14 +1890,6 @@ $$
LANGUAGE 'pltsql';
GRANT EXECUTE ON PROCEDURE sys.sp_tables TO PUBLIC;
ALTER FUNCTION sys.sp_tables_internal RENAME TO sp_tables_internal_deprecated_in_4_4_0;
ALTER FUNCTION sys.sp_columns_100_internal RENAME TO sp_columns_100_internal_deprecated_in_4_4_0;
ALTER FUNCTION sys.sp_statistics_internal RENAME TO sp_statistics_internal_deprecated_in_4_4_0;
ALTER FUNCTION sys.sp_pkeys_internal RENAME TO sp_pkeys_internal_deprecated_in_4_4_0;
create or replace view sys.tables as
with tt_internal as MATERIALIZED
(
Expand Down Expand Up @@ -3763,6 +3755,14 @@ WHERE nspname = 'sys' AND (proname LIKE 'sp\_%' OR proname LIKE 'xp\_%' OR prona
GRANT SELECT ON sys.sp_stored_procedures_view TO PUBLIC;
ALTER FUNCTION sys.sp_tables_internal RENAME TO sp_tables_internal_deprecated_in_4_4_0;
ALTER FUNCTION sys.sp_columns_100_internal RENAME TO sp_columns_100_internal_deprecated_in_4_4_0;
ALTER FUNCTION sys.sp_statistics_internal RENAME TO sp_statistics_internal_deprecated_in_4_4_0;
ALTER FUNCTION sys.sp_pkeys_internal RENAME TO sp_pkeys_internal_deprecated_in_4_4_0;
CALL sys.babelfish_drop_deprecated_object('function', 'sys', 'sp_tables_internal_deprecated_in_4_4_0');
CALL sys.babelfish_drop_deprecated_object('function', 'sys', 'sp_columns_100_internal_deprecated_in_4_4_0');
Expand Down
9 changes: 9 additions & 0 deletions test/JDBC/expected/sys-views-vu-cleanup.out
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ GO
DROP VIEW sys_views_vu_prepare_t1;
GO

DROP view s1.v1 ;
GO

DROP schema s1;
GO

DROP login l1;
GO

USE master;
GO

Expand Down
12 changes: 12 additions & 0 deletions test/JDBC/expected/sys-views-vu-prepare.out
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ GO
CREATE VIEW sys_views_vu_prepare_t1 AS select 1;
GO

CREATE schema s1;
GO

create view s1.v1 as select 1;
GO

create login l1 WITH PASSWORD = '12345678';
GO

create user u1 for login l1;
GO

USE master;
GO

Expand Down
49 changes: 49 additions & 0 deletions test/JDBC/expected/sys-views-vu-verify.out
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,52 @@ int
0
~~END~~


-- tsql user=l1 password=12345678
USE sys_views_vu_prepare_db1;
GO

#view s1.v1 should not be visible in db1 database to l1.
select count(*) from sys.views where name = 'v1';
GO
~~START~~
int
0
~~END~~


SELECT COUNT(*) FROM sys.all_objects WHERE type='V' and name = 'v1';
GO
~~START~~
int
0
~~END~~


-- tsql
use sys_views_vu_prepare_db1;
GO

GRANT select on schema::s1 to u1;
GO

-- tsql user=l1 password=12345678
USE sys_views_vu_prepare_db1;
GO

# view s1.v1 should be visible in db1 database to l1 now.
select count(*) from sys.views where name = 'v1';
GO
~~START~~
int
1
~~END~~


SELECT COUNT(*) FROM sys.all_objects WHERE type='V' and name = 'v1';
GO
~~START~~
int
1
~~END~~

Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,20 @@ GO
DROP VIEW sys_views_vu_prepare_t1;
GO

DROP view s1.v1 ;
GO

DROP schema s1;
GO

DROP login l1;
GO

USE master;
GO

DROP DATABASE sys_views_vu_prepare_db1;
GO

DROP VIEW sys_views_vu_prepare_t2;
GO
GO
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,20 @@ GO
CREATE VIEW sys_views_vu_prepare_t1 AS select 1;
GO

CREATE schema s1;
GO

create view s1.v1 as select 1;
GO

create login l1 WITH PASSWORD = '12345678';
GO

create user u1 for login l1;
GO

USE master;
GO

CREATE VIEW sys_views_vu_prepare_t2 AS select 1;
GO
GO
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,32 @@ GO

SELECT COUNT(*) FROM sys.all_objects WHERE type='V' and name = 'sys_views_vu_prepare_t2';
GO

-- tsql user=l1 password=12345678
USE sys_views_vu_prepare_db1;
GO

#view s1.v1 should not be visible in db1 database to l1.
select count(*) from sys.views where name = 'v1';
GO

SELECT COUNT(*) FROM sys.all_objects WHERE type='V' and name = 'v1';
GO

-- tsql
use sys_views_vu_prepare_db1;
GO

GRANT select on schema::s1 to u1;
GO

-- tsql user=l1 password=12345678
USE sys_views_vu_prepare_db1;
GO

# view s1.v1 should be visible in db1 database to l1 now.
select count(*) from sys.views where name = 'v1';
GO

SELECT COUNT(*) FROM sys.all_objects WHERE type='V' and name = 'v1';
GO

0 comments on commit c152e39

Please sign in to comment.