diff --git a/.travis/install.sh b/.travis/install.sh index bb117c67c..646458489 100755 --- a/.travis/install.sh +++ b/.travis/install.sh @@ -5,6 +5,7 @@ set -ev #install core of utplsql time "$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <<-SQL +whenever sqlerror exit failure rollback set feedback off set verify off @@ -57,46 +58,73 @@ SQL fi -#additional privileges to run scripted tests -time "$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <<-SQL -set feedback on ---needed for Mystats script to work -grant select any dictionary to $UT3_OWNER; ---Needed for testing a coverage outside ut3_owner. -grant create any procedure, drop any procedure, execute any procedure to $UT3_OWNER; -SQL -#Create user that will own the tests that are relevant to internal framework time "$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <<-SQL set feedback off -@create_utplsql_owner.sql $UT3_TESTER $UT3_TESTER_PASSWORD $UT3_TABLESPACE ---needed for disabling DDL trigger and testint parser without trigger enabled/present -grant alter any trigger to ut3_tester; +whenever sqlerror exit failure rollback + +-------------------------------------------------------------------------------- +PROMPT Adding back create-trigger privilege to $UT3_OWNER for testing +grant administer database trigger to $UT3_OWNER; + +-------------------------------------------------------------------------------- +PROMPT Creating $UT3_TESTER - Power-user for testing internal framework code + +create user $UT3_TESTER identified by "$UT3_TESTER_PASSWORD" default tablespace $UT3_TABLESPACE quota unlimited on $UT3_TABLESPACE; +grant create session, create procedure, create type, create table to $UT3_TESTER; + +PROMPT Additional grants for disabling DDL trigger and testing parser without trigger enabled/present + +grant alter any trigger to $UT3_TESTER; grant administer database trigger to $UT3_TESTER; -exit -SQL +grant execute on dbms_lock to $UT3_TESTER; -#Create additional UT3$USER# to test for special characters and front end API testing -time "$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <<-SQL -set feedback off -@create_utplsql_owner.sql $UT3_USER $UT3_USER_PASSWORD $UT3_TABLESPACE ---Grant UT3 framework to min user -@create_user_grants.sql $UT3_OWNER $UT3_USER -exit -SQL +PROMPT Granting $UT3_OWNER code to $UT3_TESTER -#Create additional UT3_TESTER_HELPER that will provide a functions to allow min grant test user setup test -time "$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <<-SQL -set feedback off -@create_utplsql_owner.sql $UT3_TESTER_HELPER $UT3_TESTER_HELPER_PASSWORD $UT3_TABLESPACE ---needed for testing distributed transactions +begin + for i in ( + select object_name from all_objects t + where t.object_type in ('PACKAGE','TYPE') + and owner = 'UT3' + and generated = 'N' + and object_name not like 'SYS%') + loop + execute immediate 'grant execute on ut3."'||i.object_name||'" to UT3_TESTER'; + end loop; +end; +/ + +PROMPT Granting $UT3_OWNER tables to $UT3_TESTER + +begin + for i in ( select table_name from all_tables t where owner = 'UT3' and nested = 'NO' and IOT_TYPE is NULL) + loop + execute immediate 'grant select on UT3.'||i.table_name||' to UT3_TESTER'; + end loop; +end; +/ + + +-------------------------------------------------------------------------------- +PROMPT Creating $UT3_USER - minimal privileges user for API testing + +create user $UT3_USER identified by "$UT3_USER_PASSWORD" default tablespace $UT3_TABLESPACE quota unlimited on $UT3_TABLESPACE; +grant create session, create procedure, create type, create table to $UT3_USER; + + +-------------------------------------------------------------------------------- +PROMPT Creating $UT3_TESTER_HELPER - provides functions to allow min grant test user setup tests. + +create user $UT3_TESTER_HELPER identified by "$UT3_TESTER_HELPER_PASSWORD" default tablespace $UT3_TABLESPACE quota unlimited on $UT3_TABLESPACE; +grant create session, create procedure, create type, create table to $UT3_TESTER_HELPER; + +PROMPT Grants for testing distributed transactions grant create public database link to $UT3_TESTER_HELPER; grant drop public database link to $UT3_TESTER_HELPER; -set feedback on ---Needed for testing coverage outside of main UT3 schema. + +PROMPT Grants for testing coverage outside of main UT3 schema. 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; grant create job to $UT3_TESTER_HELPER; ---Needed to allow for enable/disable of annotation triggers -grant administer database trigger to $UT3_TESTER_HELPER; + exit SQL diff --git a/source/create_utplsql_owner.sql b/source/create_utplsql_owner.sql index 9d163d802..ee161c99c 100644 --- a/source/create_utplsql_owner.sql +++ b/source/create_utplsql_owner.sql @@ -29,7 +29,7 @@ prompt Creating utPLSQL user &&ut3_user create user &ut3_user identified by "&ut3_password" default tablespace &ut3_tablespace quota unlimited on &ut3_tablespace; -grant create session, create sequence, create procedure, create type, create table, create view, create synonym, administer database trigger to &ut3_user; +grant create session, create sequence, create procedure, create type, create table, create view, create synonym to &ut3_user; begin $if dbms_db_version.version < 18 $then diff --git a/source/install_ddl_trigger.sql b/source/install_ddl_trigger.sql index 1395cc50c..843ee0c07 100644 --- a/source/install_ddl_trigger.sql +++ b/source/install_ddl_trigger.sql @@ -18,5 +18,7 @@ @@define_ut3_owner_param.sql @@check_sys_grants.sql "'ADMINISTER DATABASE TRIGGER','CREATE TRIGGER'" -@@install_component.sql 'core/annotations/ut_trigger_annotation_parsing.trg' +grant administer database trigger to &&ut3_owner; +@@install_component.sql 'core/annotations/ut_trigger_annotation_parsing.trg' +revoke administer database trigger from &&ut3_owner; diff --git a/source/install_headless_with_trigger.sql b/source/install_headless_with_trigger.sql index 0e13d7a59..16d81f3c6 100644 --- a/source/install_headless_with_trigger.sql +++ b/source/install_headless_with_trigger.sql @@ -21,6 +21,6 @@ @@install.sql &&ut3_owner @@create_synonyms_and_grants_for_public.sql &&ut3_owner -@@install_ddl_trigger.sql +@@install_ddl_trigger.sql &&ut3_owner exit diff --git a/source/uninstall_objects.sql b/source/uninstall_objects.sql index a7e6b947e..9d2c0d61e 100644 --- a/source/uninstall_objects.sql +++ b/source/uninstall_objects.sql @@ -174,8 +174,6 @@ drop table ut_compound_data_diff_tmp purge; drop table ut_json_data_diff_tmp; -drop trigger ut_trigger_annotation_parsing; - drop package ut_annotation_manager; drop package ut_annotation_parser; diff --git a/test/grant_ut3_owner_to_ut3_tester.sql b/test/grant_ut3_owner_to_ut3_tester.sql deleted file mode 100644 index 19424be1a..000000000 --- a/test/grant_ut3_owner_to_ut3_tester.sql +++ /dev/null @@ -1,35 +0,0 @@ -set define off -whenever sqlerror exit failure rollback -whenever oserror exit failure rollback - -alter session set plsql_optimize_level=0; - -set linesize 200 -set define on -set verify off - -prompt Empowering UT3_TESTER to UT3_OWNER objects - -begin - for i in ( select object_name from all_objects t - where t.object_type in ('PACKAGE','TYPE') - and owner = 'UT3' - and generated = 'N' - and lower(object_name) not like 'sys%') - loop - execute immediate 'grant execute on ut3."'||i.object_name||'" to UT3_TESTER'; - end loop; -end; -/ - -prompt Empowering UT3_TESTER to UT3_OWNER tables - -begin - for i in ( select table_name from all_tables t where owner = 'UT3' and nested = 'NO' and IOT_TYPE is NULL) - loop - execute immediate 'grant select on UT3.'||i.table_name||' to UT3_TESTER'; - end loop; -end; -/ - -exit; diff --git a/test/install_and_run_tests.sh b/test/install_and_run_tests.sh index 01bd378fb..04f51fb3c 100755 --- a/test/install_and_run_tests.sh +++ b/test/install_and_run_tests.sh @@ -3,28 +3,7 @@ set -ev #goto git root directory git rev-parse && cd "$(git rev-parse --show-cdup)" - cd test -time "$SQLCLI" sys/${ORACLE_PWD}@//${CONNECTION_STR} AS SYSDBA @grant_ut3_owner_to_ut3_tester.sql - -time "$SQLCLI" ${UT3_TESTER_HELPER}/${UT3_TESTER_HELPER_PASSWORD}@//${CONNECTION_STR} @install_ut3_tester_helper.sql - -time "$SQLCLI" ${UT3_USER}/${UT3_USER_PASSWORD}@//${CONNECTION_STR} @install_ut3_user_tests.sql - -time "$SQLCLI" ${UT3_TESTER}/${UT3_TESTER_PASSWORD}@//${CONNECTION_STR} @install_ut3_tester_tests.sql - -cd .. - -time utPLSQL-cli/bin/utplsql run ${UT3_TESTER_HELPER}/${UT3_TESTER_HELPER_PASSWORD}@${CONNECTION_STR} \ --source_path=source -owner=ut3 \ --p='ut3_tester,ut3$user#' \ --test_path=test -c \ --f=ut_coverage_sonar_reporter -o=coverage.xml \ --f=ut_coverage_cobertura_reporter -o=cobertura.xml \ --f=ut_coverage_html_reporter -o=coverage.html \ --f=ut_coveralls_reporter -o=coverage.json \ --f=ut_sonar_test_reporter -o=test_results.xml \ --f=ut_junit_reporter -o=junit_test_results.xml \ --f=ut_tfs_junit_reporter -o=tfs_test_results.xml \ --f=ut_documentation_reporter -o=test_results.log -s +time . ./${DIR}/install_tests.sh +time . ./${DIR}/run_tests.sh diff --git a/test/install_tests.sh b/test/install_tests.sh new file mode 100755 index 000000000..e07b4d2b3 --- /dev/null +++ b/test/install_tests.sh @@ -0,0 +1,13 @@ +#!/bin/bash +set -ev + +#goto git root directory +git rev-parse && cd "$(git rev-parse --show-cdup)" +cd test + +"$SQLCLI" ${UT3_TESTER_HELPER}/${UT3_TESTER_HELPER_PASSWORD}@//${CONNECTION_STR} @install_ut3_tester_helper.sql + +"$SQLCLI" ${UT3_USER}/${UT3_USER_PASSWORD}@//${CONNECTION_STR} @install_ut3_user_tests.sql + +"$SQLCLI" ${UT3_TESTER}/${UT3_TESTER_PASSWORD}@//${CONNECTION_STR} @install_ut3_tester_tests.sql + diff --git a/test/run_tests.sh b/test/run_tests.sh new file mode 100755 index 000000000..29086f5f7 --- /dev/null +++ b/test/run_tests.sh @@ -0,0 +1,18 @@ +#!/bin/bash +set -ev + +#goto git root directory +git rev-parse && cd "$(git rev-parse --show-cdup)" + +time utPLSQL-cli/bin/utplsql run ${UT3_TESTER_HELPER}/${UT3_TESTER_HELPER_PASSWORD}@${CONNECTION_STR} \ +-source_path=source -owner=ut3 \ +-p='ut3_tester,ut3$user#' \ +-test_path=test -c \ +-f=ut_coverage_sonar_reporter -o=coverage.xml \ +-f=ut_coverage_cobertura_reporter -o=cobertura.xml \ +-f=ut_coverage_html_reporter -o=coverage.html \ +-f=ut_coveralls_reporter -o=coverage.json \ +-f=ut_sonar_test_reporter -o=test_results.xml \ +-f=ut_junit_reporter -o=junit_test_results.xml \ +-f=ut_tfs_junit_reporter -o=tfs_test_results.xml \ +-f=ut_documentation_reporter -o=test_results.log -s