Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c25687a

Browse files
authored
Merge pull request #865 from utPLSQL/fix/privs_issues_on_error_msg
Fixing issue when users with min privs execute empty matcher.
2 parents dc2661a + 816b5dd commit c25687a

9 files changed

Lines changed: 218 additions & 59 deletions

source/create_synonyms_and_grants_for_public.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ grant select, insert, delete, update on &&ut3_owner..dbmspcc_units to public;
107107
grant execute on &&ut3_owner..ut_matcher_options to public;
108108
grant execute on &&ut3_owner..ut_matcher_options_items to public;
109109
grant execute on &&ut3_owner..ut_run_info to public;
110+
grant execute on &&ut3_owner..ut_cursor_column_tab to public;
111+
grant execute on &&ut3_owner..ut_cursor_details to public;
110112

111113
prompt Creating synonyms for UTPLSQL objects in &&ut3_owner schema to PUBLIC
112114

@@ -167,3 +169,5 @@ create public synonym dbmspcc_blocks for &&ut3_owner..dbmspcc_blocks;
167169
create public synonym dbmspcc_runs for &&ut3_owner..dbmspcc_runs;
168170
create public synonym dbmspcc_units for &&ut3_owner..dbmspcc_units;
169171
create public synonym ut_run_info for &&ut3_owner..ut_run_info;
172+
create public synonym ut_cursor_column_tab for &&ut3_owner..ut_cursor_column_tab;
173+
create public synonym ut_cursor_details for &&ut3_owner..ut_cursor_details;

source/create_user_grants.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,5 @@ grant select, insert, delete, update on &&ut3_owner..dbmspcc_units to &ut3_user;
126126
grant execute on &&ut3_owner..ut_matcher_options to &ut3_user;
127127
grant execute on &&ut3_owner..ut_matcher_options_items to &ut3_user;
128128
grant execute on &&ut3_owner..ut_run_info to &ut3_user;
129-
129+
grant execute on &&ut3_owner..ut_cursor_column_tab to &ut3_user;
130+
grant execute on &&ut3_owner..ut_cursor_details to &ut3_user;

source/create_user_synonyms.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,5 @@ create or replace synonym &ut3_user..dbmspcc_blocks for &&ut3_owner..dbmspcc_blo
109109
create or replace synonym &ut3_user..dbmspcc_runs for &&ut3_owner..dbmspcc_runs;
110110
create or replace synonym &ut3_user..dbmspcc_units for &&ut3_owner..dbmspcc_units;
111111
create or replace synonym &ut3_user..ut_run_info for &&ut3_owner..ut_run_info;
112+
create or replace synonym &ut3_user..ut_cursor_column_tab for &&ut3_owner..ut_cursor_column_tab;
113+
create or replace synonym &ut3_user..ut_cursor_details for &&ut3_owner..ut_cursor_details;
Lines changed: 60 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,60 @@
1-
create or replace package body test_min_grant_user is
2-
3-
procedure test_join_by_cursor is
4-
l_results clob;
5-
begin
6-
execute immediate 'begin ut3$user#.test_cursor_grants.run(); end;';
7-
l_results := core.get_dbms_output_as_clob();
8-
--Assert
9-
ut.expect( l_results ).to_be_like( '%execute join by test [% sec]' ||
10-
'%1 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%' );
11-
12-
end;
13-
14-
end;
15-
/
1+
create or replace package body test_min_grant_user is
2+
3+
procedure test_join_by_cursor is
4+
l_results clob;
5+
begin
6+
execute immediate 'begin ut3$user#.test_cursor_grants.run_test_join_by_cursor(); end;';
7+
l_results := core.get_dbms_output_as_clob();
8+
--Assert
9+
ut.expect( l_results ).to_be_like( '%execute join by test [% sec]' ||
10+
'%1 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%' );
11+
12+
end;
13+
14+
procedure test_equal_cursor is
15+
l_results clob;
16+
begin
17+
execute immediate 'begin ut3$user#.test_cursor_grants.run_test_equal_cursor(); end;';
18+
l_results := core.get_dbms_output_as_clob();
19+
--Assert
20+
ut.expect( l_results ).to_be_like( '%execute equal test [% sec]' ||
21+
'%1 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%' );
22+
23+
end;
24+
25+
procedure test_not_empty_cursor is
26+
l_results clob;
27+
begin
28+
execute immediate 'begin ut3$user#.test_cursor_grants.run_test_not_empty_cursor(); end;';
29+
l_results := core.get_dbms_output_as_clob();
30+
--Assert
31+
ut.expect( l_results ).to_be_like( '%execute not_empty test [% sec]' ||
32+
'%1 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%' );
33+
34+
end;
35+
36+
37+
procedure test_have_count_cursor is
38+
l_results clob;
39+
begin
40+
execute immediate 'begin ut3$user#.test_cursor_grants.run_test_have_count_cursor(); end;';
41+
l_results := core.get_dbms_output_as_clob();
42+
--Assert
43+
ut.expect( l_results ).to_be_like( '%execute have_count test [% sec]' ||
44+
'%1 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%' );
45+
46+
end;
47+
48+
procedure test_empty_cursor is
49+
l_results clob;
50+
begin
51+
execute immediate 'begin ut3$user#.test_cursor_grants.run_test_empty_cursor(); end;';
52+
l_results := core.get_dbms_output_as_clob();
53+
--Assert
54+
ut.expect( l_results ).to_be_like( '%execute empty test [% sec]' ||
55+
'%1 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%' );
56+
57+
end;
58+
59+
end;
60+
/
Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
1-
create or replace package test_min_grant_user is
2-
3-
--%suite(minimum grant user tests)
4-
--%suitepath(utplsql.core)
5-
6-
--%test(execute join by test)
7-
procedure test_join_by_cursor;
8-
9-
end;
10-
/
1+
create or replace package test_min_grant_user is
2+
3+
--%suite(minimum grant user tests)
4+
--%suitepath(utplsql.core)
5+
6+
--%test(execute join by test)
7+
procedure test_join_by_cursor;
8+
9+
--%test(execute equal test)
10+
procedure test_equal_cursor;
11+
12+
--%test(execute not_empty test)
13+
procedure test_not_empty_cursor;
14+
15+
--%test(execute have_count test)
16+
procedure test_have_count_cursor;
17+
18+
--%test(execute empty test)
19+
procedure test_empty_cursor;
20+
21+
end;
22+
/

test/helpers/test_dummy_object.tps

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,7 @@ create or replace type test_dummy_object as object (
1313
"name" varchar2(30),
1414
"Value" varchar2(30)
1515
)
16-
/
16+
/
17+
18+
19+
grant execute on test_dummy_object to ut3$user#;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
create or replace type test_dummy_object_list as table of test_dummy_object
22
/
3+
4+
grant execute on test_dummy_object_list to ut3$user#;
Lines changed: 96 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,96 @@
1-
create or replace package body ut3$user#.test_cursor_grants is
2-
3-
procedure run is
4-
begin
5-
ut3.ut.run('test_cursor_grants');
6-
end;
7-
8-
procedure test_join_by_cursor is
9-
l_actual SYS_REFCURSOR;
10-
l_expected SYS_REFCURSOR;
11-
begin
12-
--Arrange
13-
open l_actual for select owner, object_name,object_type from all_objects where owner = user
14-
order by 1,2,3 asc;
15-
open l_expected for select owner, object_name,object_type from all_objects where owner = user
16-
order by 1,2,3 desc;
17-
18-
--Act
19-
ut3.ut.expect(l_actual).to_equal(l_expected).join_by('OWNER');
20-
21-
end;
22-
end;
23-
/
1+
create or replace package body ut3$user#.test_cursor_grants is
2+
3+
procedure run_test_join_by_cursor is
4+
begin
5+
ut3.ut.run('test_cursor_grants.test_join_by_cursor');
6+
end;
7+
8+
procedure run_test_equal_cursor is
9+
begin
10+
ut3.ut.run('test_cursor_grants.test_equal_cursor');
11+
end;
12+
13+
procedure run_test_not_empty_cursor is
14+
begin
15+
ut3.ut.run('test_cursor_grants.test_not_empty_cursor');
16+
end;
17+
18+
procedure run_test_have_count_cursor is
19+
begin
20+
ut3.ut.run('test_cursor_grants.test_have_count_cursor');
21+
end;
22+
23+
procedure run_test_empty_cursor is
24+
begin
25+
ut3.ut.run('test_cursor_grants.test_empty_cursor');
26+
end;
27+
28+
procedure test_join_by_cursor is
29+
l_actual SYS_REFCURSOR;
30+
l_expected SYS_REFCURSOR;
31+
begin
32+
--Arrange
33+
open l_actual for select owner, object_name,object_type from all_objects where owner = user
34+
order by 1,2,3 asc;
35+
open l_expected for select owner, object_name,object_type from all_objects where owner = user
36+
order by 1,2,3 desc;
37+
38+
--Act
39+
ut3.ut.expect(l_actual).to_equal(l_expected).join_by('OBJECT_NAME,OBJECT_TYPE');
40+
41+
end;
42+
43+
procedure test_equal_cursor is
44+
l_actual SYS_REFCURSOR;
45+
l_expected SYS_REFCURSOR;
46+
l_list ut3_tester.test_dummy_object_list;
47+
begin
48+
--Arrange
49+
open l_actual for select value(x) as item from table(l_list) x;
50+
open l_expected for select value(x) as item from table(l_list) x;
51+
52+
--Act
53+
ut3.ut.expect(l_actual).to_equal(l_expected);
54+
55+
end;
56+
57+
procedure test_not_empty_cursor is
58+
l_details_cur SYS_REFCURSOR;
59+
l_expected ut3_tester.test_dummy_object_list;
60+
begin
61+
select ut3_tester.test_dummy_object( rn, 'Something '||rn, rn1)
62+
bulk collect into l_expected
63+
from (select rownum * case when mod(rownum,2) = 0 then -1 else 1 end rn,
64+
rownum * case when mod(rownum,4) = 0 then -1 else 1 end rn1
65+
from dual connect by level <=10);
66+
67+
--Arrange
68+
open l_details_cur for
69+
select value(x) as item from table(l_expected) x;
70+
71+
--Act
72+
ut3.ut.expect(l_details_cur).not_to_be_empty();
73+
end;
74+
75+
procedure test_have_count_cursor is
76+
l_expected SYS_REFCURSOR;
77+
begin
78+
--Arrange
79+
open l_expected for
80+
select value(x) as item from table(ut3_tester.test_dummy_object_list()) x;
81+
82+
--Act
83+
ut3.ut.expect(l_expected).to_have_count(0);
84+
end;
85+
86+
procedure test_empty_cursor is
87+
l_expected SYS_REFCURSOR;
88+
begin
89+
open l_expected for
90+
select value(x) as item from table(ut3_tester.test_dummy_object_list()) x;
91+
--Act
92+
ut3.ut.expect(l_expected).to_be_empty();
93+
end;
94+
95+
end;
96+
/
Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,26 @@
1-
create or replace package ut3$user#.test_cursor_grants is
2-
--%suite()
3-
4-
procedure run;
5-
6-
--%test(execute join by test)
7-
procedure test_join_by_cursor;
8-
end;
9-
/
1+
create or replace package ut3$user#.test_cursor_grants is
2+
--%suite()
3+
4+
procedure run_test_join_by_cursor;
5+
procedure run_test_equal_cursor;
6+
procedure run_test_not_empty_cursor;
7+
procedure run_test_have_count_cursor;
8+
procedure run_test_empty_cursor;
9+
10+
--%test(execute join by test)
11+
procedure test_join_by_cursor;
12+
13+
--%test(execute equal test)
14+
procedure test_equal_cursor;
15+
16+
--%test(execute not empty test)
17+
procedure test_not_empty_cursor;
18+
19+
--%test(execute have_count test)
20+
procedure test_have_count_cursor;
21+
22+
--%test(execute empty test)
23+
procedure test_empty_cursor;
24+
25+
end;
26+
/

0 commit comments

Comments
 (0)