From 4745ad56e9f0253e8038889bc1765c213d65a47c Mon Sep 17 00:00:00 2001 From: Akshay Joshi Date: Tue, 3 Sep 2019 16:27:41 +0530 Subject: [PATCH] 1) Add Reverse Engineered and Modified SQL tests for Foreign Servers. Fixes #4617 2) Add Reverse Engineered and Modified SQL tests for User Mappings. Fixes #4627 --- docs/en_US/release_notes_4_13.rst | 2 + .../foreign_servers/sql/9.3_plus/acl.sql | 1 + .../foreign_servers/sql/9.3_plus/create.sql | 1 - .../foreign_servers/sql/default/create.sql | 2 +- .../pg/9.3_plus/alter_comment_version.sql | 13 ++ .../9.3_plus/alter_comment_version_msql.sql | 5 + .../pg/9.3_plus/alter_options_privileges.sql | 18 ++ .../alter_options_privileges_msql.sql | 4 + .../pg/9.3_plus/alter_remove_options_priv.sql | 15 ++ .../alter_remove_options_priv_msql.sql | 4 + .../pg/9.3_plus/create_fs_all_options.sql | 18 ++ .../9.3_plus/create_fs_all_options_msql.sql | 13 ++ .../pg/9.3_plus/test_foreign_servers.json | 159 ++++++++++++++++++ .../ppas/9.3_plus/alter_comment_version.sql | 13 ++ .../9.3_plus/alter_comment_version_msql.sql | 5 + .../9.3_plus/alter_options_privileges.sql | 18 ++ .../alter_options_privileges_msql.sql | 4 + .../9.3_plus/alter_remove_options_priv.sql | 15 ++ .../alter_remove_options_priv_msql.sql | 4 + .../ppas/9.3_plus/create_fs_all_options.sql | 18 ++ .../9.3_plus/create_fs_all_options_msql.sql | 13 ++ .../ppas/9.3_plus/test_foreign_servers.json | 159 ++++++++++++++++++ .../tests/pg/default/alter_options.sql | 6 + .../pg/default/alter_options_deleted.sql | 5 + .../pg/default/alter_options_deleted_msql.sql | 2 + .../tests/pg/default/alter_options_msql.sql | 2 + .../tests/pg/default/create_user_mapping.sql | 6 + .../pg/default/create_user_mapping_msql.sql | 2 + .../tests/pg/default/test_user_mappings.json | 99 +++++++++++ .../tests/ppas/default/alter_options.sql | 6 + .../ppas/default/alter_options_deleted.sql | 5 + .../default/alter_options_deleted_msql.sql | 2 + .../tests/ppas/default/alter_options_msql.sql | 2 + .../ppas/default/create_user_mapping.sql | 6 + .../ppas/default/create_user_mapping_msql.sql | 2 + .../ppas/default/test_user_mappings.json | 99 +++++++++++ .../tables/columns/tests/10_plus/test.json | 2 +- .../tables/columns/tests/12_plus/test.json | 2 +- .../tables/columns/tests/default/test.json | 2 +- .../tests/ppas/12_plus/test.json | 2 +- .../check_constraint/tests/Default/test.json | 2 +- .../tests/11_plus/test.json | 2 +- .../tests/default/test.json | 2 +- .../tables/rules/tests/default/test.json | 2 +- web/regression/re_sql/tests/test_resql.py | 44 ++++- 45 files changed, 790 insertions(+), 18 deletions(-) create mode 100644 web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/alter_comment_version.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/alter_comment_version_msql.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/alter_options_privileges.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/alter_options_privileges_msql.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/alter_remove_options_priv.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/alter_remove_options_priv_msql.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/create_fs_all_options.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/create_fs_all_options_msql.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/test_foreign_servers.json create mode 100644 web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/alter_comment_version.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/alter_comment_version_msql.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/alter_options_privileges.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/alter_options_privileges_msql.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/alter_remove_options_priv.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/alter_remove_options_priv_msql.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/create_fs_all_options.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/create_fs_all_options_msql.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/test_foreign_servers.json create mode 100644 web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/pg/default/alter_options.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/pg/default/alter_options_deleted.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/pg/default/alter_options_deleted_msql.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/pg/default/alter_options_msql.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/pg/default/create_user_mapping.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/pg/default/create_user_mapping_msql.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/pg/default/test_user_mappings.json create mode 100644 web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/ppas/default/alter_options.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/ppas/default/alter_options_deleted.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/ppas/default/alter_options_deleted_msql.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/ppas/default/alter_options_msql.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/ppas/default/create_user_mapping.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/ppas/default/create_user_mapping_msql.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/ppas/default/test_user_mappings.json diff --git a/docs/en_US/release_notes_4_13.rst b/docs/en_US/release_notes_4_13.rst index 5f3c01767..ca16616fc 100644 --- a/docs/en_US/release_notes_4_13.rst +++ b/docs/en_US/release_notes_4_13.rst @@ -20,7 +20,9 @@ Housekeeping | `Issue #4575 `_ - Add Reverse Engineered SQL tests for Schemas. | `Issue #4576 `_ - Add Reverse Engineered SQL tests for Views. | `Issue #4600 `_ - Add Reverse Engineered SQL tests for Rules. +| `Issue #4617 `_ - Add Reverse Engineered and Modified SQL tests for Foreign Servers. | `Issue #4619 `_ - Add Reverse Engineered and Modified SQL tests for FTS Templates. +| `Issue #4627 `_ - Add Reverse Engineered and Modified SQL tests for User Mappings. | `Issue #4690 `_ - Add Modified SQL tests for Resource Group. Bug fixes diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/templates/foreign_servers/sql/9.3_plus/acl.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/templates/foreign_servers/sql/9.3_plus/acl.sql index 7cf087905..ac0f9d762 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/templates/foreign_servers/sql/9.3_plus/acl.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/templates/foreign_servers/sql/9.3_plus/acl.sql @@ -19,3 +19,4 @@ FROM LEFT JOIN pg_catalog.pg_roles g ON (d.grantor = g.oid) LEFT JOIN pg_catalog.pg_roles gt ON (d.grantee = gt.oid) GROUP BY g.rolname, gt.rolname +ORDER BY grantee diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/templates/foreign_servers/sql/9.3_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/templates/foreign_servers/sql/9.3_plus/create.sql index 46efe92ed..d2e63d83d 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/templates/foreign_servers/sql/9.3_plus/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/templates/foreign_servers/sql/9.3_plus/create.sql @@ -15,7 +15,6 @@ CREATE SERVER {{ conn|qtIdent(data.name) }}{% if data.fsrvtype %} {# ============= Set the owner for foreign server ============= #} {% if data.fsrvowner %} - ALTER SERVER {{ conn|qtIdent(data.name) }} OWNER TO {{ conn|qtIdent(data.fsrvowner) }}; {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/templates/foreign_servers/sql/default/create.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/templates/foreign_servers/sql/default/create.sql index c9533f83a..1c664e971 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/templates/foreign_servers/sql/default/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/templates/foreign_servers/sql/default/create.sql @@ -31,4 +31,4 @@ COMMENT ON SERVER {{ conn|qtIdent(data.name) }} {% for priv in data.fsrvacl %} {{ PRIVILEGE.APPLY(conn, 'FOREIGN SERVER', priv.grantee, data.name, priv.without_grant, priv.with_grant) }}{% endfor %} {% endif %} -{% endif %} \ No newline at end of file +{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/alter_comment_version.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/alter_comment_version.sql new file mode 100644 index 000000000..9f8760603 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/alter_comment_version.sql @@ -0,0 +1,13 @@ +-- Foreign Server: FS_$%{}[]()&*^!@"'`\/# + +-- DROP SERVER FS_$%{}[]()&*^!@"'`\/# + +CREATE SERVER "FS_$%{}[]()&*^!@""'`\/#" + VERSION '1.1' + FOREIGN DATA WRAPPER test_fdw_for_fs; + +ALTER SERVER "FS_$%{}[]()&*^!@""'`\/#" + OWNER TO postgres; + +COMMENT ON SERVER "FS_$%{}[]()&*^!@""'`\/#" + IS 'Test comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/alter_comment_version_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/alter_comment_version_msql.sql new file mode 100644 index 000000000..bfcae0309 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/alter_comment_version_msql.sql @@ -0,0 +1,5 @@ +ALTER SERVER "FS_$%{}[]()&*^!@""'`\/#" + VERSION 1.1; + +COMMENT ON SERVER "FS_$%{}[]()&*^!@""'`\/#" + IS 'Test comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/alter_options_privileges.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/alter_options_privileges.sql new file mode 100644 index 000000000..3532f9830 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/alter_options_privileges.sql @@ -0,0 +1,18 @@ +-- Foreign Server: FS_$%{}[]()&*^!@"'`\/# + +-- DROP SERVER FS_$%{}[]()&*^!@"'`\/# + +CREATE SERVER "FS_$%{}[]()&*^!@""'`\/#" + VERSION '1.1' + FOREIGN DATA WRAPPER test_fdw_for_fs + OPTIONS (host '192.168.1.1', dbname 'edb', port '5450'); + +ALTER SERVER "FS_$%{}[]()&*^!@""'`\/#" + OWNER TO postgres; + +COMMENT ON SERVER "FS_$%{}[]()&*^!@""'`\/#" + IS 'Test comment'; + +GRANT USAGE ON FOREIGN SERVER "FS_$%{}[]()&*^!@""'`\/#" TO PUBLIC; +GRANT USAGE ON FOREIGN SERVER "FS_$%{}[]()&*^!@""'`\/#" TO postgres; + diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/alter_options_privileges_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/alter_options_privileges_msql.sql new file mode 100644 index 000000000..822cc1aef --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/alter_options_privileges_msql.sql @@ -0,0 +1,4 @@ +ALTER SERVER "FS_$%{}[]()&*^!@""'`\/#" + OPTIONS (ADD host '192.168.1.1', ADD dbname 'edb', ADD port '5450'); + +GRANT USAGE ON FOREIGN SERVER "FS_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/alter_remove_options_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/alter_remove_options_priv.sql new file mode 100644 index 000000000..6cf0a519c --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/alter_remove_options_priv.sql @@ -0,0 +1,15 @@ +-- Foreign Server: FS_$%{}[]()&*^!@"'`\/# + +-- DROP SERVER FS_$%{}[]()&*^!@"'`\/# + +CREATE SERVER "FS_$%{}[]()&*^!@""'`\/#" + VERSION '1.1' + FOREIGN DATA WRAPPER test_fdw_for_fs; + +ALTER SERVER "FS_$%{}[]()&*^!@""'`\/#" + OWNER TO postgres; + +COMMENT ON SERVER "FS_$%{}[]()&*^!@""'`\/#" + IS 'Test comment'; + +GRANT USAGE ON FOREIGN SERVER "FS_$%{}[]()&*^!@""'`\/#" TO postgres; diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/alter_remove_options_priv_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/alter_remove_options_priv_msql.sql new file mode 100644 index 000000000..4a162822f --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/alter_remove_options_priv_msql.sql @@ -0,0 +1,4 @@ +ALTER SERVER "FS_$%{}[]()&*^!@""'`\/#" + OPTIONS (DROP host, DROP dbname, DROP port); + +REVOKE ALL ON FOREIGN SERVER "FS_$%{}[]()&*^!@""'`\/#" FROM PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/create_fs_all_options.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/create_fs_all_options.sql new file mode 100644 index 000000000..b5c0c1d25 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/create_fs_all_options.sql @@ -0,0 +1,18 @@ +-- Foreign Server: FS_$%{}[]()&*^!@"'`\/# + +-- DROP SERVER FS_$%{}[]()&*^!@"'`\/# + +CREATE SERVER "FS_$%{}[]()&*^!@""'`\/#" + TYPE 'oracle' + VERSION '1.1' + FOREIGN DATA WRAPPER test_fdw_for_fs + OPTIONS (host '192.168.1.1', dbname 'edb', port '5450'); + +ALTER SERVER "FS_$%{}[]()&*^!@""'`\/#" + OWNER TO postgres; + +COMMENT ON SERVER "FS_$%{}[]()&*^!@""'`\/#" + IS 'Test comment'; + +GRANT USAGE ON FOREIGN SERVER "FS_$%{}[]()&*^!@""'`\/#" TO PUBLIC; +GRANT USAGE ON FOREIGN SERVER "FS_$%{}[]()&*^!@""'`\/#" TO postgres; diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/create_fs_all_options_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/create_fs_all_options_msql.sql new file mode 100644 index 000000000..a0e422ca0 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/create_fs_all_options_msql.sql @@ -0,0 +1,13 @@ +CREATE SERVER "FS_$%{}[]()&*^!@""'`\/#" + TYPE 'oracle' + VERSION 1.1 + FOREIGN DATA WRAPPER test_fdw_for_fs + OPTIONS (host '192.168.1.1', dbname 'edb', port '5450'); + +ALTER SERVER "FS_$%{}[]()&*^!@""'`\/#" + OWNER TO postgres; + +COMMENT ON SERVER "FS_$%{}[]()&*^!@""'`\/#" + IS 'Test comment'; + +GRANT USAGE ON FOREIGN SERVER "FS_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/test_foreign_servers.json b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/test_foreign_servers.json new file mode 100644 index 000000000..d8c0c3435 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/test_foreign_servers.json @@ -0,0 +1,159 @@ +{ + "scenarios": [ + { + "type": "create", + "name": "Create FDW for foreign server", + "endpoint": "NODE-foreign_data_wrapper.obj", + "sql_endpoint": "NODE-foreign_data_wrapper.sql_id", + "data": { + "name": "test_fdw_for_fs", + "fdwacl": [], + "fdwoptions": [] + }, + "store_object_id": "True" + }, { + "type": "create", + "name": "Create foreign server with all options", + "endpoint": "NODE-foreign_server.obj", + "sql_endpoint": "NODE-foreign_server.sql_id", + "msql_endpoint": "NODE-foreign_server.msql", + "data": { + "name":"FS_$%{}[]()&*^!@\"'`\\/#", + "fsrvtype":"oracle", + "fsrvversion":"1.1", + "fsrvoptions":[ + { + "fsrvoption":"host", + "fsrvvalue":"192.168.1.1" + },{ + "fsrvoption":"dbname", + "fsrvvalue":"edb" + },{ + "fsrvoption":"port", + "fsrvvalue":"5450" + }], + "fsrvowner":"postgres", + "description":"Test comment", + "fsrvacl":[{ + "grantee":"PUBLIC", + "grantor":"postgres", + "privileges":[{ + "privilege_type":"U", + "privilege":true, + "with_grant":false + }] + }] + }, + "expected_sql_file": "create_fs_all_options.sql", + "expected_msql_file": "create_fs_all_options_msql.sql" + }, { + "type": "delete", + "name": "Drop foreign server", + "endpoint": "NODE-foreign_server.delete_id", + "data": { + "name": "FS_$%{}[]()&*^!@\"'`\\/#" + } + }, { + "type": "create", + "name": "Create foreign server", + "endpoint": "NODE-foreign_server.obj", + "sql_endpoint": "NODE-foreign_server.sql_id", + "data": { + "name":"FS_$%{}[]()&*^!@\"'`\\/#", + "fsrvowner":"postgres" + } + }, { + "type": "alter", + "name": "Alter foreign server comment and version", + "endpoint": "NODE-foreign_server.obj_id", + "sql_endpoint": "NODE-foreign_server.sql_id", + "msql_endpoint": "NODE-foreign_server.msql_id", + "data": { + "fsrvversion":"1.1", + "description":"Test comment" + }, + "expected_sql_file": "alter_comment_version.sql", + "expected_msql_file": "alter_comment_version_msql.sql" + }, { + "type": "alter", + "name": "Alter foreign server add options and privileges", + "endpoint": "NODE-foreign_server.obj_id", + "sql_endpoint": "NODE-foreign_server.sql_id", + "msql_endpoint": "NODE-foreign_server.msql_id", + "data": { + "fsrvoptions":{ + "added": [{ + "fsrvoption":"host", + "fsrvvalue":"192.168.1.1" + },{ + "fsrvoption":"dbname", + "fsrvvalue":"edb" + },{ + "fsrvoption":"port", + "fsrvvalue":"5450" + }] + }, + "fsrvacl":{ + "added": [{ + "grantee":"PUBLIC", + "grantor":"postgres", + "privileges":[{ + "privilege_type":"U", + "privilege":true, + "with_grant":false + }] + }] + } + }, + "expected_sql_file": "alter_options_privileges.sql", + "expected_msql_file": "alter_options_privileges_msql.sql" + }, { + "type": "alter", + "name": "Alter foreign server add options and privileges", + "endpoint": "NODE-foreign_server.obj_id", + "sql_endpoint": "NODE-foreign_server.sql_id", + "msql_endpoint": "NODE-foreign_server.msql_id", + "data": { + "fsrvoptions":{ + "deleted": [{ + "fsrvoption":"host", + "fsrvvalue":"192.168.1.1" + },{ + "fsrvoption":"dbname", + "fsrvvalue":"edb" + },{ + "fsrvoption":"port", + "fsrvvalue":"5450" + }] + }, + "fsrvacl":{ + "deleted": [{ + "grantee":"PUBLIC", + "grantor":"postgres", + "privileges":[{ + "privilege_type":"U", + "privilege":true, + "with_grant":false + }] + }] + } + }, + "expected_sql_file": "alter_remove_options_priv.sql", + "expected_msql_file": "alter_remove_options_priv_msql.sql" + }, { + "type": "delete", + "name": "Drop foreign server", + "endpoint": "NODE-foreign_server.delete_id", + "data": { + "name": "FS_$%{}[]()&*^!@\"'`\\/#" + } + }, { + "type": "delete", + "name": "Drop FDW", + "endpoint": "NODE-foreign_data_wrapper.delete_id", + "data": { + "name": "test_fdw_for_fs" + } + } + ] +} diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/alter_comment_version.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/alter_comment_version.sql new file mode 100644 index 000000000..49e423d75 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/alter_comment_version.sql @@ -0,0 +1,13 @@ +-- Foreign Server: FS_$%{}[]()&*^!@"'`\/# + +-- DROP SERVER FS_$%{}[]()&*^!@"'`\/# + +CREATE SERVER "FS_$%{}[]()&*^!@""'`\/#" + VERSION '1.1' + FOREIGN DATA WRAPPER test_fdw_for_fs; + +ALTER SERVER "FS_$%{}[]()&*^!@""'`\/#" + OWNER TO enterprisedb; + +COMMENT ON SERVER "FS_$%{}[]()&*^!@""'`\/#" + IS 'Test comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/alter_comment_version_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/alter_comment_version_msql.sql new file mode 100644 index 000000000..bfcae0309 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/alter_comment_version_msql.sql @@ -0,0 +1,5 @@ +ALTER SERVER "FS_$%{}[]()&*^!@""'`\/#" + VERSION 1.1; + +COMMENT ON SERVER "FS_$%{}[]()&*^!@""'`\/#" + IS 'Test comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/alter_options_privileges.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/alter_options_privileges.sql new file mode 100644 index 000000000..4b083cfe2 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/alter_options_privileges.sql @@ -0,0 +1,18 @@ +-- Foreign Server: FS_$%{}[]()&*^!@"'`\/# + +-- DROP SERVER FS_$%{}[]()&*^!@"'`\/# + +CREATE SERVER "FS_$%{}[]()&*^!@""'`\/#" + VERSION '1.1' + FOREIGN DATA WRAPPER test_fdw_for_fs + OPTIONS (host '192.168.1.1', dbname 'edb', port '5450'); + +ALTER SERVER "FS_$%{}[]()&*^!@""'`\/#" + OWNER TO enterprisedb; + +COMMENT ON SERVER "FS_$%{}[]()&*^!@""'`\/#" + IS 'Test comment'; + +GRANT USAGE ON FOREIGN SERVER "FS_$%{}[]()&*^!@""'`\/#" TO PUBLIC; +GRANT USAGE ON FOREIGN SERVER "FS_$%{}[]()&*^!@""'`\/#" TO enterprisedb; + diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/alter_options_privileges_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/alter_options_privileges_msql.sql new file mode 100644 index 000000000..822cc1aef --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/alter_options_privileges_msql.sql @@ -0,0 +1,4 @@ +ALTER SERVER "FS_$%{}[]()&*^!@""'`\/#" + OPTIONS (ADD host '192.168.1.1', ADD dbname 'edb', ADD port '5450'); + +GRANT USAGE ON FOREIGN SERVER "FS_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/alter_remove_options_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/alter_remove_options_priv.sql new file mode 100644 index 000000000..6641687fb --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/alter_remove_options_priv.sql @@ -0,0 +1,15 @@ +-- Foreign Server: FS_$%{}[]()&*^!@"'`\/# + +-- DROP SERVER FS_$%{}[]()&*^!@"'`\/# + +CREATE SERVER "FS_$%{}[]()&*^!@""'`\/#" + VERSION '1.1' + FOREIGN DATA WRAPPER test_fdw_for_fs; + +ALTER SERVER "FS_$%{}[]()&*^!@""'`\/#" + OWNER TO enterprisedb; + +COMMENT ON SERVER "FS_$%{}[]()&*^!@""'`\/#" + IS 'Test comment'; + +GRANT USAGE ON FOREIGN SERVER "FS_$%{}[]()&*^!@""'`\/#" TO enterprisedb; diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/alter_remove_options_priv_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/alter_remove_options_priv_msql.sql new file mode 100644 index 000000000..4a162822f --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/alter_remove_options_priv_msql.sql @@ -0,0 +1,4 @@ +ALTER SERVER "FS_$%{}[]()&*^!@""'`\/#" + OPTIONS (DROP host, DROP dbname, DROP port); + +REVOKE ALL ON FOREIGN SERVER "FS_$%{}[]()&*^!@""'`\/#" FROM PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/create_fs_all_options.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/create_fs_all_options.sql new file mode 100644 index 000000000..f5f404606 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/create_fs_all_options.sql @@ -0,0 +1,18 @@ +-- Foreign Server: FS_$%{}[]()&*^!@"'`\/# + +-- DROP SERVER FS_$%{}[]()&*^!@"'`\/# + +CREATE SERVER "FS_$%{}[]()&*^!@""'`\/#" + TYPE 'oracle' + VERSION '1.1' + FOREIGN DATA WRAPPER test_fdw_for_fs + OPTIONS (host '192.168.1.1', dbname 'edb', port '5450'); + +ALTER SERVER "FS_$%{}[]()&*^!@""'`\/#" + OWNER TO enterprisedb; + +COMMENT ON SERVER "FS_$%{}[]()&*^!@""'`\/#" + IS 'Test comment'; + +GRANT USAGE ON FOREIGN SERVER "FS_$%{}[]()&*^!@""'`\/#" TO PUBLIC; +GRANT USAGE ON FOREIGN SERVER "FS_$%{}[]()&*^!@""'`\/#" TO enterprisedb; diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/create_fs_all_options_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/create_fs_all_options_msql.sql new file mode 100644 index 000000000..8f1baebe1 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/create_fs_all_options_msql.sql @@ -0,0 +1,13 @@ +CREATE SERVER "FS_$%{}[]()&*^!@""'`\/#" + TYPE 'oracle' + VERSION 1.1 + FOREIGN DATA WRAPPER test_fdw_for_fs + OPTIONS (host '192.168.1.1', dbname 'edb', port '5450'); + +ALTER SERVER "FS_$%{}[]()&*^!@""'`\/#" + OWNER TO enterprisedb; + +COMMENT ON SERVER "FS_$%{}[]()&*^!@""'`\/#" + IS 'Test comment'; + +GRANT USAGE ON FOREIGN SERVER "FS_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/test_foreign_servers.json b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/test_foreign_servers.json new file mode 100644 index 000000000..376a08fc9 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/test_foreign_servers.json @@ -0,0 +1,159 @@ +{ + "scenarios": [ + { + "type": "create", + "name": "Create FDW for foreign server", + "endpoint": "NODE-foreign_data_wrapper.obj", + "sql_endpoint": "NODE-foreign_data_wrapper.sql_id", + "data": { + "name": "test_fdw_for_fs", + "fdwacl": [], + "fdwoptions": [] + }, + "store_object_id": "True" + }, { + "type": "create", + "name": "Create foreign server with all options", + "endpoint": "NODE-foreign_server.obj", + "sql_endpoint": "NODE-foreign_server.sql_id", + "msql_endpoint": "NODE-foreign_server.msql", + "data": { + "name":"FS_$%{}[]()&*^!@\"'`\\/#", + "fsrvtype":"oracle", + "fsrvversion":"1.1", + "fsrvoptions":[ + { + "fsrvoption":"host", + "fsrvvalue":"192.168.1.1" + },{ + "fsrvoption":"dbname", + "fsrvvalue":"edb" + },{ + "fsrvoption":"port", + "fsrvvalue":"5450" + }], + "fsrvowner":"enterprisedb", + "description":"Test comment", + "fsrvacl":[{ + "grantee":"PUBLIC", + "grantor":"enterprisedb", + "privileges":[{ + "privilege_type":"U", + "privilege":true, + "with_grant":false + }] + }] + }, + "expected_sql_file": "create_fs_all_options.sql", + "expected_msql_file": "create_fs_all_options_msql.sql" + }, { + "type": "delete", + "name": "Drop foreign server", + "endpoint": "NODE-foreign_server.delete_id", + "data": { + "name": "FS_$%{}[]()&*^!@\"'`\\/#" + } + }, { + "type": "create", + "name": "Create foreign server", + "endpoint": "NODE-foreign_server.obj", + "sql_endpoint": "NODE-foreign_server.sql_id", + "data": { + "name":"FS_$%{}[]()&*^!@\"'`\\/#", + "fsrvowner":"enterprisedb" + } + }, { + "type": "alter", + "name": "Alter foreign server comment and version", + "endpoint": "NODE-foreign_server.obj_id", + "sql_endpoint": "NODE-foreign_server.sql_id", + "msql_endpoint": "NODE-foreign_server.msql_id", + "data": { + "fsrvversion":"1.1", + "description":"Test comment" + }, + "expected_sql_file": "alter_comment_version.sql", + "expected_msql_file": "alter_comment_version_msql.sql" + }, { + "type": "alter", + "name": "Alter foreign server add options and privileges", + "endpoint": "NODE-foreign_server.obj_id", + "sql_endpoint": "NODE-foreign_server.sql_id", + "msql_endpoint": "NODE-foreign_server.msql_id", + "data": { + "fsrvoptions":{ + "added": [{ + "fsrvoption":"host", + "fsrvvalue":"192.168.1.1" + },{ + "fsrvoption":"dbname", + "fsrvvalue":"edb" + },{ + "fsrvoption":"port", + "fsrvvalue":"5450" + }] + }, + "fsrvacl":{ + "added": [{ + "grantee":"PUBLIC", + "grantor":"enterprisedb", + "privileges":[{ + "privilege_type":"U", + "privilege":true, + "with_grant":false + }] + }] + } + }, + "expected_sql_file": "alter_options_privileges.sql", + "expected_msql_file": "alter_options_privileges_msql.sql" + }, { + "type": "alter", + "name": "Alter foreign server add options and privileges", + "endpoint": "NODE-foreign_server.obj_id", + "sql_endpoint": "NODE-foreign_server.sql_id", + "msql_endpoint": "NODE-foreign_server.msql_id", + "data": { + "fsrvoptions":{ + "deleted": [{ + "fsrvoption":"host", + "fsrvvalue":"192.168.1.1" + },{ + "fsrvoption":"dbname", + "fsrvvalue":"edb" + },{ + "fsrvoption":"port", + "fsrvvalue":"5450" + }] + }, + "fsrvacl":{ + "deleted": [{ + "grantee":"PUBLIC", + "grantor":"enterprisedb", + "privileges":[{ + "privilege_type":"U", + "privilege":true, + "with_grant":false + }] + }] + } + }, + "expected_sql_file": "alter_remove_options_priv.sql", + "expected_msql_file": "alter_remove_options_priv_msql.sql" + }, { + "type": "delete", + "name": "Drop foreign server", + "endpoint": "NODE-foreign_server.delete_id", + "data": { + "name": "FS_$%{}[]()&*^!@\"'`\\/#" + } + }, { + "type": "delete", + "name": "Drop FDW", + "endpoint": "NODE-foreign_data_wrapper.delete_id", + "data": { + "name": "test_fdw_for_fs" + } + } + ] +} diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/pg/default/alter_options.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/pg/default/alter_options.sql new file mode 100644 index 000000000..cd79e92bf --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/pg/default/alter_options.sql @@ -0,0 +1,6 @@ +-- User Mapping : postgres + +-- DROP USER MAPPING FOR postgres SERVER test_fs_for_user_mapping + +CREATE USER MAPPING FOR postgres SERVER test_fs_for_user_mapping + OPTIONS ("user" 'test_user12', password 'secret123'); diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/pg/default/alter_options_deleted.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/pg/default/alter_options_deleted.sql new file mode 100644 index 000000000..1fcb36852 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/pg/default/alter_options_deleted.sql @@ -0,0 +1,5 @@ +-- User Mapping : postgres + +-- DROP USER MAPPING FOR postgres SERVER test_fs_for_user_mapping + +CREATE USER MAPPING FOR postgres SERVER test_fs_for_user_mapping; diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/pg/default/alter_options_deleted_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/pg/default/alter_options_deleted_msql.sql new file mode 100644 index 000000000..dc0789560 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/pg/default/alter_options_deleted_msql.sql @@ -0,0 +1,2 @@ +ALTER USER MAPPING FOR postgres SERVER test_fs_for_user_mapping + OPTIONS (DROP "user", DROP password); diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/pg/default/alter_options_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/pg/default/alter_options_msql.sql new file mode 100644 index 000000000..6b8af0922 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/pg/default/alter_options_msql.sql @@ -0,0 +1,2 @@ +ALTER USER MAPPING FOR postgres SERVER test_fs_for_user_mapping + OPTIONS (SET "user" 'test_user12', SET password 'secret123'); diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/pg/default/create_user_mapping.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/pg/default/create_user_mapping.sql new file mode 100644 index 000000000..9ea5990ca --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/pg/default/create_user_mapping.sql @@ -0,0 +1,6 @@ +-- User Mapping : postgres + +-- DROP USER MAPPING FOR postgres SERVER test_fs_for_user_mapping + +CREATE USER MAPPING FOR postgres SERVER test_fs_for_user_mapping + OPTIONS ("user" 'test_user', password 'secret'); diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/pg/default/create_user_mapping_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/pg/default/create_user_mapping_msql.sql new file mode 100644 index 000000000..769a44e1e --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/pg/default/create_user_mapping_msql.sql @@ -0,0 +1,2 @@ +CREATE USER MAPPING FOR postgres SERVER test_fs_for_user_mapping + OPTIONS ("user" 'test_user', password 'secret'); diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/pg/default/test_user_mappings.json b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/pg/default/test_user_mappings.json new file mode 100644 index 000000000..2792d97c8 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/pg/default/test_user_mappings.json @@ -0,0 +1,99 @@ +{ + "scenarios": [ + { + "type": "create", + "name": "Create FDW for user mapping", + "endpoint": "NODE-foreign_data_wrapper.obj", + "sql_endpoint": "NODE-foreign_data_wrapper.sql_id", + "data": { + "name": "test_fdw_for_user_mapping", + "fdwacl": [], + "fdwoptions": [] + }, + "store_object_id": "True" + }, { + "type": "create", + "name": "Create foreign server for user mapping", + "endpoint": "NODE-foreign_server.obj", + "sql_endpoint": "NODE-foreign_server.sql_id", + "data": { + "name":"test_fs_for_user_mapping" + }, + "store_object_id": "True" + }, { + "type": "create", + "name": "Create User Mapping", + "endpoint": "NODE-user_mapping.obj", + "sql_endpoint": "NODE-user_mapping.sql_id", + "msql_endpoint": "NODE-user_mapping.msql", + "data": { + "name": "postgres", + "umoptions":[{ + "umoption":"user", + "umvalue":"test_user" + },{ + "umoption":"password", + "umvalue":"secret" + }] + }, + "expected_sql_file": "create_user_mapping.sql", + "expected_msql_file": "create_user_mapping_msql.sql" + }, { + "type": "alter", + "name": "Alter user mapping options", + "endpoint": "NODE-user_mapping.obj_id", + "sql_endpoint": "NODE-user_mapping.sql_id", + "msql_endpoint": "NODE-user_mapping.msql_id", + "data": { + "umoptions":{ + "changed": [{ + "umoption":"user", + "umvalue":"test_user12" + },{ + "umoption":"password", + "umvalue":"secret123" + }] + } + }, + "expected_sql_file": "alter_options.sql", + "expected_msql_file": "alter_options_msql.sql" + }, { + "type": "alter", + "name": "Alter user mapping drop options", + "endpoint": "NODE-user_mapping.obj_id", + "sql_endpoint": "NODE-user_mapping.sql_id", + "msql_endpoint": "NODE-user_mapping.msql_id", + "data": { + "umoptions":{ + "deleted": [{ + "umoption":"user", + "umvalue":"test_user12" + },{ + "umoption":"password", + "umvalue":"secret123" + }] + } + }, + "expected_sql_file": "alter_options_deleted.sql", + "expected_msql_file": "alter_options_deleted_msql.sql" + }, { + "type": "delete", + "name": "Drop user mapping", + "endpoint": "NODE-user_mapping.delete_id" + }, { + "type": "delete", + "name": "Drop foreign server", + "endpoint": "NODE-foreign_server.delete_id", + "data": { + "name": "test_fs_for_user_mapping" + } + }, { + "type": "delete", + "name": "Drop FDW", + "endpoint": "NODE-foreign_data_wrapper.delete_id", + "data": { + "name": "test_fdw_for_user_mapping" + } + } + ] +} diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/ppas/default/alter_options.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/ppas/default/alter_options.sql new file mode 100644 index 000000000..f29d51dab --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/ppas/default/alter_options.sql @@ -0,0 +1,6 @@ +-- User Mapping : enterprisedb + +-- DROP USER MAPPING FOR enterprisedb SERVER test_fs_for_user_mapping + +CREATE USER MAPPING FOR enterprisedb SERVER test_fs_for_user_mapping + OPTIONS ("user" 'test_user12', password 'secret123'); diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/ppas/default/alter_options_deleted.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/ppas/default/alter_options_deleted.sql new file mode 100644 index 000000000..a83e7fff5 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/ppas/default/alter_options_deleted.sql @@ -0,0 +1,5 @@ +-- User Mapping : enterprisedb + +-- DROP USER MAPPING FOR enterprisedb SERVER test_fs_for_user_mapping + +CREATE USER MAPPING FOR enterprisedb SERVER test_fs_for_user_mapping; diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/ppas/default/alter_options_deleted_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/ppas/default/alter_options_deleted_msql.sql new file mode 100644 index 000000000..be75be664 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/ppas/default/alter_options_deleted_msql.sql @@ -0,0 +1,2 @@ +ALTER USER MAPPING FOR enterprisedb SERVER test_fs_for_user_mapping + OPTIONS (DROP "user", DROP password); diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/ppas/default/alter_options_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/ppas/default/alter_options_msql.sql new file mode 100644 index 000000000..0ffa33aef --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/ppas/default/alter_options_msql.sql @@ -0,0 +1,2 @@ +ALTER USER MAPPING FOR enterprisedb SERVER test_fs_for_user_mapping + OPTIONS (SET "user" 'test_user12', SET password 'secret123'); diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/ppas/default/create_user_mapping.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/ppas/default/create_user_mapping.sql new file mode 100644 index 000000000..16adddebf --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/ppas/default/create_user_mapping.sql @@ -0,0 +1,6 @@ +-- User Mapping : enterprisedb + +-- DROP USER MAPPING FOR enterprisedb SERVER test_fs_for_user_mapping + +CREATE USER MAPPING FOR enterprisedb SERVER test_fs_for_user_mapping + OPTIONS ("user" 'test_user', password 'secret'); diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/ppas/default/create_user_mapping_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/ppas/default/create_user_mapping_msql.sql new file mode 100644 index 000000000..348ec5a4c --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/ppas/default/create_user_mapping_msql.sql @@ -0,0 +1,2 @@ +CREATE USER MAPPING FOR enterprisedb SERVER test_fs_for_user_mapping + OPTIONS ("user" 'test_user', password 'secret'); diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/ppas/default/test_user_mappings.json b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/ppas/default/test_user_mappings.json new file mode 100644 index 000000000..f957c81b2 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/tests/ppas/default/test_user_mappings.json @@ -0,0 +1,99 @@ +{ + "scenarios": [ + { + "type": "create", + "name": "Create FDW for user mapping", + "endpoint": "NODE-foreign_data_wrapper.obj", + "sql_endpoint": "NODE-foreign_data_wrapper.sql_id", + "data": { + "name": "test_fdw_for_user_mapping", + "fdwacl": [], + "fdwoptions": [] + }, + "store_object_id": "True" + }, { + "type": "create", + "name": "Create foreign server for user mapping", + "endpoint": "NODE-foreign_server.obj", + "sql_endpoint": "NODE-foreign_server.sql_id", + "data": { + "name":"test_fs_for_user_mapping" + }, + "store_object_id": "True" + }, { + "type": "create", + "name": "Create User Mapping", + "endpoint": "NODE-user_mapping.obj", + "sql_endpoint": "NODE-user_mapping.sql_id", + "msql_endpoint": "NODE-user_mapping.msql", + "data": { + "name": "enterprisedb", + "umoptions":[{ + "umoption":"user", + "umvalue":"test_user" + },{ + "umoption":"password", + "umvalue":"secret" + }] + }, + "expected_sql_file": "create_user_mapping.sql", + "expected_msql_file": "create_user_mapping_msql.sql" + }, { + "type": "alter", + "name": "Alter user mapping options", + "endpoint": "NODE-user_mapping.obj_id", + "sql_endpoint": "NODE-user_mapping.sql_id", + "msql_endpoint": "NODE-user_mapping.msql_id", + "data": { + "umoptions":{ + "changed": [{ + "umoption":"user", + "umvalue":"test_user12" + },{ + "umoption":"password", + "umvalue":"secret123" + }] + } + }, + "expected_sql_file": "alter_options.sql", + "expected_msql_file": "alter_options_msql.sql" + }, { + "type": "alter", + "name": "Alter user mapping drop options", + "endpoint": "NODE-user_mapping.obj_id", + "sql_endpoint": "NODE-user_mapping.sql_id", + "msql_endpoint": "NODE-user_mapping.msql_id", + "data": { + "umoptions":{ + "deleted": [{ + "umoption":"user", + "umvalue":"test_user12" + },{ + "umoption":"password", + "umvalue":"secret123" + }] + } + }, + "expected_sql_file": "alter_options_deleted.sql", + "expected_msql_file": "alter_options_deleted_msql.sql" + }, { + "type": "delete", + "name": "Drop user mapping", + "endpoint": "NODE-user_mapping.delete_id" + }, { + "type": "delete", + "name": "Drop foreign server", + "endpoint": "NODE-foreign_server.delete_id", + "data": { + "name": "test_fs_for_user_mapping" + } + }, { + "type": "delete", + "name": "Drop FDW", + "endpoint": "NODE-foreign_data_wrapper.delete_id", + "data": { + "name": "test_fdw_for_user_mapping" + } + } + ] +} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/test.json index 5596ec178..09844ec97 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/test.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/test.json @@ -11,7 +11,7 @@ "columns": [], "schema": "testschema" }, - "store_table_id": true + "store_object_id": true }, { "type": "create", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/test.json index 9a52b7e8a..1d515ca4c 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/test.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/test.json @@ -11,7 +11,7 @@ "columns": [], "schema": "testschema" }, - "store_table_id": true + "store_object_id": true }, { "type": "create", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/test.json index 59555d2bd..8d0e4d05c 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/test.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/test.json @@ -11,7 +11,7 @@ "columns": [], "schema": "testschema" }, - "store_table_id": true + "store_object_id": true }, { "type": "create", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/compound_triggers/tests/ppas/12_plus/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/compound_triggers/tests/ppas/12_plus/test.json index e33be7670..7e3717265 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/compound_triggers/tests/ppas/12_plus/test.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/compound_triggers/tests/ppas/12_plus/test.json @@ -19,7 +19,7 @@ "schema": "testschema", "spcname": "pg_default" }, - "store_table_id": true + "store_object_id": true }, { "type": "create", "name": "Create compound trigger for insert or delete", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/tests/Default/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/tests/Default/test.json index a5fb36716..9f99ba790 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/tests/Default/test.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/tests/Default/test.json @@ -16,7 +16,7 @@ "schema": "testschema", "spcname": "pg_default" }, - "store_table_id": true + "store_object_id": true }, { "type": "create", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/tests/11_plus/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/tests/11_plus/test.json index 11d14487d..2fd6a71c2 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/tests/11_plus/test.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/tests/11_plus/test.json @@ -19,7 +19,7 @@ "schema": "testschema", "spcname": "pg_default" }, - "store_table_id": true + "store_object_id": true }, { "type": "create", "name": "Create Extension", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/tests/default/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/tests/default/test.json index 8cb5567e7..f8a137030 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/tests/default/test.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/tests/default/test.json @@ -19,7 +19,7 @@ "schema": "testschema", "spcname": "pg_default" }, - "store_table_id": true + "store_object_id": true }, { "type": "create", "name": "Create Extension", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/tests/default/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/tests/default/test.json index 6f7dfb40d..a618a248a 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/tests/default/test.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/tests/default/test.json @@ -22,7 +22,7 @@ "schema": "public", "spcname": "pg_default" }, - "store_table_id": true + "store_object_id": true }, { "type": "create", "name": "Create Rule for insert event", diff --git a/web/regression/re_sql/tests/test_resql.py b/web/regression/re_sql/tests/test_resql.py index fc8939907..9b21d31d6 100644 --- a/web/regression/re_sql/tests/test_resql.py +++ b/web/regression/re_sql/tests/test_resql.py @@ -79,6 +79,7 @@ class ReverseEngineeredSQLTestCases(BaseTestGenerator): self.apppath = os.getcwd() # Status of the test case self.final_test_status = True + self.parent_ids = dict() # Added line break after scenario name print("") @@ -99,7 +100,6 @@ class ReverseEngineeredSQLTestCases(BaseTestGenerator): getattr(BaseTestGenerator, 'for_modules', [])) for module in resql_module_list: - self.table_id = None module_path = resql_module_list[module] # Get the folder name based on server version number and # their existence. @@ -126,6 +126,9 @@ class ReverseEngineeredSQLTestCases(BaseTestGenerator): for key, scenarios in data.items(): self.execute_test_case(scenarios) + # Clear the parent ids stored for one json file. + self.parent_ids.clear() + # Check the final status of the test case self.assertEqual(self.final_test_status, True) @@ -174,8 +177,15 @@ class ReverseEngineeredSQLTestCases(BaseTestGenerator): options['scid'] = int(object_id) else: options['scid'] = int(self.schema_id) - elif arg == 'tid' and self.table_id: - options['tid'] = int(self.table_id) + # tid represents table oid + elif arg == 'tid' and 'tid' in self.parent_ids: + options['tid'] = int(self.parent_ids['tid']) + # fid represents FDW oid + elif arg == 'fid' and 'fid' in self.parent_ids: + options['fid'] = int(self.parent_ids['fid']) + # fsid represents Foreign Server oid + elif arg == 'fsid' and 'fsid' in self.parent_ids: + options['fsid'] = int(self.parent_ids['fsid']) else: if object_id is not None: options[arg] = int(object_id) @@ -236,9 +246,9 @@ class ReverseEngineeredSQLTestCases(BaseTestGenerator): resp_data = json.loads(response.data.decode('utf8')) object_id = resp_data['node']['_id'] - # Table child nodes require table id - if 'store_table_id' in scenario: - self.table_id = object_id + # Store the object id based on endpoints + if 'store_object_id' in scenario: + self.store_object_ids(object_id, scenario['endpoint']) # Compare the reverse engineering SQL if not self.check_re_sql(scenario, object_id): @@ -370,7 +380,9 @@ class ReverseEngineeredSQLTestCases(BaseTestGenerator): # Remove first and last double quotes if resp_sql.startswith('"') and resp_sql.endswith('"'): resp_sql = resp_sql[1:-1] - resp_sql = resp_sql.rstrip() + + # Remove triling \n + resp_sql = resp_sql.rstrip() # Check if expected sql is given in JSON file or path of the output # file is given @@ -429,7 +441,9 @@ class ReverseEngineeredSQLTestCases(BaseTestGenerator): # Remove first and last double quotes if resp_sql.startswith('"') and resp_sql.endswith('"'): resp_sql = resp_sql[1:-1] - resp_sql = resp_sql.rstrip() + + # Remove triling \n + resp_sql = resp_sql.rstrip() # Check if expected sql is given in JSON file or path of the output # file is given @@ -562,3 +576,17 @@ class ReverseEngineeredSQLTestCases(BaseTestGenerator): pg_cursor.close() return sql + + def store_object_ids(self, object_id, endpoint): + """ + This functions will store the object id based on endpoints + :param object_id: Object id of the created node + :param endpoint: + :return: + """ + if endpoint.__contains__("NODE-table"): + self.parent_ids['tid'] = object_id + elif endpoint.__contains__("NODE-foreign_data_wrapper"): + self.parent_ids['fid'] = object_id + elif endpoint.__contains__("NODE-foreign_server"): + self.parent_ids['fsid'] = object_id