Make sure only supported parameters are written to connection string (#3207)

Close #3206
This commit is contained in:
Alexander Kukushkin
2024-11-12 09:24:30 +01:00
committed by GitHub
parent e1faa38e90
commit efba02f52e
2 changed files with 27 additions and 1 deletions
+23
View File
@@ -1182,3 +1182,26 @@ class TestPostgresql2(BaseTestPostgresql):
self.assertEqual(dict(self.p.config._recovery_params),
{'primary_conninfo': {'host': 'a', 'port': '5433', 'passfile': '/blabla', 'sslmode': 'prefer',
'gssencmode': 'prefer', 'channel_binding': 'prefer', 'sslnegotiation': 'postgres'}})
def test_format_dsn(self):
params = {'host': '1', 'port': 2, 'target_session_attrs': 'read-write', 'gssencmode': 'prefer',
'channel_binding': 'prefer', 'sslpassword': 'pwd', 'sslcrldir': '/', 'sslnegotiation': 'postgres'}
self.p._major_version = 90600
self.assertEqual(self.p.config.format_dsn(params), 'host=1 port=2')
self.p._major_version = 100000
self.assertEqual(self.p.config.format_dsn(params), 'host=1 port=2 target_session_attrs=read-write')
self.p._major_version = 120000
self.assertEqual(self.p.config.format_dsn(params),
'host=1 port=2 gssencmode=prefer target_session_attrs=read-write')
self.p._major_version = 130000
self.assertEqual(self.p.config.format_dsn(params),
'host=1 port=2 sslpassword=pwd gssencmode=prefer '
'channel_binding=prefer target_session_attrs=read-write')
self.p._major_version = 140000
self.assertEqual(self.p.config.format_dsn(params),
'host=1 port=2 sslpassword=pwd sslcrldir=/ gssencmode=prefer '
'channel_binding=prefer target_session_attrs=read-write')
self.p._major_version = 170000
self.assertEqual(self.p.config.format_dsn(params),
'host=1 port=2 sslpassword=pwd sslcrldir=/ gssencmode=prefer channel_binding=prefer '
'target_session_attrs=read-write sslnegotiation=postgres')