-
Notifications
You must be signed in to change notification settings - Fork 686
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
64 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,74 @@ | ||
-- | ||
-- SECLABEL | ||
-- | ||
-- Test suite for SECURITY LABEL ON ROLE statements | ||
-- | ||
|
||
-- first we remove one of the worker nodes to be able to test | ||
-- citus_add_node later | ||
SELECT citus_remove_node('localhost', :worker_2_port); | ||
|
||
-- now we register a label provider | ||
CREATE FUNCTION citus_test_register_label_provider() | ||
RETURNS void | ||
LANGUAGE C | ||
AS 'citus', $$citus_test_register_label_provider$$; | ||
|
||
SELECT citus_test_register_label_provider(); | ||
|
||
CREATE ROLE user1; | ||
|
||
SET citus.enable_metadata_sync TO off; | ||
-- the registered label provider is per session only | ||
-- this means that we need to maintain the same connection to the worker node | ||
-- in order for the label provider to be visible there | ||
-- hence here we create the necessary session_level_connection_to_node functions | ||
|
||
SET citus.enable_metadata_sync TO off; | ||
CREATE OR REPLACE FUNCTION start_session_level_connection_to_node(text, integer) | ||
RETURNS void | ||
LANGUAGE C STRICT VOLATILE | ||
AS 'citus', $$start_session_level_connection_to_node$$; | ||
|
||
CREATE OR REPLACE FUNCTION override_backend_data_gpid(bigint) | ||
RETURNS void | ||
LANGUAGE C STRICT IMMUTABLE | ||
AS 'citus', $$override_backend_data_gpid$$; | ||
|
||
SELECT run_command_on_workers($$SET citus.enable_metadata_sync TO off;CREATE OR REPLACE FUNCTION override_backend_data_gpid(bigint) | ||
RETURNS void | ||
LANGUAGE C STRICT IMMUTABLE | ||
AS 'citus'$$); | ||
|
||
CREATE OR REPLACE FUNCTION run_commands_on_session_level_connection_to_node(text) | ||
RETURNS void | ||
LANGUAGE C STRICT VOLATILE | ||
AS 'citus', $$run_commands_on_session_level_connection_to_node$$; | ||
|
||
CREATE OR REPLACE FUNCTION stop_session_level_connection_to_node() | ||
RETURNS void | ||
LANGUAGE C STRICT VOLATILE | ||
AS 'citus', $$stop_session_level_connection_to_node$$; | ||
|
||
RESET citus.enable_metadata_sync; | ||
|
||
-- now we establish a connection to the worker node | ||
SELECT start_session_level_connection_to_node('localhost', :worker_1_port); | ||
|
||
-- with that same connection, we register the label provider in the worker node | ||
SELECT run_commands_on_session_level_connection_to_node('SELECT citus_test_register_label_provider()'); | ||
|
||
SET citus.log_remote_commands TO on; | ||
SET citus.grep_remote_commands = '%SECURITY LABEL%'; | ||
|
||
-- then we run a security label statement which will use the same connection to the worker node | ||
-- it should finish successfully | ||
SECURITY LABEL for citus_tests_label_provider ON ROLE user1 IS 'citus_classified'; | ||
|
||
-- adding a new node will fail because the label provider is not there | ||
-- however, this is enough for testing as we can see that the SECURITY LABEL commands | ||
-- will be propagated when adding a new node | ||
SELECT 1 FROM citus_add_node('localhost', :worker_2_port); | ||
|
||
-- cleanup | ||
RESET citus.log_remote_commands; | ||
|
||
SELECT stop_session_level_connection_to_node(); | ||
|
||
DROP FUNCTION stop_session_level_connection_to_node, run_commands_on_session_level_connection_to_node, | ||
override_backend_data_gpid, start_session_level_connection_to_node; | ||
SELECT run_command_on_workers($$ DROP FUNCTION override_backend_data_gpid $$); | ||
|
||
DROP FUNCTION citus_test_register_label_provider; | ||
|
||
DROP ROLE user1; | ||
|
||
SELECT 1 FROM citus_add_node('localhost', :worker_2_port); |