SQL privileges fix and unit tests
* Fixed privileges on both variants of defs.uoc_natural_resource() * Added user unit tests which check execution privileges on all (new) stored procedures and INSERT/UPDATE/SELECT/DELETE privileges on all (new) tables
This commit is contained in:
parent
d4945d8e21
commit
e7d2072813
19 changed files with 258 additions and 2 deletions
|
@ -393,7 +393,7 @@ CREATE OR REPLACE FUNCTION defs.uoc_natural_resource(
|
||||||
_recovery_dev DOUBLE PRECISION )
|
_recovery_dev DOUBLE PRECISION )
|
||||||
RETURNS defs.resource_update_result
|
RETURNS defs.resource_update_result
|
||||||
STRICT VOLATILE
|
STRICT VOLATILE
|
||||||
SECURITY INVOKER
|
SECURITY DEFINER
|
||||||
AS $$
|
AS $$
|
||||||
SELECT defs.uoc_natres_internal( $1 , $2 , NULL , $3 , $4 , $5 , $6 , $7 ,
|
SELECT defs.uoc_natres_internal( $1 , $2 , NULL , $3 , $4 , $5 , $6 , $7 ,
|
||||||
$8 , $9 , $10 );
|
$8 , $9 , $10 );
|
||||||
|
@ -447,7 +447,7 @@ CREATE OR REPLACE FUNCTION defs.uoc_natural_resource(
|
||||||
_recovery_dev DOUBLE PRECISION )
|
_recovery_dev DOUBLE PRECISION )
|
||||||
RETURNS defs.resource_update_result
|
RETURNS defs.resource_update_result
|
||||||
STRICT VOLATILE
|
STRICT VOLATILE
|
||||||
SECURITY INVOKER
|
SECURITY DEFINER
|
||||||
AS $$
|
AS $$
|
||||||
SELECT defs.uoc_natres_internal( $1 , $2 , $3 , $4 , $5 , $6 , $7 , $8 ,
|
SELECT defs.uoc_natres_internal( $1 , $2 , $3 , $4 , $5 , $6 , $7 , $8 ,
|
||||||
$9 , $10 , $11 );
|
$9 , $10 , $11 );
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
* Test privileges on defs.resources
|
||||||
|
*/
|
||||||
|
BEGIN;
|
||||||
|
SELECT plan( 4 );
|
||||||
|
|
||||||
|
SELECT diag_test_name( 'defs.resources - INSERT privileges' );
|
||||||
|
SELECT throws_ok(
|
||||||
|
$$ INSERT INTO defs.resources(
|
||||||
|
resource_name_id , resource_description_id , resource_weight
|
||||||
|
) VALUES (
|
||||||
|
1 , 2 , 1
|
||||||
|
); $$ ,
|
||||||
|
42501 );
|
||||||
|
|
||||||
|
SELECT diag_test_name( 'defs.resources - UPDATE privileges' );
|
||||||
|
SELECT throws_ok(
|
||||||
|
$$ UPDATE defs.resources SET resource_weight = 10; $$ ,
|
||||||
|
42501 );
|
||||||
|
|
||||||
|
SELECT diag_test_name( 'defs.resources - SELECT privileges' );
|
||||||
|
SELECT throws_ok(
|
||||||
|
$$ SELECT * FROM defs.resources; $$ ,
|
||||||
|
42501 );
|
||||||
|
|
||||||
|
SELECT diag_test_name( 'defs.resources - DELETE privileges' );
|
||||||
|
SELECT throws_ok(
|
||||||
|
$$ DELETE FROM defs.resources; $$ ,
|
||||||
|
42501 );
|
||||||
|
|
||||||
|
SELECT * FROM finish( );
|
||||||
|
ROLLBACK;
|
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
* Test privileges on defs.natural_resources
|
||||||
|
*/
|
||||||
|
BEGIN;
|
||||||
|
SELECT plan( 4 );
|
||||||
|
|
||||||
|
SELECT diag_test_name( 'defs.natural_resources - INSERT privileges' );
|
||||||
|
SELECT throws_ok(
|
||||||
|
$$ INSERT INTO defs.natural_resources( resource_name_id ) VALUES ( 1 ); $$ ,
|
||||||
|
42501 );
|
||||||
|
|
||||||
|
SELECT diag_test_name( 'defs.natural_resources - UPDATE privileges' );
|
||||||
|
SELECT throws_ok(
|
||||||
|
$$ UPDATE defs.natural_resources SET natres_p_presence = 0.5; $$ ,
|
||||||
|
42501 );
|
||||||
|
|
||||||
|
SELECT diag_test_name( 'defs.natural_resources - SELECT privileges' );
|
||||||
|
SELECT throws_ok(
|
||||||
|
$$ SELECT * FROM defs.natural_resources; $$ ,
|
||||||
|
42501 );
|
||||||
|
|
||||||
|
SELECT diag_test_name( 'defs.natural_resources - DELETE privileges' );
|
||||||
|
SELECT throws_ok(
|
||||||
|
$$ DELETE FROM defs.natural_resources; $$ ,
|
||||||
|
42501 );
|
||||||
|
|
||||||
|
SELECT * FROM finish( );
|
||||||
|
ROLLBACK;
|
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
* Test privileges on verse.resource_providers
|
||||||
|
*/
|
||||||
|
BEGIN;
|
||||||
|
SELECT plan( 4 );
|
||||||
|
|
||||||
|
SELECT diag_test_name( 'verse.resource_providers - INSERT privileges' );
|
||||||
|
SELECT throws_ok(
|
||||||
|
$$ INSERT INTO verse.resource_providers( resource_name_id ) VALUES ( 1 ); $$ ,
|
||||||
|
42501 );
|
||||||
|
|
||||||
|
SELECT diag_test_name( 'verse.resource_providers - UPDATE privileges' );
|
||||||
|
SELECT throws_ok(
|
||||||
|
$$ UPDATE verse.resource_providers SET resprov_quantity = 42; $$ ,
|
||||||
|
42501 );
|
||||||
|
|
||||||
|
SELECT diag_test_name( 'verse.resource_providers - SELECT privileges' );
|
||||||
|
SELECT throws_ok(
|
||||||
|
$$ SELECT * FROM verse.resource_providers; $$ ,
|
||||||
|
42501 );
|
||||||
|
|
||||||
|
SELECT diag_test_name( 'verse.resource_providers - DELETE privileges' );
|
||||||
|
SELECT throws_ok(
|
||||||
|
$$ DELETE FROM verse.resource_providers; $$ ,
|
||||||
|
42501 );
|
||||||
|
|
||||||
|
SELECT * FROM finish( );
|
||||||
|
ROLLBACK;
|
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
* Test privileges on emp.resources
|
||||||
|
*/
|
||||||
|
BEGIN;
|
||||||
|
SELECT plan( 4 );
|
||||||
|
|
||||||
|
SELECT diag_test_name( 'emp.resources - INSERT privileges' );
|
||||||
|
SELECT throws_ok(
|
||||||
|
$$ INSERT INTO emp.resources( resource_name_id ) VALUES ( 1 ); $$ ,
|
||||||
|
42501 );
|
||||||
|
|
||||||
|
SELECT diag_test_name( 'emp.resources - UPDATE privileges' );
|
||||||
|
SELECT throws_ok(
|
||||||
|
$$ UPDATE emp.resources SET empres_possessed = 42; $$ ,
|
||||||
|
42501 );
|
||||||
|
|
||||||
|
SELECT diag_test_name( 'emp.resources - SELECT privileges' );
|
||||||
|
SELECT throws_ok(
|
||||||
|
$$ SELECT * FROM emp.resources; $$ ,
|
||||||
|
42501 );
|
||||||
|
|
||||||
|
SELECT diag_test_name( 'emp.resources - DELETE privileges' );
|
||||||
|
SELECT throws_ok(
|
||||||
|
$$ DELETE FROM emp.resources; $$ ,
|
||||||
|
42501 );
|
||||||
|
|
||||||
|
SELECT * FROM finish( );
|
||||||
|
ROLLBACK;
|
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
* Test privileges on emp.mining_settings
|
||||||
|
*/
|
||||||
|
BEGIN;
|
||||||
|
SELECT plan( 4 );
|
||||||
|
|
||||||
|
SELECT diag_test_name( 'emp.mining_settings - INSERT privileges' );
|
||||||
|
SELECT throws_ok(
|
||||||
|
$$ INSERT INTO emp.mining_settings( resource_name_id ) VALUES ( 1 ); $$ ,
|
||||||
|
42501 );
|
||||||
|
|
||||||
|
SELECT diag_test_name( 'emp.mining_settings - UPDATE privileges' );
|
||||||
|
SELECT throws_ok(
|
||||||
|
$$ UPDATE emp.mining_settings SET empmset_weight = 42; $$ ,
|
||||||
|
42501 );
|
||||||
|
|
||||||
|
SELECT diag_test_name( 'emp.mining_settings - SELECT privileges' );
|
||||||
|
SELECT throws_ok(
|
||||||
|
$$ SELECT * FROM emp.mining_settings; $$ ,
|
||||||
|
42501 );
|
||||||
|
|
||||||
|
SELECT diag_test_name( 'emp.mining_settings - DELETE privileges' );
|
||||||
|
SELECT throws_ok(
|
||||||
|
$$ DELETE FROM emp.mining_settings; $$ ,
|
||||||
|
42501 );
|
||||||
|
|
||||||
|
SELECT * FROM finish( );
|
||||||
|
ROLLBACK;
|
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
* Test privileges on emp.planet_mining_settings
|
||||||
|
*/
|
||||||
|
BEGIN;
|
||||||
|
SELECT plan( 4 );
|
||||||
|
|
||||||
|
SELECT diag_test_name( 'emp.planet_mining_settings - INSERT privileges' );
|
||||||
|
SELECT throws_ok(
|
||||||
|
$$ INSERT INTO emp.planet_mining_settings( resource_name_id ) VALUES ( 1 ); $$ ,
|
||||||
|
42501 );
|
||||||
|
|
||||||
|
SELECT diag_test_name( 'emp.planet_mining_settings - UPDATE privileges' );
|
||||||
|
SELECT throws_ok(
|
||||||
|
$$ UPDATE emp.planet_mining_settings SET emppmset_weight = 42; $$ ,
|
||||||
|
42501 );
|
||||||
|
|
||||||
|
SELECT diag_test_name( 'emp.planet_mining_settings - SELECT privileges' );
|
||||||
|
SELECT throws_ok(
|
||||||
|
$$ SELECT * FROM emp.planet_mining_settings; $$ ,
|
||||||
|
42501 );
|
||||||
|
|
||||||
|
SELECT diag_test_name( 'emp.planet_mining_settings - DELETE privileges' );
|
||||||
|
SELECT throws_ok(
|
||||||
|
$$ DELETE FROM emp.planet_mining_settings; $$ ,
|
||||||
|
42501 );
|
||||||
|
|
||||||
|
SELECT * FROM finish( );
|
||||||
|
ROLLBACK;
|
|
@ -0,0 +1,14 @@
|
||||||
|
/*
|
||||||
|
* Test privileges on defs.uoc_resource_internal()
|
||||||
|
*/
|
||||||
|
BEGIN;
|
||||||
|
|
||||||
|
SELECT plan( 1 );
|
||||||
|
|
||||||
|
SELECT diag_test_name( 'defs.uoc_resource_internal() - Privileges' );
|
||||||
|
PREPARE _test_this AS
|
||||||
|
SELECT defs.uoc_resource_internal( 'test1' , 'test2' , NULL , 1 );
|
||||||
|
SELECT throws_ok( '_test_this' , 42501 );
|
||||||
|
|
||||||
|
SELECT * FROM finish( );
|
||||||
|
ROLLBACK;
|
|
@ -0,0 +1,14 @@
|
||||||
|
/*
|
||||||
|
* Test privileges on defs.uoc_resource()
|
||||||
|
*/
|
||||||
|
BEGIN;
|
||||||
|
SELECT plan( 2 );
|
||||||
|
|
||||||
|
SELECT diag_test_name( 'defs.uoc_resource() - Privileges (without category)' );
|
||||||
|
SELECT is( defs.uoc_resource( 'test1' , 'test2' , 1 ) , 'BAD_STRINGS' );
|
||||||
|
|
||||||
|
SELECT diag_test_name( 'defs.uoc_resource() - Privileges (with category)' );
|
||||||
|
SELECT is( defs.uoc_resource( 'test1' , 'test2' , 'test3' , 1 ) , 'BAD_STRINGS' );
|
||||||
|
|
||||||
|
SELECT * FROM finish( );
|
||||||
|
ROLLBACK;
|
|
@ -0,0 +1,16 @@
|
||||||
|
/*
|
||||||
|
* Test privileges on defs.uoc_natres_internal()
|
||||||
|
*/
|
||||||
|
BEGIN;
|
||||||
|
|
||||||
|
SELECT plan( 1 );
|
||||||
|
|
||||||
|
SELECT diag_test_name( 'defs.uoc_natres_internal() - Privileges' );
|
||||||
|
PREPARE _test_this AS
|
||||||
|
SELECT defs.uoc_natres_internal( 'test1' , 'test2' , NULL , 1 ,
|
||||||
|
0.5 , 100 , 50 , 0.5 , 0.1 , 0.5 , 0.1
|
||||||
|
);
|
||||||
|
SELECT throws_ok( '_test_this' , 42501 );
|
||||||
|
|
||||||
|
SELECT * FROM finish( );
|
||||||
|
ROLLBACK;
|
|
@ -0,0 +1,18 @@
|
||||||
|
/*
|
||||||
|
* Test privileges on defs.uoc_natural_resource()
|
||||||
|
*/
|
||||||
|
BEGIN;
|
||||||
|
SELECT plan( 2 );
|
||||||
|
|
||||||
|
SELECT diag_test_name( 'defs.uoc_natural_resource() - Privileges (without category)' );
|
||||||
|
SELECT is( defs.uoc_natural_resource( 'test1' , 'test2' , 1 ,
|
||||||
|
0.5 , 100 , 50 , 0.5 , 0.1 , 0.5 , 0.1
|
||||||
|
) , 'BAD_STRINGS' );
|
||||||
|
|
||||||
|
SELECT diag_test_name( 'defs.uoc_natural_resource() - Privileges (with category)' );
|
||||||
|
SELECT is( defs.uoc_natural_resource( 'test1' , 'test2' , 'test3' , 1 ,
|
||||||
|
0.5 , 100 , 50 , 0.5 , 0.1 , 0.5 , 0.1
|
||||||
|
) , 'BAD_STRINGS' );
|
||||||
|
|
||||||
|
SELECT * FROM finish( );
|
||||||
|
ROLLBACK;
|
|
@ -0,0 +1,11 @@
|
||||||
|
/*
|
||||||
|
* Test privileges on verse.compute_provider_regeneration()
|
||||||
|
*/
|
||||||
|
BEGIN;
|
||||||
|
SELECT plan( 1 );
|
||||||
|
|
||||||
|
SELECT diag_test_name( 'verse.compute_provider_regeneration() - Privileges' );
|
||||||
|
SELECT throws_ok( 'SELECT verse.compute_provider_regeneration( 100.0 , 100.0 , 0.5 )' , 42501 );
|
||||||
|
|
||||||
|
SELECT * FROM finish( );
|
||||||
|
ROLLBACK;
|
|
@ -0,0 +1,11 @@
|
||||||
|
/*
|
||||||
|
* Test privileges on sys.process_planet_res_regen_updates()
|
||||||
|
*/
|
||||||
|
BEGIN;
|
||||||
|
SELECT plan( 1 );
|
||||||
|
|
||||||
|
SELECT diag_test_name( 'sys.process_planet_res_regen_updates() - Privileges' );
|
||||||
|
SELECT throws_ok( 'SELECT sys.process_planet_res_regen_updates( 1 )' , 42501 );
|
||||||
|
|
||||||
|
SELECT * FROM finish( );
|
||||||
|
ROLLBACK;
|
Reference in a new issue