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

Skip to content

Commit fdbc3b4

Browse files
authored
Merge pull request #950 from utPLSQL/feature/fix_privs_for_dbms_crypto
Reorganized test-users privileges
2 parents e5ec54c + 11c0752 commit fdbc3b4

9 files changed

Lines changed: 97 additions & 94 deletions

.travis/install.sh

Lines changed: 59 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ set -ev
55

66
#install core of utplsql
77
time "$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <<-SQL
8+
whenever sqlerror exit failure rollback
89
set feedback off
910
set verify off
1011
@@ -57,46 +58,73 @@ SQL
5758

5859
fi
5960

60-
#additional privileges to run scripted tests
61-
time "$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <<-SQL
62-
set feedback on
63-
--needed for Mystats script to work
64-
grant select any dictionary to $UT3_OWNER;
65-
--Needed for testing a coverage outside ut3_owner.
66-
grant create any procedure, drop any procedure, execute any procedure to $UT3_OWNER;
67-
SQL
6861

69-
#Create user that will own the tests that are relevant to internal framework
7062
time "$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <<-SQL
7163
set feedback off
72-
@create_utplsql_owner.sql $UT3_TESTER $UT3_TESTER_PASSWORD $UT3_TABLESPACE
73-
--needed for disabling DDL trigger and testint parser without trigger enabled/present
74-
grant alter any trigger to ut3_tester;
64+
whenever sqlerror exit failure rollback
65+
66+
--------------------------------------------------------------------------------
67+
PROMPT Adding back create-trigger privilege to $UT3_OWNER for testing
68+
grant administer database trigger to $UT3_OWNER;
69+
70+
--------------------------------------------------------------------------------
71+
PROMPT Creating $UT3_TESTER - Power-user for testing internal framework code
72+
73+
create user $UT3_TESTER identified by "$UT3_TESTER_PASSWORD" default tablespace $UT3_TABLESPACE quota unlimited on $UT3_TABLESPACE;
74+
grant create session, create procedure, create type, create table to $UT3_TESTER;
75+
76+
PROMPT Additional grants for disabling DDL trigger and testing parser without trigger enabled/present
77+
78+
grant alter any trigger to $UT3_TESTER;
7579
grant administer database trigger to $UT3_TESTER;
76-
exit
77-
SQL
80+
grant execute on dbms_lock to $UT3_TESTER;
7881
79-
#Create additional UT3$USER# to test for special characters and front end API testing
80-
time "$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <<-SQL
81-
set feedback off
82-
@create_utplsql_owner.sql $UT3_USER $UT3_USER_PASSWORD $UT3_TABLESPACE
83-
--Grant UT3 framework to min user
84-
@create_user_grants.sql $UT3_OWNER $UT3_USER
85-
exit
86-
SQL
82+
PROMPT Granting $UT3_OWNER code to $UT3_TESTER
8783
88-
#Create additional UT3_TESTER_HELPER that will provide a functions to allow min grant test user setup test
89-
time "$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <<-SQL
90-
set feedback off
91-
@create_utplsql_owner.sql $UT3_TESTER_HELPER $UT3_TESTER_HELPER_PASSWORD $UT3_TABLESPACE
92-
--needed for testing distributed transactions
84+
begin
85+
for i in (
86+
select object_name from all_objects t
87+
where t.object_type in ('PACKAGE','TYPE')
88+
and owner = 'UT3'
89+
and generated = 'N'
90+
and object_name not like 'SYS%')
91+
loop
92+
execute immediate 'grant execute on ut3."'||i.object_name||'" to UT3_TESTER';
93+
end loop;
94+
end;
95+
/
96+
97+
PROMPT Granting $UT3_OWNER tables to $UT3_TESTER
98+
99+
begin
100+
for i in ( select table_name from all_tables t where owner = 'UT3' and nested = 'NO' and IOT_TYPE is NULL)
101+
loop
102+
execute immediate 'grant select on UT3.'||i.table_name||' to UT3_TESTER';
103+
end loop;
104+
end;
105+
/
106+
107+
108+
--------------------------------------------------------------------------------
109+
PROMPT Creating $UT3_USER - minimal privileges user for API testing
110+
111+
create user $UT3_USER identified by "$UT3_USER_PASSWORD" default tablespace $UT3_TABLESPACE quota unlimited on $UT3_TABLESPACE;
112+
grant create session, create procedure, create type, create table to $UT3_USER;
113+
114+
115+
--------------------------------------------------------------------------------
116+
PROMPT Creating $UT3_TESTER_HELPER - provides functions to allow min grant test user setup tests.
117+
118+
create user $UT3_TESTER_HELPER identified by "$UT3_TESTER_HELPER_PASSWORD" default tablespace $UT3_TABLESPACE quota unlimited on $UT3_TABLESPACE;
119+
grant create session, create procedure, create type, create table to $UT3_TESTER_HELPER;
120+
121+
PROMPT Grants for testing distributed transactions
93122
grant create public database link to $UT3_TESTER_HELPER;
94123
grant drop public database link to $UT3_TESTER_HELPER;
95-
set feedback on
96-
--Needed for testing coverage outside of main UT3 schema.
124+
125+
PROMPT Grants for testing coverage outside of main UT3 schema.
97126
grant create any procedure, drop any procedure, execute any procedure, create any type, drop any type, execute any type, under any type, select any table, update any table, insert any table, delete any table, create any table, drop any table, alter any table, select any dictionary, create any synonym, drop any synonym to $UT3_TESTER_HELPER;
98127
grant create job to $UT3_TESTER_HELPER;
99-
--Needed to allow for enable/disable of annotation triggers
100-
grant administer database trigger to $UT3_TESTER_HELPER;
128+
101129
exit
102130
SQL

source/create_utplsql_owner.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ prompt Creating utPLSQL user &&ut3_user
2929

3030
create user &ut3_user identified by "&ut3_password" default tablespace &ut3_tablespace quota unlimited on &ut3_tablespace;
3131

32-
grant create session, create sequence, create procedure, create type, create table, create view, create synonym, administer database trigger to &ut3_user;
32+
grant create session, create sequence, create procedure, create type, create table, create view, create synonym to &ut3_user;
3333

3434
begin
3535
$if dbms_db_version.version < 18 $then

source/install_ddl_trigger.sql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,7 @@
1818
@@define_ut3_owner_param.sql
1919

2020
@@check_sys_grants.sql "'ADMINISTER DATABASE TRIGGER','CREATE TRIGGER'"
21-
@@install_component.sql 'core/annotations/ut_trigger_annotation_parsing.trg'
2221

22+
grant administer database trigger to &&ut3_owner;
23+
@@install_component.sql 'core/annotations/ut_trigger_annotation_parsing.trg'
24+
revoke administer database trigger from &&ut3_owner;

source/install_headless_with_trigger.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@
2121
@@install.sql &&ut3_owner
2222
@@create_synonyms_and_grants_for_public.sql &&ut3_owner
2323

24-
@@install_ddl_trigger.sql
24+
@@install_ddl_trigger.sql &&ut3_owner
2525

2626
exit

source/uninstall_objects.sql

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,6 @@ drop table ut_compound_data_diff_tmp purge;
174174

175175
drop table ut_json_data_diff_tmp;
176176

177-
drop trigger ut_trigger_annotation_parsing;
178-
179177
drop package ut_annotation_manager;
180178

181179
drop package ut_annotation_parser;

test/grant_ut3_owner_to_ut3_tester.sql

Lines changed: 0 additions & 35 deletions
This file was deleted.

test/install_and_run_tests.sh

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,7 @@ set -ev
33

44
#goto git root directory
55
git rev-parse && cd "$(git rev-parse --show-cdup)"
6-
76
cd test
87

9-
time "$SQLCLI" sys/${ORACLE_PWD}@//${CONNECTION_STR} AS SYSDBA @grant_ut3_owner_to_ut3_tester.sql
10-
11-
time "$SQLCLI" ${UT3_TESTER_HELPER}/${UT3_TESTER_HELPER_PASSWORD}@//${CONNECTION_STR} @install_ut3_tester_helper.sql
12-
13-
time "$SQLCLI" ${UT3_USER}/${UT3_USER_PASSWORD}@//${CONNECTION_STR} @install_ut3_user_tests.sql
14-
15-
time "$SQLCLI" ${UT3_TESTER}/${UT3_TESTER_PASSWORD}@//${CONNECTION_STR} @install_ut3_tester_tests.sql
16-
17-
cd ..
18-
19-
time utPLSQL-cli/bin/utplsql run ${UT3_TESTER_HELPER}/${UT3_TESTER_HELPER_PASSWORD}@${CONNECTION_STR} \
20-
-source_path=source -owner=ut3 \
21-
-p='ut3_tester,ut3$user#' \
22-
-test_path=test -c \
23-
-f=ut_coverage_sonar_reporter -o=coverage.xml \
24-
-f=ut_coverage_cobertura_reporter -o=cobertura.xml \
25-
-f=ut_coverage_html_reporter -o=coverage.html \
26-
-f=ut_coveralls_reporter -o=coverage.json \
27-
-f=ut_sonar_test_reporter -o=test_results.xml \
28-
-f=ut_junit_reporter -o=junit_test_results.xml \
29-
-f=ut_tfs_junit_reporter -o=tfs_test_results.xml \
30-
-f=ut_documentation_reporter -o=test_results.log -s
8+
time . ./${DIR}/install_tests.sh
9+
time . ./${DIR}/run_tests.sh

test/install_tests.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
set -ev
3+
4+
#goto git root directory
5+
git rev-parse && cd "$(git rev-parse --show-cdup)"
6+
cd test
7+
8+
"$SQLCLI" ${UT3_TESTER_HELPER}/${UT3_TESTER_HELPER_PASSWORD}@//${CONNECTION_STR} @install_ut3_tester_helper.sql
9+
10+
"$SQLCLI" ${UT3_USER}/${UT3_USER_PASSWORD}@//${CONNECTION_STR} @install_ut3_user_tests.sql
11+
12+
"$SQLCLI" ${UT3_TESTER}/${UT3_TESTER_PASSWORD}@//${CONNECTION_STR} @install_ut3_tester_tests.sql
13+

test/run_tests.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
set -ev
3+
4+
#goto git root directory
5+
git rev-parse && cd "$(git rev-parse --show-cdup)"
6+
7+
time utPLSQL-cli/bin/utplsql run ${UT3_TESTER_HELPER}/${UT3_TESTER_HELPER_PASSWORD}@${CONNECTION_STR} \
8+
-source_path=source -owner=ut3 \
9+
-p='ut3_tester,ut3$user#' \
10+
-test_path=test -c \
11+
-f=ut_coverage_sonar_reporter -o=coverage.xml \
12+
-f=ut_coverage_cobertura_reporter -o=cobertura.xml \
13+
-f=ut_coverage_html_reporter -o=coverage.html \
14+
-f=ut_coveralls_reporter -o=coverage.json \
15+
-f=ut_sonar_test_reporter -o=test_results.xml \
16+
-f=ut_junit_reporter -o=junit_test_results.xml \
17+
-f=ut_tfs_junit_reporter -o=tfs_test_results.xml \
18+
-f=ut_documentation_reporter -o=test_results.log -s

0 commit comments

Comments
 (0)