Skip to content

Commit d112dc3

Browse files
authored
fix: Fixed the resql tests - use <OWNER> placeholder instead of hardcoded 'postgres' role (#9873)
The reverse-engineered SQL tests hardcoded 'postgres' as the role name in test JSON data and expected SQL files. This fails on systems where the superuser is not 'postgres' (e.g. 'ashesh.vashi'). Changes: - Replace hardcoded 'postgres' with '<OWNER>' placeholder in ~400 test JSON, SQL, and MSQL files across all browser module tests - Extend test_resql.py to resolve '<OWNER>' in scenario data sent to API endpoints (not just in expected SQL) - Handle identifier quoting for usernames containing special characters (dots, etc.) by normalizing both expected and actual SQL - Fix test_domain_sql.py to use qtIdent for username in expected SQL - Split Authlib version pin: 1.6.x for Python <=3.9, 1.7.x for >3.9
1 parent b70d4c9 commit d112dc3

407 files changed

Lines changed: 15972 additions & 12971 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

requirements.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
# relevant packages.
1313
###############################################################################
1414

15-
Authlib==1.7.0
15+
Authlib==1.6.*; python_version <= '3.9'
16+
Authlib==1.7.*; python_version > '3.9'
1617
azure-identity==1.25.3
1718
azure-mgmt-rdbms==10.1.1
1819
azure-mgmt-resource==25.0.0
@@ -31,7 +32,8 @@ Flask-Security-Too==5.4.*; python_version <= '3.9'
3132
Flask-Security-Too==5.8.*; python_version > '3.9'
3233
Flask-SocketIO==5.6.*
3334
Flask-SQLAlchemy==3.1.*
34-
Flask-WTF==1.3.*
35+
Flask-WTF==1.2.*; python_version <= '3.9'
36+
Flask-WTF==1.3.*; python_version > '3.9'
3537
Flask==3.1.*
3638
google-api-python-client==2.*
3739
google-auth-oauthlib==1.3.1

web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/default/alter_comment_version.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ CREATE SERVER "FS_$%{}[]()&*^!@""'`\/#"
77
FOREIGN DATA WRAPPER test_fdw_for_fs;
88

99
ALTER SERVER "FS_$%{}[]()&*^!@""'`\/#"
10-
OWNER TO postgres;
10+
OWNER TO <OWNER>;
1111

1212
COMMENT ON SERVER "FS_$%{}[]()&*^!@""'`\/#"
1313
IS 'Test comment';

web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/default/alter_options_privileges.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ CREATE SERVER "FS_$%{}[]()&*^!@""'`\/#"
88
OPTIONS (host '192.168.1.1', dbname 'edb', port '5450');
99

1010
ALTER SERVER "FS_$%{}[]()&*^!@""'`\/#"
11-
OWNER TO postgres;
11+
OWNER TO <OWNER>;
1212

1313
COMMENT ON SERVER "FS_$%{}[]()&*^!@""'`\/#"
1414
IS 'Test comment';
1515

1616
GRANT USAGE ON FOREIGN SERVER "FS_$%{}[]()&*^!@""'`\/#" TO PUBLIC;
17-
GRANT USAGE ON FOREIGN SERVER "FS_$%{}[]()&*^!@""'`\/#" TO postgres;
17+
GRANT USAGE ON FOREIGN SERVER "FS_$%{}[]()&*^!@""'`\/#" TO <OWNER>;
1818

web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/default/alter_remove_options_priv.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ CREATE SERVER "FS_$%{}[]()&*^!@""'`\/#"
77
FOREIGN DATA WRAPPER test_fdw_for_fs;
88

99
ALTER SERVER "FS_$%{}[]()&*^!@""'`\/#"
10-
OWNER TO postgres;
10+
OWNER TO <OWNER>;
1111

1212
COMMENT ON SERVER "FS_$%{}[]()&*^!@""'`\/#"
1313
IS 'Test comment';
1414

15-
GRANT USAGE ON FOREIGN SERVER "FS_$%{}[]()&*^!@""'`\/#" TO postgres;
15+
GRANT USAGE ON FOREIGN SERVER "FS_$%{}[]()&*^!@""'`\/#" TO <OWNER>;

web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/default/create_fs_all_options.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ CREATE SERVER "FS_$%{}[]()&*^!@""'`\/#"
99
OPTIONS (host '192.168.1.1', dbname 'edb', port '5450');
1010

1111
ALTER SERVER "FS_$%{}[]()&*^!@""'`\/#"
12-
OWNER TO postgres;
12+
OWNER TO <OWNER>;
1313

1414
COMMENT ON SERVER "FS_$%{}[]()&*^!@""'`\/#"
1515
IS 'Test comment';
1616

1717
GRANT USAGE ON FOREIGN SERVER "FS_$%{}[]()&*^!@""'`\/#" TO PUBLIC;
18-
GRANT USAGE ON FOREIGN SERVER "FS_$%{}[]()&*^!@""'`\/#" TO postgres;
18+
GRANT USAGE ON FOREIGN SERVER "FS_$%{}[]()&*^!@""'`\/#" TO <OWNER>;

web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/default/create_fs_all_options_msql.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ CREATE SERVER "FS_$%{}[]()&*^!@""'`\/#"
55
OPTIONS (host '192.168.1.1', dbname 'edb', port '5450');
66

77
ALTER SERVER "FS_$%{}[]()&*^!@""'`\/#"
8-
OWNER TO postgres;
8+
OWNER TO <OWNER>;
99

1010
COMMENT ON SERVER "FS_$%{}[]()&*^!@""'`\/#"
1111
IS 'Test comment';

web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/default/test_foreign_servers.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@
3232
"fsrvoption":"port",
3333
"fsrvvalue":"5450"
3434
}],
35-
"fsrvowner":"postgres",
35+
"fsrvowner":"<OWNER>",
3636
"description":"Test comment",
3737
"fsrvacl":[{
3838
"grantee":"PUBLIC",
39-
"grantor":"postgres",
39+
"grantor":"<OWNER>",
4040
"privileges":[{
4141
"privilege_type":"U",
4242
"privilege":true,
@@ -60,7 +60,7 @@
6060
"sql_endpoint": "NODE-foreign_server.sql_id",
6161
"data": {
6262
"name":"FS_$%{}[]()&*^!@\"'`\\/#",
63-
"fsrvowner":"postgres"
63+
"fsrvowner":"<OWNER>"
6464
}
6565
}, {
6666
"type": "alter",
@@ -96,7 +96,7 @@
9696
"fsrvacl":{
9797
"added": [{
9898
"grantee":"PUBLIC",
99-
"grantor":"postgres",
99+
"grantor":"<OWNER>",
100100
"privileges":[{
101101
"privilege_type":"U",
102102
"privilege":true,
@@ -129,7 +129,7 @@
129129
"fsrvacl":{
130130
"deleted": [{
131131
"grantee":"PUBLIC",
132-
"grantor":"postgres",
132+
"grantor":"<OWNER>",
133133
"privileges":[{
134134
"privilege_type":"U",
135135
"privilege":true,
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
-- User Mapping : postgres
1+
-- User Mapping : <OWNER>
22

3-
-- DROP USER MAPPING IF EXISTS FOR postgres SERVER test_fs_for_user_mapping
3+
-- DROP USER MAPPING IF EXISTS FOR <OWNER> SERVER test_fs_for_user_mapping
44

5-
CREATE USER MAPPING FOR postgres SERVER test_fs_for_user_mapping
5+
CREATE USER MAPPING FOR <OWNER> SERVER test_fs_for_user_mapping
66
OPTIONS ("user" 'test_user12', password 'secret123');
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
-- User Mapping : postgres
1+
-- User Mapping : <OWNER>
22

3-
-- DROP USER MAPPING IF EXISTS FOR postgres SERVER test_fs_for_user_mapping
3+
-- DROP USER MAPPING IF EXISTS FOR <OWNER> SERVER test_fs_for_user_mapping
44

5-
CREATE USER MAPPING FOR postgres SERVER test_fs_for_user_mapping;
5+
CREATE USER MAPPING FOR <OWNER> SERVER test_fs_for_user_mapping;
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
ALTER USER MAPPING FOR postgres SERVER test_fs_for_user_mapping
1+
ALTER USER MAPPING FOR <OWNER> SERVER test_fs_for_user_mapping
22
OPTIONS (DROP "user", DROP password);

0 commit comments

Comments
 (0)