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

Skip to content

Commit 8620240

Browse files
committed
Reorganized test-users privileges
1 parent a594288 commit 8620240

6 files changed

Lines changed: 89 additions & 90 deletions

File tree

.travis/install.sh

Lines changed: 55 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,69 @@ 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 Creating $UT3_TESTER - Power-user for testing internal framework code
68+
69+
create user $UT3_TESTER identified by "$UT3_TESTER_PASSWORD" default tablespace $UT3_TABLESPACE quota unlimited on $UT3_TABLESPACE;
70+
grant create session, create procedure, create type, create table to $UT3_TESTER;
71+
72+
PROMPT Additional grants for disabling DDL trigger and testing parser without trigger enabled/present
73+
74+
grant alter any trigger to $UT3_TESTER;
7575
grant administer database trigger to $UT3_TESTER;
76-
exit
77-
SQL
76+
grant execute on dbms_lock to $UT3_TESTER;
7877
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
78+
PROMPT Granting $UT3_OWNER code to $UT3_TESTER
8779
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
80+
begin
81+
for i in (
82+
select object_name from all_objects t
83+
where t.object_type in ('PACKAGE','TYPE')
84+
and owner = 'UT3'
85+
and generated = 'N'
86+
and object_name not like 'SYS%')
87+
loop
88+
execute immediate 'grant execute on ut3."'||i.object_name||'" to UT3_TESTER';
89+
end loop;
90+
end;
91+
/
92+
93+
PROMPT Granting $UT3_OWNER tables to $UT3_TESTER
94+
95+
begin
96+
for i in ( select table_name from all_tables t where owner = 'UT3' and nested = 'NO' and IOT_TYPE is NULL)
97+
loop
98+
execute immediate 'grant select on UT3.'||i.table_name||' to UT3_TESTER';
99+
end loop;
100+
end;
101+
/
102+
103+
104+
--------------------------------------------------------------------------------
105+
PROMPT Creating $UT3_USER - minimal privileges user for API testing
106+
107+
create user $UT3_USER identified by "$UT3_USER_PASSWORD" default tablespace $UT3_TABLESPACE quota unlimited on $UT3_TABLESPACE;
108+
grant create session, create procedure, create type, create table to $UT3_USER;
109+
110+
111+
--------------------------------------------------------------------------------
112+
PROMPT Creating $UT3_TESTER_HELPER - provides functions to allow min grant test user setup tests.
113+
114+
create user $UT3_TESTER_HELPER identified by "$UT3_TESTER_HELPER_PASSWORD" default tablespace $UT3_TABLESPACE quota unlimited on $UT3_TABLESPACE;
115+
grant create session, create procedure, create type, create table to $UT3_TESTER_HELPER;
116+
117+
PROMPT Grants for testing distributed transactions
93118
grant create public database link to $UT3_TESTER_HELPER;
94119
grant drop public database link to $UT3_TESTER_HELPER;
95-
set feedback on
96-
--Needed for testing coverage outside of main UT3 schema.
120+
121+
PROMPT Grants for testing coverage outside of main UT3 schema.
97122
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;
98123
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;
124+
101125
exit
102126
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

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)