\c eal_db eal_superuser
--
-- Pre-Requisite: The following test case assume that Postgres Plus Advanced server 8.4 is installed on 
--               system and pgAgent is also selected in tools during the installation 
--               process. Database server is up and pgAgent is running with default settings.
-- 
--
-- NOTE: The scenario cannot be scripted into a single runnable sql file and requires
--       the following steps to be performed to verify the behavior of test case.
--

-- Testcase UDP-1-207 - FDP_ACC.1  pgAgent
-- 
-- Description: Prove that a non-superuser cannot use pgAgent to schedule a job 
--              if they do not have sufficient privileges.
--              
-- Expected Result: A non-superuser cannot schedule a job with PPAS unless they 
--                  are granted privileges by a superuser.


1. Open an edb-psql session using the following command:
/opt/PostgresPlus/8.4AS/bin/edb-psql -U enterprisedb -d edb -p 5444 -h localhost
edb-psql (8.4.4.10)
Type "help" for help.

edb=# 


2. Execute the following command for creating a non-superuser:
CREATE ROLE alice NOSUPERUSER CREATEDB LOGIN PASSWORD 'wonderland';
CREATE ROLE

3.Quit from edb-psql session using the following command:
\q

4. Execute the following command for stoping and checking status of pgAgent
--stoping pgAgent
/etc/init.d/ppasAgent stop

--verifying that pgAgent is not running
/etc/init.d/ppasAgent status
ppasAgent not running


5. Execute the following command for starting pgAgent using non-superuser alice
 /opt/PostgresPlus/8.4AS/bin/pgagent.bin -l 1 -s /var/log/ppasAgent.log hostaddr=localhost port=5444 dbname=edb user=alice


6. Execute the following command for checking status of pgAgent
--verifying that pgAgent is not running
/etc/init.d/ppasAgent status
ppasAgent not running

7. Execute the following command so verify the error thrown by database server
cat /var/log/ppasAgent.log
WARNING: Query error: ERROR:  permission denied for schema pgagent

ERROR: Unsupported schema version: . Version 3 is required - please run pgagent_upgrade.sql.

--
-- Cleanup
-- 
DROP ROLE alice CASCADE;