From 2a6e63b6182e7561742f688799afe5d9aea87fbc Mon Sep 17 00:00:00 2001 From: antoniocarlon Date: Tue, 11 Sep 2018 12:02:24 +0200 Subject: [PATCH] Fixed tests --- client/test/expected/10_admin0_test.out | 4 ++-- client/test/expected/20_admin1_test.out | 4 ++-- .../expected/21_bulk_geocoding_functions_test.out | 4 ++-- .../25_exception_safe_private_functions_test.out | 4 ++-- client/test/expected/30_namedplaces_test.out | 4 ++-- client/test/expected/40_postalcodes_test.out | 4 ++-- client/test/expected/50_ipaddresses_test.out | 4 ++-- client/test/expected/60_street_test.out | 4 ++-- .../test/expected/80_route_point_to_point_test.out | 4 ++-- client/test/expected/90_data_observatory_test.out | 12 ++++++++++++ .../expected/95_data_observatory_tables_test.out | 12 ++++++++++++ client/test/expected/999_permissions_test.out | 4 ++-- client/test/sql/10_admin0_test.sql | 4 ++-- client/test/sql/20_admin1_test.sql | 4 ++-- client/test/sql/21_bulk_geocoding_functions_test.sql | 4 ++-- .../sql/25_exception_safe_private_functions_test.sql | 4 ++-- client/test/sql/30_namedplaces_test.sql | 4 ++-- client/test/sql/40_postalcodes_test.sql | 4 ++-- client/test/sql/50_ipaddresses_test.sql | 4 ++-- client/test/sql/60_street_test.sql | 4 ++-- client/test/sql/80_route_point_to_point_test.sql | 4 ++-- client/test/sql/90_data_observatory_test.sql | 3 +++ client/test/sql/95_data_observatory_tables_test.sql | 6 +++++- client/test/sql/999_permissions_test.sql | 4 ++-- 24 files changed, 72 insertions(+), 41 deletions(-) diff --git a/client/test/expected/10_admin0_test.out b/client/test/expected/10_admin0_test.out index 9046dce..c36e98e 100644 --- a/client/test/expected/10_admin0_test.out +++ b/client/test/expected/10_admin0_test.out @@ -14,7 +14,7 @@ $$ LANGUAGE 'plpgsql'; SELECT cdb_geocode_admin0_polygon('Spain'); ERROR: Geocoding permission denied -- Grant other permissions but geocoding -SELECT CDB_Conf_SetConf('api_keys_postgres', '{"permissions": ["routing", "isolines"]}'); +SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["routing", "isolines"]}'); cdb_conf_setconf ------------------ @@ -23,7 +23,7 @@ SELECT CDB_Conf_SetConf('api_keys_postgres', '{"permissions": ["routing", "isoli SELECT cdb_geocode_admin0_polygon('Spain'); ERROR: Geocoding permission denied -- Grant geocoding permissions -SELECT CDB_Conf_SetConf('api_keys_postgres', '{"permissions": ["geocoding"]}'); +SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["geocoding"]}'); cdb_conf_setconf ------------------ diff --git a/client/test/expected/20_admin1_test.out b/client/test/expected/20_admin1_test.out index 4c1839e..006695a 100644 --- a/client/test/expected/20_admin1_test.out +++ b/client/test/expected/20_admin1_test.out @@ -23,7 +23,7 @@ ERROR: Geocoding permission denied SELECT cdb_geocode_admin1_polygon('California', 'United States'); ERROR: Geocoding permission denied -- Grant other permissions but geocoding -SELECT CDB_Conf_SetConf('api_keys_postgres', '{"permissions": ["routing", "isolines"]}'); +SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["routing", "isolines"]}'); cdb_conf_setconf ------------------ @@ -34,7 +34,7 @@ ERROR: Geocoding permission denied SELECT cdb_geocode_admin1_polygon('California', 'United States'); ERROR: Geocoding permission denied -- Grant geocoding permissions -SELECT CDB_Conf_SetConf('api_keys_postgres', '{"permissions": ["geocoding"]}'); +SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["geocoding"]}'); cdb_conf_setconf ------------------ diff --git a/client/test/expected/21_bulk_geocoding_functions_test.out b/client/test/expected/21_bulk_geocoding_functions_test.out index 16c370d..beebcab 100644 --- a/client/test/expected/21_bulk_geocoding_functions_test.out +++ b/client/test/expected/21_bulk_geocoding_functions_test.out @@ -17,7 +17,7 @@ ERROR: Geocoding permission denied SELECT cdb_dataservices_client.cdb_bulk_geocode_street_point('select 1 as cartodb_id', '''Valladolid, Spain'''); ERROR: Geocoding permission denied -- Grant other permissions but geocoding -SELECT CDB_Conf_SetConf('api_keys_postgres', '{"permissions": ["routing", "isolines"]}'); +SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["routing", "isolines"]}'); cdb_conf_setconf ------------------ @@ -30,7 +30,7 @@ ERROR: Geocoding permission denied SELECT cdb_dataservices_client.cdb_bulk_geocode_street_point('select 1 as cartodb_id', '''Valladolid, Spain'''); ERROR: Geocoding permission denied -- Grant geocoding permissions -SELECT CDB_Conf_SetConf('api_keys_postgres', '{"permissions": ["geocoding"]}'); +SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["geocoding"]}'); cdb_conf_setconf ------------------ diff --git a/client/test/expected/25_exception_safe_private_functions_test.out b/client/test/expected/25_exception_safe_private_functions_test.out index c5bcd1f..563aa50 100644 --- a/client/test/expected/25_exception_safe_private_functions_test.out +++ b/client/test/expected/25_exception_safe_private_functions_test.out @@ -38,7 +38,7 @@ SELECT * FROM _cdb_route_point_to_point_exception_safe('POINT(-3.70237112 40.417 ERROR: Routing permission denied -- No permissions granted but conf created SET ROLE postgres; -SELECT CDB_Conf_SetConf('api_keys_postgres', '{"permissions": []}'); +SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": []}'); cdb_conf_setconf ------------------ @@ -53,7 +53,7 @@ SELECT * FROM _cdb_route_point_to_point_exception_safe('POINT(-3.70237112 40.417 ERROR: Routing permission denied -- Grant geocoding permissions SET ROLE postgres; -SELECT CDB_Conf_SetConf('api_keys_postgres', '{"permissions": ["geocoding", "routing", "isolines"]}'); +SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["geocoding", "routing", "isolines"]}'); cdb_conf_setconf ------------------ diff --git a/client/test/expected/30_namedplaces_test.out b/client/test/expected/30_namedplaces_test.out index 095d4b3..bc26eb4 100644 --- a/client/test/expected/30_namedplaces_test.out +++ b/client/test/expected/30_namedplaces_test.out @@ -32,7 +32,7 @@ ERROR: Geocoding permission denied SELECT cdb_geocode_namedplace_point('Elx', 'Valencia', 'Spain'); ERROR: Geocoding permission denied -- Grant other permissions but geocoding -SELECT CDB_Conf_SetConf('api_keys_postgres', '{"permissions": ["routing", "isolines"]}'); +SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["routing", "isolines"]}'); cdb_conf_setconf ------------------ @@ -45,7 +45,7 @@ ERROR: Geocoding permission denied SELECT cdb_geocode_namedplace_point('Elx', 'Valencia', 'Spain'); ERROR: Geocoding permission denied -- Grant geocoding permissions -SELECT CDB_Conf_SetConf('api_keys_postgres', '{"permissions": ["geocoding"]}'); +SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["geocoding"]}'); cdb_conf_setconf ------------------ diff --git a/client/test/expected/40_postalcodes_test.out b/client/test/expected/40_postalcodes_test.out index e66f912..afca43a 100644 --- a/client/test/expected/40_postalcodes_test.out +++ b/client/test/expected/40_postalcodes_test.out @@ -23,7 +23,7 @@ ERROR: Geocoding permission denied SELECT cdb_geocode_postalcode_point('03204', 'Spain'); ERROR: Geocoding permission denied -- Grant other permissions but geocoding -SELECT CDB_Conf_SetConf('api_keys_postgres', '{"permissions": ["routing", "isolines"]}'); +SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["routing", "isolines"]}'); cdb_conf_setconf ------------------ @@ -34,7 +34,7 @@ ERROR: Geocoding permission denied SELECT cdb_geocode_postalcode_point('03204', 'Spain'); ERROR: Geocoding permission denied -- Grant geocoding permissions -SELECT CDB_Conf_SetConf('api_keys_postgres', '{"permissions": ["geocoding"]}'); +SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["geocoding"]}'); cdb_conf_setconf ------------------ diff --git a/client/test/expected/50_ipaddresses_test.out b/client/test/expected/50_ipaddresses_test.out index 36acf41..6ebcbbd 100644 --- a/client/test/expected/50_ipaddresses_test.out +++ b/client/test/expected/50_ipaddresses_test.out @@ -14,7 +14,7 @@ $$ LANGUAGE 'plpgsql'; SELECT cdb_geocode_ipaddress_point('8.8.8.8'); ERROR: Geocoding permission denied -- Grant other permissions but geocoding -SELECT CDB_Conf_SetConf('api_keys_postgres', '{"permissions": ["routing", "isolines"]}'); +SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["routing", "isolines"]}'); cdb_conf_setconf ------------------ @@ -23,7 +23,7 @@ SELECT CDB_Conf_SetConf('api_keys_postgres', '{"permissions": ["routing", "isoli SELECT cdb_geocode_ipaddress_point('8.8.8.8'); ERROR: Geocoding permission denied -- Grant geocoding permissions -SELECT CDB_Conf_SetConf('api_keys_postgres', '{"permissions": ["geocoding"]}'); +SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["geocoding"]}'); cdb_conf_setconf ------------------ diff --git a/client/test/expected/60_street_test.out b/client/test/expected/60_street_test.out index ce4df0b..b3d9604 100644 --- a/client/test/expected/60_street_test.out +++ b/client/test/expected/60_street_test.out @@ -32,7 +32,7 @@ ERROR: Geocoding permission denied SELECT cdb_geocode_street_point('One street', 'city', NULL, 'country'); ERROR: Geocoding permission denied -- Grant other permissions but geocoding -SELECT CDB_Conf_SetConf('api_keys_postgres', '{"permissions": ["routing", "isolines"]}'); +SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["routing", "isolines"]}'); cdb_conf_setconf ------------------ @@ -59,7 +59,7 @@ ERROR: Geocoding permission denied SELECT cdb_geocode_street_point('One street', 'city', NULL, 'country'); ERROR: Geocoding permission denied -- Grant geocoding permissions -SELECT CDB_Conf_SetConf('api_keys_postgres', '{"permissions": ["geocoding"]}'); +SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["geocoding"]}'); cdb_conf_setconf ------------------ diff --git a/client/test/expected/80_route_point_to_point_test.out b/client/test/expected/80_route_point_to_point_test.out index 762de95..c5bc94f 100644 --- a/client/test/expected/80_route_point_to_point_test.out +++ b/client/test/expected/80_route_point_to_point_test.out @@ -37,7 +37,7 @@ ERROR: Routing permission denied SELECT cdb_route_with_waypoints(Array['POINT(-87.81406 41.89308)'::geometry,'POINT(-87.80406 41.87308)'::geometry,'POINT(-87.79209 41.86138)'::geometry], 'car', ARRAY[]::text[], 'miles'); ERROR: Routing permission denied -- Grant other permissions but routing -SELECT CDB_Conf_SetConf('api_keys_postgres', '{"permissions": ["geocoding", "isolines"]}'); +SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["geocoding", "isolines"]}'); cdb_conf_setconf ------------------ @@ -56,7 +56,7 @@ ERROR: Routing permission denied SELECT cdb_route_with_waypoints(Array['POINT(-87.81406 41.89308)'::geometry,'POINT(-87.80406 41.87308)'::geometry,'POINT(-87.79209 41.86138)'::geometry], 'car', ARRAY[]::text[], 'miles'); ERROR: Routing permission denied -- Grant routing permissions -SELECT CDB_Conf_SetConf('api_keys_postgres', '{"permissions": ["routing"]}'); +SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["routing"]}'); cdb_conf_setconf ------------------ diff --git a/client/test/expected/90_data_observatory_test.out b/client/test/expected/90_data_observatory_test.out index d461dde..05b429d 100644 --- a/client/test/expected/90_data_observatory_test.out +++ b/client/test/expected/90_data_observatory_test.out @@ -202,6 +202,12 @@ BEGIN RETURN QUERY SELECT true AS valid, ARRAY[]::TEXT[] AS errors; END; $$ LANGUAGE 'plpgsql'; +SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": [""]}'); + cdb_conf_setconf +------------------ + +(1 row) + -- Exercise the public and the proxied function SELECT obs_get_demographic_snapshot(ST_SetSRID(ST_Point(-73.936669 , 40.704512), 4326), '2009 - 2013'::text, '"us.census.tiger".block_group'::text); NOTICE: cdb_dataservices_client._obs_get_demographic_snapshot(5): [contrib_regression] REMOTE NOTICE: cdb_dataservices_server.obs_get_demographic_snapshot invoked with params (test_user, , 0101000020E6100000548B8862F27B52C0DDD1FF722D5A4440, 2009 - 2013, "us.census.tiger".block_group) @@ -366,3 +372,9 @@ NOTICE: cdb_dataservices_client._obs_metadatavalidation(6): [contrib_regression (t,{}) (1 row) +SELECT CDB_Conf_RemoveConf('api_keys_postgres'); + cdb_conf_removeconf +--------------------- + +(1 row) + diff --git a/client/test/expected/95_data_observatory_tables_test.out b/client/test/expected/95_data_observatory_tables_test.out index aaf97e7..594305e 100644 --- a/client/test/expected/95_data_observatory_tables_test.out +++ b/client/test/expected/95_data_observatory_tables_test.out @@ -27,6 +27,12 @@ BEGIN RETURN true; END; $$ LANGUAGE 'plpgsql'; +SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": [""]}'); + cdb_conf_setconf +------------------ + +(1 row) + -- Create a sample user table CREATE TABLE user_table (cartodb_id int, the_geom geometry); INSERT INTO user_table(cartodb_id, the_geom) VALUES (1, '0101000020E6100000F74FC902E07D52C05FE24CC7654B4440'); @@ -63,3 +69,9 @@ SELECT * FROM my_table_dst; -- Clean tables DROP TABLE my_table_dst; +SELECT CDB_Conf_RemoveConf('api_keys_postgres'); + cdb_conf_removeconf +--------------------- + +(1 row) + diff --git a/client/test/expected/999_permissions_test.out b/client/test/expected/999_permissions_test.out index 945f1dc..7f304b1 100644 --- a/client/test/expected/999_permissions_test.out +++ b/client/test/expected/999_permissions_test.out @@ -53,7 +53,7 @@ SELECT cdb_route_point_to_point('POINT(-87.81406 41.89308)'::geometry,'POINT(-87 ERROR: Routing permission denied -- Grant other permissions but geocoding and routing SET ROLE postgres; -SELECT CDB_Conf_SetConf('api_keys_postgres', '{"permissions": ["isolines"]}'); +SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["isolines"]}'); cdb_conf_setconf ------------------ @@ -84,7 +84,7 @@ SELECT cdb_route_point_to_point('POINT(-87.81406 41.89308)'::geometry,'POINT(-87 ERROR: Routing permission denied -- Grant geocoding permissions SET ROLE postgres; -SELECT CDB_Conf_SetConf('api_keys_postgres', '{"permissions": ["geocoding", "routing"]}'); +SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["geocoding", "routing"]}'); cdb_conf_setconf ------------------ diff --git a/client/test/sql/10_admin0_test.sql b/client/test/sql/10_admin0_test.sql index 4dfc2a6..69ee0be 100644 --- a/client/test/sql/10_admin0_test.sql +++ b/client/test/sql/10_admin0_test.sql @@ -17,11 +17,11 @@ $$ LANGUAGE 'plpgsql'; SELECT cdb_geocode_admin0_polygon('Spain'); -- Grant other permissions but geocoding -SELECT CDB_Conf_SetConf('api_keys_postgres', '{"permissions": ["routing", "isolines"]}'); +SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["routing", "isolines"]}'); SELECT cdb_geocode_admin0_polygon('Spain'); -- Grant geocoding permissions -SELECT CDB_Conf_SetConf('api_keys_postgres', '{"permissions": ["geocoding"]}'); +SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["geocoding"]}'); SELECT cdb_geocode_admin0_polygon('Spain'); -- Remove permissions diff --git a/client/test/sql/20_admin1_test.sql b/client/test/sql/20_admin1_test.sql index 2f8e0f4..829546a 100644 --- a/client/test/sql/20_admin1_test.sql +++ b/client/test/sql/20_admin1_test.sql @@ -26,12 +26,12 @@ SELECT cdb_geocode_admin1_polygon('California'); SELECT cdb_geocode_admin1_polygon('California', 'United States'); -- Grant other permissions but geocoding -SELECT CDB_Conf_SetConf('api_keys_postgres', '{"permissions": ["routing", "isolines"]}'); +SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["routing", "isolines"]}'); SELECT cdb_geocode_admin1_polygon('California'); SELECT cdb_geocode_admin1_polygon('California', 'United States'); -- Grant geocoding permissions -SELECT CDB_Conf_SetConf('api_keys_postgres', '{"permissions": ["geocoding"]}'); +SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["geocoding"]}'); SELECT cdb_geocode_admin1_polygon('California'); SELECT cdb_geocode_admin1_polygon('California', 'United States'); diff --git a/client/test/sql/21_bulk_geocoding_functions_test.sql b/client/test/sql/21_bulk_geocoding_functions_test.sql index 01838b5..5b899c8 100644 --- a/client/test/sql/21_bulk_geocoding_functions_test.sql +++ b/client/test/sql/21_bulk_geocoding_functions_test.sql @@ -19,14 +19,14 @@ SELECT cdb_dataservices_client.cdb_bulk_geocode_street_point('select 1 as cartod SELECT cdb_dataservices_client.cdb_bulk_geocode_street_point('select 1 as cartodb_id', '''Valladolid, Spain'''); -- Grant other permissions but geocoding -SELECT CDB_Conf_SetConf('api_keys_postgres', '{"permissions": ["routing", "isolines"]}'); +SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["routing", "isolines"]}'); -- Test bulk size not mandatory (it will get the optimal) SELECT cdb_dataservices_client.cdb_bulk_geocode_street_point('select 1 as cartodb_id', '''Valladolid, Spain''', null, null, null, null); -- Test quota check by mocking quota 0 SELECT cdb_dataservices_client.cdb_bulk_geocode_street_point('select 1 as cartodb_id', '''Valladolid, Spain'''); -- Grant geocoding permissions -SELECT CDB_Conf_SetConf('api_keys_postgres', '{"permissions": ["geocoding"]}'); +SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["geocoding"]}'); -- Test bulk size not mandatory (it will get the optimal) SELECT cdb_dataservices_client.cdb_bulk_geocode_street_point('select 1 as cartodb_id', '''Valladolid, Spain''', null, null, null, null); -- Test quota check by mocking quota 0 diff --git a/client/test/sql/25_exception_safe_private_functions_test.sql b/client/test/sql/25_exception_safe_private_functions_test.sql index 602817e..9b4f9fd 100644 --- a/client/test/sql/25_exception_safe_private_functions_test.sql +++ b/client/test/sql/25_exception_safe_private_functions_test.sql @@ -42,7 +42,7 @@ SELECT * FROM _cdb_route_point_to_point_exception_safe('POINT(-3.70237112 40.417 -- No permissions granted but conf created SET ROLE postgres; -SELECT CDB_Conf_SetConf('api_keys_postgres', '{"permissions": []}'); +SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": []}'); SET ROLE test_regular_user; -- Use regular user role SELECT _cdb_geocode_street_point_exception_safe('One street, 1'); SELECT * FROM _cdb_isodistance_exception_safe('POINT(-3.70568 40.42028)'::geometry, 'walk', ARRAY[300]::integer[]); @@ -50,7 +50,7 @@ SELECT * FROM _cdb_route_point_to_point_exception_safe('POINT(-3.70237112 40.417 -- Grant geocoding permissions SET ROLE postgres; -SELECT CDB_Conf_SetConf('api_keys_postgres', '{"permissions": ["geocoding", "routing", "isolines"]}'); +SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["geocoding", "routing", "isolines"]}'); SET ROLE test_regular_user; -- Use regular user role SELECT _cdb_geocode_street_point_exception_safe('One street, 1'); SELECT * FROM _cdb_isodistance_exception_safe('POINT(-3.70568 40.42028)'::geometry, 'walk', ARRAY[300]::integer[]); diff --git a/client/test/sql/30_namedplaces_test.sql b/client/test/sql/30_namedplaces_test.sql index f973b94..73bbe9a 100644 --- a/client/test/sql/30_namedplaces_test.sql +++ b/client/test/sql/30_namedplaces_test.sql @@ -35,13 +35,13 @@ SELECT cdb_geocode_namedplace_point('Elx', 'Spain'); SELECT cdb_geocode_namedplace_point('Elx', 'Valencia', 'Spain'); -- Grant other permissions but geocoding -SELECT CDB_Conf_SetConf('api_keys_postgres', '{"permissions": ["routing", "isolines"]}'); +SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["routing", "isolines"]}'); SELECT cdb_geocode_namedplace_point('Elx'); SELECT cdb_geocode_namedplace_point('Elx', 'Spain'); SELECT cdb_geocode_namedplace_point('Elx', 'Valencia', 'Spain'); -- Grant geocoding permissions -SELECT CDB_Conf_SetConf('api_keys_postgres', '{"permissions": ["geocoding"]}'); +SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["geocoding"]}'); SELECT cdb_geocode_namedplace_point('Elx'); SELECT cdb_geocode_namedplace_point('Elx', 'Spain'); SELECT cdb_geocode_namedplace_point('Elx', 'Valencia', 'Spain'); diff --git a/client/test/sql/40_postalcodes_test.sql b/client/test/sql/40_postalcodes_test.sql index 707ebfa..8b2472c 100644 --- a/client/test/sql/40_postalcodes_test.sql +++ b/client/test/sql/40_postalcodes_test.sql @@ -26,12 +26,12 @@ SELECT cdb_geocode_postalcode_polygon('03204', 'Spain'); SELECT cdb_geocode_postalcode_point('03204', 'Spain'); -- Grant other permissions but geocoding -SELECT CDB_Conf_SetConf('api_keys_postgres', '{"permissions": ["routing", "isolines"]}'); +SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["routing", "isolines"]}'); SELECT cdb_geocode_postalcode_polygon('03204', 'Spain'); SELECT cdb_geocode_postalcode_point('03204', 'Spain'); -- Grant geocoding permissions -SELECT CDB_Conf_SetConf('api_keys_postgres', '{"permissions": ["geocoding"]}'); +SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["geocoding"]}'); SELECT cdb_geocode_postalcode_polygon('03204', 'Spain'); SELECT cdb_geocode_postalcode_point('03204', 'Spain'); diff --git a/client/test/sql/50_ipaddresses_test.sql b/client/test/sql/50_ipaddresses_test.sql index 36c8b96..c16de38 100644 --- a/client/test/sql/50_ipaddresses_test.sql +++ b/client/test/sql/50_ipaddresses_test.sql @@ -18,11 +18,11 @@ $$ LANGUAGE 'plpgsql'; SELECT cdb_geocode_ipaddress_point('8.8.8.8'); -- Grant other permissions but geocoding -SELECT CDB_Conf_SetConf('api_keys_postgres', '{"permissions": ["routing", "isolines"]}'); +SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["routing", "isolines"]}'); SELECT cdb_geocode_ipaddress_point('8.8.8.8'); -- Grant geocoding permissions -SELECT CDB_Conf_SetConf('api_keys_postgres', '{"permissions": ["geocoding"]}'); +SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["geocoding"]}'); SELECT cdb_geocode_ipaddress_point('8.8.8.8'); -- Remove permissions diff --git a/client/test/sql/60_street_test.sql b/client/test/sql/60_street_test.sql index e47c124..a04d1d9 100644 --- a/client/test/sql/60_street_test.sql +++ b/client/test/sql/60_street_test.sql @@ -27,7 +27,7 @@ SELECT cdb_geocode_street_point('One street', 'city', 'state', 'country'); SELECT cdb_geocode_street_point('One street', 'city', NULL, 'country'); -- Grant other permissions but geocoding -SELECT CDB_Conf_SetConf('api_keys_postgres', '{"permissions": ["routing", "isolines"]}'); +SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["routing", "isolines"]}'); SELECT cdb_geocode_street_point('One street, 1'); SELECT cdb_geocode_street_point('One street', 'city'); SELECT cdb_geocode_street_point('One street', 'city', 'state'); @@ -40,7 +40,7 @@ SELECT cdb_geocode_street_point('One street', 'city', 'state', 'country'); SELECT cdb_geocode_street_point('One street', 'city', NULL, 'country'); -- Grant geocoding permissions -SELECT CDB_Conf_SetConf('api_keys_postgres', '{"permissions": ["geocoding"]}'); +SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["geocoding"]}'); SELECT cdb_geocode_street_point('One street, 1'); SELECT cdb_geocode_street_point('One street', 'city'); SELECT cdb_geocode_street_point('One street', 'city', 'state'); diff --git a/client/test/sql/80_route_point_to_point_test.sql b/client/test/sql/80_route_point_to_point_test.sql index bff1c6d..018a148 100644 --- a/client/test/sql/80_route_point_to_point_test.sql +++ b/client/test/sql/80_route_point_to_point_test.sql @@ -39,7 +39,7 @@ SELECT cdb_route_with_waypoints(Array['POINT(-87.81406 41.89308)'::geometry,'POI SELECT cdb_route_with_waypoints(Array['POINT(-87.81406 41.89308)'::geometry,'POINT(-87.80406 41.87308)'::geometry,'POINT(-87.79209 41.86138)'::geometry], 'car', ARRAY[]::text[], 'miles'); -- Grant other permissions but routing -SELECT CDB_Conf_SetConf('api_keys_postgres', '{"permissions": ["geocoding", "isolines"]}'); +SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["geocoding", "isolines"]}'); SELECT cdb_route_point_to_point('POINT(-87.81406 41.89308)'::geometry,'POINT(-87.79209 41.86138)'::geometry, 'car'); SELECT cdb_route_point_to_point('POINT(-87.81406 41.89308)'::geometry,'POINT(-87.79209 41.86138)'::geometry, 'car', ARRAY['mode_type=shortest']::text[]); SELECT cdb_route_point_to_point('POINT(-87.81406 41.89308)'::geometry,'POINT(-87.79209 41.86138)'::geometry, 'car', ARRAY[]::text[], 'miles'); @@ -48,7 +48,7 @@ SELECT cdb_route_with_waypoints(Array['POINT(-87.81406 41.89308)'::geometry,'POI SELECT cdb_route_with_waypoints(Array['POINT(-87.81406 41.89308)'::geometry,'POINT(-87.80406 41.87308)'::geometry,'POINT(-87.79209 41.86138)'::geometry], 'car', ARRAY[]::text[], 'miles'); -- Grant routing permissions -SELECT CDB_Conf_SetConf('api_keys_postgres', '{"permissions": ["routing"]}'); +SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["routing"]}'); SELECT cdb_route_point_to_point('POINT(-87.81406 41.89308)'::geometry,'POINT(-87.79209 41.86138)'::geometry, 'car'); SELECT cdb_route_point_to_point('POINT(-87.81406 41.89308)'::geometry,'POINT(-87.79209 41.86138)'::geometry, 'car', ARRAY['mode_type=shortest']::text[]); SELECT cdb_route_point_to_point('POINT(-87.81406 41.89308)'::geometry,'POINT(-87.79209 41.86138)'::geometry, 'car', ARRAY[]::text[], 'miles'); diff --git a/client/test/sql/90_data_observatory_test.sql b/client/test/sql/90_data_observatory_test.sql index 1508ba2..ea62696 100644 --- a/client/test/sql/90_data_observatory_test.sql +++ b/client/test/sql/90_data_observatory_test.sql @@ -227,6 +227,8 @@ BEGIN END; $$ LANGUAGE 'plpgsql'; +SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": [""]}'); + -- Exercise the public and the proxied function SELECT obs_get_demographic_snapshot(ST_SetSRID(ST_Point(-73.936669 , 40.704512), 4326), '2009 - 2013'::text, '"us.census.tiger".block_group'::text); SELECT obs_get_segment_snapshot(ST_SetSRID(ST_Point(-73.936669 , 40.704512), 4326), '"us.census.tiger".block_group'::text); @@ -252,3 +254,4 @@ SELECT obs_getdata(ARRAY['36047'], obs_getmeta(st_setsrid(st_point(-73.9, 40.7), SELECT obs_getdata(ARRAY[(ST_SetSRID(ST_Point(-73.9, 40.7), 4326), 1)::geomval], obs_getmeta(st_setsrid(st_point(-73.9, 40.7), 4326), '[{"numer_id": "us.census.acs.B01003001"}]')); SELECT obs_metadatavalidation(ST_SetSRID(ST_Point(-73.9, 40.7), 4326), 'ST_Polygon', '[{"numer_id": "us.census.acs.B01003001"}]', 1000); +SELECT CDB_Conf_RemoveConf('api_keys_postgres'); diff --git a/client/test/sql/95_data_observatory_tables_test.sql b/client/test/sql/95_data_observatory_tables_test.sql index 71054ad..6cf401c 100644 --- a/client/test/sql/95_data_observatory_tables_test.sql +++ b/client/test/sql/95_data_observatory_tables_test.sql @@ -34,6 +34,8 @@ BEGIN END; $$ LANGUAGE 'plpgsql'; +SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": [""]}'); + -- Create a sample user table CREATE TABLE user_table (cartodb_id int, the_geom geometry); INSERT INTO user_table(cartodb_id, the_geom) VALUES (1, '0101000020E6100000F74FC902E07D52C05FE24CC7654B4440'); @@ -53,4 +55,6 @@ SELECT cdb_dataservices_client._DST_PopulateTableOBS_GetMeasure('user_table', 'm SELECT * FROM my_table_dst; -- Clean tables -DROP TABLE my_table_dst; \ No newline at end of file +DROP TABLE my_table_dst; + +SELECT CDB_Conf_RemoveConf('api_keys_postgres'); diff --git a/client/test/sql/999_permissions_test.sql b/client/test/sql/999_permissions_test.sql index bac1254..2dbc6c0 100644 --- a/client/test/sql/999_permissions_test.sql +++ b/client/test/sql/999_permissions_test.sql @@ -35,7 +35,7 @@ SELECT cdb_route_point_to_point('POINT(-87.81406 41.89308)'::geometry,'POINT(-87 -- Grant other permissions but geocoding and routing SET ROLE postgres; -SELECT CDB_Conf_SetConf('api_keys_postgres', '{"permissions": ["isolines"]}'); +SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["isolines"]}'); SET ROLE test_regular_user; -- Use regular user role SELECT cdb_geocode_admin0_polygon('Spain'); SELECT cdb_geocode_admin1_polygon('California'); @@ -51,7 +51,7 @@ SELECT cdb_route_point_to_point('POINT(-87.81406 41.89308)'::geometry,'POINT(-87 -- Grant geocoding permissions SET ROLE postgres; -SELECT CDB_Conf_SetConf('api_keys_postgres', '{"permissions": ["geocoding", "routing"]}'); +SELECT CDB_Conf_SetConf('api_keys_postgres', '{"username": "test_user", "permissions": ["geocoding", "routing"]}'); SET ROLE test_regular_user; -- Use regular user role SELECT cdb_geocode_admin0_polygon('Spain'); SELECT cdb_geocode_admin1_polygon('California');