Skip to content

Commit 629e086

Browse files
committed
Removed need to grant ut_annotation_manager to users.
1 parent a594288 commit 629e086

File tree

9 files changed

+112
-89
lines changed

9 files changed

+112
-89
lines changed

source/api/ut_runner.pkb

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,5 +264,39 @@ create or replace package body ut_runner is
264264
end loop;
265265
end;
266266

267+
function hash_suite_path(a_path varchar2, a_random_seed positiven) return varchar2 is
268+
l_start_pos pls_integer := 1;
269+
l_end_pos pls_integer := 1;
270+
l_result varchar2(4000);
271+
l_item varchar2(4000);
272+
l_at_end boolean := false;
273+
begin
274+
if a_random_seed is null then
275+
l_result := a_path;
276+
end if;
277+
if a_path is not null then
278+
loop
279+
l_end_pos := instr(a_path,'.',l_start_pos);
280+
if l_end_pos = 0 then
281+
l_end_pos := length(a_path)+1;
282+
l_at_end := true;
283+
end if;
284+
l_item := substr(a_path,l_start_pos,l_end_pos-l_start_pos);
285+
if l_item is not null then
286+
l_result :=
287+
l_result ||
288+
dbms_crypto.hash(
289+
to_char( dbms_utility.get_hash_value( l_item, 1, a_random_seed ) ),
290+
dbms_crypto.hash_sh1
291+
);
292+
end if;
293+
exit when l_at_end;
294+
l_result := l_result || chr(0);
295+
l_start_pos := l_end_pos + 1;
296+
end loop;
297+
end if;
298+
return l_result;
299+
end;
300+
267301
end ut_runner;
268302
/

source/api/ut_runner.pks

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,5 +140,10 @@ create or replace package ut_runner authid current_user is
140140
*/
141141
function get_reporters_list return tt_reporters_info pipelined;
142142

143+
/*
144+
* Returns a hash value of suitepath based on input path and random seed
145+
*/
146+
function hash_suite_path(a_path varchar2, a_random_seed positiven) return varchar2;
147+
143148
end ut_runner;
144149
/

source/core/annotations/ut_annotation_manager.pkb

Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -331,11 +331,9 @@ create or replace package body ut_annotation_manager as
331331
end if;
332332
end;
333333

334-
function get_annotated_objects(a_object_owner varchar2, a_object_type varchar2, a_parse_date timestamp := null) return ut_annotated_objects pipelined is
334+
function get_annotated_objects(a_object_owner varchar2, a_object_type varchar2, a_parse_date timestamp := null) return sys_refcursor is
335335
l_annotation_objs_info ut_annotation_objs_cache_info;
336336
l_cursor sys_refcursor;
337-
l_results ut_annotated_objects;
338-
c_object_fetch_limit constant integer := 10;
339337
l_full_scan_needed boolean := not ut_trigger_check.is_alive();
340338
begin
341339
ut_event_manager.trigger_event('get_annotated_objects - start');
@@ -344,55 +342,14 @@ create or replace package body ut_annotation_manager as
344342

345343
--pipe annotations from cache
346344
l_cursor := ut_annotation_cache_manager.get_annotations_for_objects(l_annotation_objs_info, a_parse_date);
347-
loop
348-
fetch l_cursor bulk collect into l_results limit c_object_fetch_limit;
349-
for i in 1 .. l_results.count loop
350-
pipe row (l_results(i));
351-
end loop;
352-
exit when l_cursor%notfound;
353-
end loop;
354-
close l_cursor;
355345
ut_event_manager.trigger_event('get_annotated_objects - end');
346+
return l_cursor;
356347
end;
357348

358349
procedure purge_cache(a_object_owner varchar2, a_object_type varchar2) is
359350
begin
360351
ut_annotation_cache_manager.purge_cache(a_object_owner, a_object_type);
361352
end;
362353

363-
function hash_suite_path(a_path varchar2, a_random_seed positiven) return varchar2 is
364-
l_start_pos pls_integer := 1;
365-
l_end_pos pls_integer := 1;
366-
l_result varchar2(4000);
367-
l_item varchar2(4000);
368-
l_at_end boolean := false;
369-
begin
370-
if a_random_seed is null then
371-
l_result := a_path;
372-
end if;
373-
if a_path is not null then
374-
loop
375-
l_end_pos := instr(a_path,'.',l_start_pos);
376-
if l_end_pos = 0 then
377-
l_end_pos := length(a_path)+1;
378-
l_at_end := true;
379-
end if;
380-
l_item := substr(a_path,l_start_pos,l_end_pos-l_start_pos);
381-
if l_item is not null then
382-
l_result :=
383-
l_result ||
384-
dbms_crypto.hash(
385-
to_char( dbms_utility.get_hash_value( l_item, 1, a_random_seed ) ),
386-
dbms_crypto.hash_sh1
387-
);
388-
end if;
389-
exit when l_at_end;
390-
l_result := l_result || chr(0);
391-
l_start_pos := l_end_pos + 1;
392-
end loop;
393-
end if;
394-
return l_result;
395-
end;
396-
397354
end ut_annotation_manager;
398355
/

source/core/annotations/ut_annotation_manager.pks

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ create or replace package ut_annotation_manager authid current_user as
3030
* @param a_parse_date date when object was last parsed
3131
* @return array containing annotated objects along with annotations for each object (nested)
3232
*/
33-
function get_annotated_objects(a_object_owner varchar2, a_object_type varchar2, a_parse_date timestamp := null) return ut_annotated_objects pipelined;
33+
function get_annotated_objects(a_object_owner varchar2, a_object_type varchar2, a_parse_date timestamp := null) return sys_refcursor;
3434

3535
/**
3636
* Rebuilds annotation cache for a specified schema and object type.
@@ -57,10 +57,5 @@ create or replace package ut_annotation_manager authid current_user as
5757
procedure purge_cache(a_object_owner varchar2, a_object_type varchar2);
5858

5959

60-
/*
61-
* Returns a hash value of suitepath based on input path and random seed
62-
*/
63-
function hash_suite_path(a_path varchar2, a_random_seed positiven) return varchar2;
64-
6560
end ut_annotation_manager;
6661
/

source/core/ut_suite_manager.pkb

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ create or replace package body ut_suite_manager is
491491
c.line_no,
492492
:a_random_seed]'
493493
else
494-
' {:owner:}.ut_annotation_manager.hash_suite_path(
494+
' {:owner:}.ut_runner.hash_suite_path(
495495
c.path, :a_random_seed
496496
) desc nulls last'
497497
end;
@@ -614,14 +614,9 @@ create or replace package body ut_suite_manager is
614614
begin
615615
ut_event_manager.trigger_event('refresh_cache - start');
616616
l_suite_cache_time := ut_suite_cache_manager.get_schema_parse_time(a_owner_name);
617-
open l_annotations_cursor for
618-
q'[select value(x)
619-
from table(
620-
]' || ut_utils.ut_owner || q'[.ut_annotation_manager.get_annotated_objects(
621-
:a_owner_name, 'PACKAGE', :a_suite_cache_parse_time
622-
)
623-
)x ]'
624-
using a_owner_name, l_suite_cache_time;
617+
l_annotations_cursor := ut_annotation_manager.get_annotated_objects(
618+
a_owner_name, 'PACKAGE', l_suite_cache_time
619+
);
625620

626621
build_and_cache_suites(a_owner_name, l_annotations_cursor);
627622

source/create_synonyms_and_grants_for_public.sql

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,12 @@ whenever oserror exit failure rollback
3131

3232
alter session set current_schema = &&ut3_owner;
3333

34+
--expectations
3435
grant execute on &&ut3_owner..ut_expectation to public;
3536
grant execute on &&ut3_owner..ut_expectation_compound to public;
3637
grant execute on &&ut3_owner..ut_expectation_json to public;
38+
39+
--matchers
3740
grant execute on &&ut3_owner..ut_be_between to public;
3841
grant execute on &&ut3_owner..ut_be_empty to public;
3942
grant execute on &&ut3_owner..ut_be_false to public;
@@ -48,8 +51,22 @@ grant execute on &&ut3_owner..ut_be_true to public;
4851
grant execute on &&ut3_owner..ut_equal to public;
4952
grant execute on &&ut3_owner..ut_have_count to public;
5053
grant execute on &&ut3_owner..ut_match to public;
54+
55+
--public API
5156
grant execute on &&ut3_owner..ut to public;
5257
grant execute on &&ut3_owner..ut_runner to public;
58+
grant execute on &&ut3_owner..ut_file_mappings to public;
59+
grant execute on &&ut3_owner..ut_file_mapping to public;
60+
grant execute on &&ut3_owner..ut_file_mapper to public;
61+
grant execute on &&ut3_owner..ut_key_value_pairs to public;
62+
grant execute on &&ut3_owner..ut_key_value_pair to public;
63+
64+
--generic types
65+
grant execute on &&ut3_owner..ut_varchar2_list to public;
66+
grant execute on &&ut3_owner..ut_varchar2_rows to public;
67+
grant execute on &&ut3_owner..ut_integer_list to public;
68+
69+
--reporters
5370
grant execute on &&ut3_owner..ut_debug_reporter to public;
5471
grant execute on &&ut3_owner..ut_teamcity_reporter to public;
5572
grant execute on &&ut3_owner..ut_xunit_reporter to public;
@@ -60,37 +77,39 @@ grant execute on &&ut3_owner..ut_coverage_html_reporter to public;
6077
grant execute on &&ut3_owner..ut_coverage_sonar_reporter to public;
6178
grant execute on &&ut3_owner..ut_coveralls_reporter to public;
6279
grant execute on &&ut3_owner..ut_coverage_cobertura_reporter to public;
80+
grant execute on &&ut3_owner..ut_realtime_reporter to public;
81+
grant execute on &&ut3_owner..ut_sonar_test_reporter to public;
82+
83+
--reporters base
6384
grant execute on &&ut3_owner..ut_reporters to public;
64-
grant execute on &&ut3_owner..ut_varchar2_list to public;
65-
grant execute on &&ut3_owner..ut_varchar2_rows to public;
66-
grant execute on &&ut3_owner..ut_integer_list to public;
6785
grant execute on &&ut3_owner..ut_reporter_base to public;
6886
grant execute on &&ut3_owner..ut_output_reporter_base to public;
69-
grant execute on &&ut3_owner..ut_output_data_row to public;
70-
grant execute on &&ut3_owner..ut_output_data_rows to public;
7187
grant execute on &&ut3_owner..ut_coverage_reporter_base to public;
7288
grant execute on &&ut3_owner..ut_console_reporter_base to public;
89+
90+
--coverage
7391
grant execute on &&ut3_owner..ut_coverage to public;
7492
grant execute on &&ut3_owner..ut_coverage_options to public;
7593
grant execute on &&ut3_owner..ut_coverage_helper to public;
94+
95+
--outputs
96+
grant execute on &&ut3_owner..ut_output_data_row to public;
97+
grant execute on &&ut3_owner..ut_output_data_rows to public;
7698
grant execute on &&ut3_owner..ut_output_buffer_base to public;
7799
grant execute on &&ut3_owner..ut_output_table_buffer to public;
78100
grant execute on &&ut3_owner..ut_output_clob_table_buffer to public;
79-
grant execute on &&ut3_owner..ut_file_mappings to public;
80-
grant execute on &&ut3_owner..ut_file_mapping to public;
81-
grant execute on &&ut3_owner..ut_file_mapper to public;
82-
grant execute on &&ut3_owner..ut_key_value_pairs to public;
83-
grant execute on &&ut3_owner..ut_key_value_pair to public;
101+
102+
--user temp tables
84103
grant select, insert, update, delete on &&ut3_owner..ut_compound_data_tmp to public;
85104
grant select, insert, update, delete on &&ut3_owner..ut_compound_data_diff_tmp to public;
86-
grant execute on &&ut3_owner..ut_sonar_test_reporter to public;
105+
87106
grant execute on &&ut3_owner..ut_annotations to public;
88107
grant execute on &&ut3_owner..ut_annotation to public;
89-
grant execute on &&ut3_owner..ut_annotation_manager to public;
90108
grant execute on &&ut3_owner..ut_annotated_object to public;
91109
grant execute on &&ut3_owner..ut_annotated_objects to public;
92110
grant select on &&ut3_owner..ut_annotation_cache_info to public;
93111
grant select on &&ut3_owner..ut_annotation_cache to public;
112+
94113
grant execute on &&ut3_owner..ut_executables to public;
95114
grant execute on &&ut3_owner..ut_executable_test to public;
96115
grant select on &&ut3_owner..ut_suite_cache to public;
@@ -102,7 +121,6 @@ grant execute on &&ut3_owner..ut_annotation_objs_cache_info to public;
102121
grant execute on &&ut3_owner..ut_annotation_obj_cache_info to public;
103122
grant execute on &&ut3_owner..ut_suite_items_info to public;
104123
grant execute on &&ut3_owner..ut_suite_item_info to public;
105-
grant execute on &&ut3_owner..ut_realtime_reporter to public;
106124
grant select, insert, delete, update on &&ut3_owner..dbmspcc_blocks to public;
107125
grant select, insert, delete, update on &&ut3_owner..dbmspcc_runs to public;
108126
grant select, insert, delete, update on &&ut3_owner..dbmspcc_units to public;

source/create_user_grants.sql

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,12 @@ whenever oserror exit failure rollback
5151

5252
alter session set current_schema = &&ut3_owner;
5353

54+
--expectations
5455
grant execute on &&ut3_owner..ut_expectation to &ut3_user;
5556
grant execute on &&ut3_owner..ut_expectation_compound to &ut3_user;
5657
grant execute on &&ut3_owner..ut_expectation_json to &ut3_user;
5758

59+
--matchers
5860
grant execute on &&ut3_owner..ut_be_between to &ut3_user;
5961
grant execute on &&ut3_owner..ut_be_empty to &ut3_user;
6062
grant execute on &&ut3_owner..ut_be_false to &ut3_user;
@@ -69,8 +71,22 @@ grant execute on &&ut3_owner..ut_be_true to &ut3_user;
6971
grant execute on &&ut3_owner..ut_equal to &ut3_user;
7072
grant execute on &&ut3_owner..ut_have_count to &ut3_user;
7173
grant execute on &&ut3_owner..ut_match to &ut3_user;
74+
75+
--public API
7276
grant execute on &&ut3_owner..ut to &ut3_user;
7377
grant execute on &&ut3_owner..ut_runner to &ut3_user;
78+
grant execute on &&ut3_owner..ut_file_mappings to &ut3_user;
79+
grant execute on &&ut3_owner..ut_file_mapping to &ut3_user;
80+
grant execute on &&ut3_owner..ut_file_mapper to &ut3_user;
81+
grant execute on &&ut3_owner..ut_key_value_pairs to &ut3_user;
82+
grant execute on &&ut3_owner..ut_key_value_pair to &ut3_user;
83+
84+
--generic types
85+
grant execute on &&ut3_owner..ut_varchar2_list to &ut3_user;
86+
grant execute on &&ut3_owner..ut_varchar2_rows to &ut3_user;
87+
grant execute on &&ut3_owner..ut_integer_list to &ut3_user;
88+
89+
--reporters
7490
grant execute on &&ut3_owner..ut_debug_reporter to &ut3_user;
7591
grant execute on &&ut3_owner..ut_teamcity_reporter to &ut3_user;
7692
grant execute on &&ut3_owner..ut_xunit_reporter to &ut3_user;
@@ -81,41 +97,42 @@ grant execute on &&ut3_owner..ut_coverage_html_reporter to &ut3_user;
8197
grant execute on &&ut3_owner..ut_coverage_sonar_reporter to &ut3_user;
8298
grant execute on &&ut3_owner..ut_coveralls_reporter to &ut3_user;
8399
grant execute on &&ut3_owner..ut_coverage_cobertura_reporter to &ut3_user;
100+
grant execute on &&ut3_owner..ut_sonar_test_reporter to &ut3_user;
101+
102+
--reporters base
84103
grant execute on &&ut3_owner..ut_reporters to &ut3_user;
85-
grant execute on &&ut3_owner..ut_varchar2_list to &ut3_user;
86-
grant execute on &&ut3_owner..ut_varchar2_rows to &ut3_user;
87-
grant execute on &&ut3_owner..ut_integer_list to &ut3_user;
88104
grant execute on &&ut3_owner..ut_reporter_base to &ut3_user;
89105
grant execute on &&ut3_owner..ut_output_reporter_base to &ut3_user;
90106
grant execute on &&ut3_owner..ut_coverage_reporter_base to &ut3_user;
91107
grant execute on &&ut3_owner..ut_console_reporter_base to &ut3_user;
108+
109+
--coverage
92110
grant execute on &&ut3_owner..ut_coverage to &ut3_user;
93111
grant execute on &&ut3_owner..ut_coverage_options to &ut3_user;
94112
grant execute on &&ut3_owner..ut_coverage_helper to &ut3_user;
113+
114+
--outputs
95115
grant execute on &&ut3_owner..ut_output_buffer_base to &ut3_user;
96116
grant execute on &&ut3_owner..ut_output_data_row to &ut3_user;
97117
grant execute on &&ut3_owner..ut_output_data_rows to &ut3_user;
98118
grant execute on &&ut3_owner..ut_output_table_buffer to &ut3_user;
99119
grant execute on &&ut3_owner..ut_output_clob_table_buffer to &ut3_user;
100-
grant execute on &&ut3_owner..ut_file_mappings to &ut3_user;
101-
grant execute on &&ut3_owner..ut_file_mapping to &ut3_user;
102-
grant execute on &&ut3_owner..ut_file_mapper to &ut3_user;
103-
grant execute on &&ut3_owner..ut_key_value_pairs to &ut3_user;
104-
grant execute on &&ut3_owner..ut_key_value_pair to &ut3_user;
120+
121+
--user temp tables
105122
grant select, insert, update, delete on &&ut3_owner..ut_compound_data_tmp to &ut3_user;
106123
grant select, insert, update, delete on &&ut3_owner..ut_compound_data_diff_tmp to &ut3_user;
107-
grant execute on &&ut3_owner..ut_sonar_test_reporter to &ut3_user;
124+
108125
grant execute on &&ut3_owner..ut_annotations to &ut3_user;
109126
grant execute on &&ut3_owner..ut_annotation to &ut3_user;
110-
grant execute on &&ut3_owner..ut_annotation_manager to &ut3_user;
111127
grant execute on &&ut3_owner..ut_annotated_object to &ut3_user;
112128
grant execute on &&ut3_owner..ut_annotated_objects to &ut3_user;
113129
grant select on &&ut3_owner..ut_annotation_cache_info to &ut3_user;
114130
grant select on &&ut3_owner..ut_annotation_cache to &ut3_user;
131+
115132
grant execute on &&ut3_owner..ut_executables to &ut3_user;
116133
grant execute on &&ut3_owner..ut_executable_test to &ut3_user;
117134
grant select on &&ut3_owner..ut_suite_cache to &ut3_user;
118-
grant select on &&ut3_owner..ut_suite_cache_package to public;
135+
grant select on &&ut3_owner..ut_suite_cache_package to &ut3_user;
119136
grant select on &&ut3_owner..ut_suite_cache_schema to &ut3_user;
120137
grant execute on &&ut3_owner..ut_annotation_cache_manager to &ut3_user;
121138
grant execute on &&ut3_owner..ut_annotation_parser to &ut3_user;

test/ut3_tester/core/annotations/test_annotation_manager.pkb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,15 +372,17 @@ create or replace package body test_annotation_manager is
372372
end;
373373

374374
procedure no_data_for_dropped_object is
375-
l_actual sys_refcursor;
375+
l_result sys_refcursor;
376+
l_data ut3.ut_annotated_objects;
377+
l_actual sys_refcursor;
376378
begin
377379
--Arrange
378380
ut3.ut_annotation_manager.rebuild_annotation_cache(sys_context('USERENV', 'CURRENT_USER'),'PACKAGE');
379381
drop_dummy_test_package();
380382
--Act
381-
open l_actual for
382-
select * from table(ut3.ut_annotation_manager.get_annotated_objects(sys_context('USERENV', 'CURRENT_USER'),'PACKAGE'))
383-
where object_name = 'DUMMY_TEST_PACKAGE';
383+
l_result := ut3.ut_annotation_manager.get_annotated_objects(sys_context('USERENV', 'CURRENT_USER'),'PACKAGE');
384+
fetch l_result bulk collect into l_data;
385+
open l_actual for select object_name from table(l_data) where object_name = 'DUMMY_TEST_PACKAGE';
384386
--Assert
385387
ut.expect(l_actual).to_be_empty();
386388
end;

test/ut3_tester_helper/main_helper.pkb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ create or replace package body main_helper is
110110
execute immediate q'[
111111
create or replace procedure ut3$user#.parse_annotations is
112112
begin
113-
ut3.ut_annotation_manager.rebuild_annotation_cache('UT3_TESTER','PACKAGE');
113+
ut3.ut_runner.rebuild_annotation_cache('UT3_TESTER','PACKAGE');
114114
end;]';
115115
end;
116116

0 commit comments

Comments
 (0)