Add more tests for [un-]registering servers
This commit is contained in:
@@ -71,15 +71,64 @@ SELECT '5.1', cartodb.CDB_Federated_Server_Unregister(server := 'doesNotExist'::
|
||||
SELECT '6.1', cartodb.CDB_Federated_Server_Unregister(server := 'myRemote2'::text);
|
||||
SELECT '6.2', cartodb.CDB_Federated_Server_List_Servers();
|
||||
|
||||
-- Should show the appropiate output (database, read-write, user, pass)
|
||||
-- Test empty config
|
||||
SELECT '7.1', cartodb.CDB_Federated_Server_Register_PG(server := 'empty'::text, config := '{}');
|
||||
-- Test without passing credentials
|
||||
SELECT '7.2', cartodb.CDB_Federated_Server_Register_PG(server := 'empty'::text, config := '{
|
||||
"server": {
|
||||
"dbname": "fdw_target",
|
||||
"host": "localhost",
|
||||
"port": @@PGPORT@@,
|
||||
"extensions": "postgis",
|
||||
"updatable": "false",
|
||||
"use_remote_estimate": "true",
|
||||
"fetch_size": "1000"
|
||||
}
|
||||
}'::jsonb);
|
||||
-- Test with empty credentials
|
||||
SELECT '7.3', cartodb.CDB_Federated_Server_Register_PG(server := 'empty'::text, config := '{
|
||||
"server": {
|
||||
"dbname": "fdw_target",
|
||||
"host": "localhost",
|
||||
"port": @@PGPORT@@,
|
||||
"extensions": "postgis",
|
||||
"updatable": "false",
|
||||
"use_remote_estimate": "true",
|
||||
"fetch_size": "1000"
|
||||
},
|
||||
"credentials": { }
|
||||
}'::jsonb);
|
||||
SELECT '7.4', cartodb.CDB_Federated_Server_List_Servers();
|
||||
SELECT '7.5', cartodb.CDB_Federated_Server_Unregister(server := 'empty'::text);
|
||||
-- Test without without server options
|
||||
SELECT '7.6', cartodb.CDB_Federated_Server_Register_PG(server := 'empty'::text, config := '{
|
||||
"credentials": {
|
||||
"username": "other_remote_user",
|
||||
"password": "foobarino"
|
||||
}
|
||||
}'::jsonb);
|
||||
|
||||
-- Test multiple user mappings
|
||||
-- Should work ok with special characters
|
||||
SELECT '8.1', cartodb.CDB_Federated_Server_Register_PG(server := 'myRemote" or''not'::text, config := '{
|
||||
"server": {
|
||||
"dbname": "fdw target",
|
||||
"host": "localhost",
|
||||
"port": @@PGPORT@@,
|
||||
"extensions": "postgis",
|
||||
"updatable": "false",
|
||||
"use_remote_estimate": "true",
|
||||
"fetch_size": "1000"
|
||||
},
|
||||
"credentials": {
|
||||
"username": "fdw user",
|
||||
"password": "foo barino"
|
||||
}
|
||||
}'::jsonb);
|
||||
SELECT '8.2', cartodb.CDB_Federated_Server_List_Servers();
|
||||
SELECT '8.3', cartodb.CDB_Federated_Server_Unregister(server := 'myRemote" or''not'::text);
|
||||
|
||||
-- Should work ok with special characters in the name
|
||||
|
||||
-- Should throw with invalid or NULL config
|
||||
|
||||
-- -- List works with multiple and single server
|
||||
-- Should throw when trying to unregistering a server that doesn't exists
|
||||
SELECT '8.4', cartodb.CDB_Federated_Server_Unregister(server := 'Does not exist'::text);
|
||||
|
||||
-- Cleanup
|
||||
\set QUIET on
|
||||
|
||||
@@ -11,3 +11,13 @@
|
||||
4.2|(myRemote2,postgres_fdw,localhost,5432,fdw_target,read-only,other_remote_user)
|
||||
ERROR: Server "doesNotExist" does not exist
|
||||
6.1|
|
||||
ERROR: Server information is mandatory
|
||||
ERROR: Credentials are mandatory
|
||||
7.3|
|
||||
7.4|(empty,postgres_fdw,localhost,5432,fdw_target,read-only,)
|
||||
7.5|
|
||||
ERROR: Server information is mandatory
|
||||
8.1|
|
||||
8.2|("myRemote"" or'not",postgres_fdw,localhost,5432,"fdw target",read-only,"fdw user")
|
||||
8.3|
|
||||
ERROR: Server "Does not exist" does not exist
|
||||
|
||||
Reference in New Issue
Block a user