@@ -264,3 +264,48 @@ def test_postgresql_database_configuration_improper_ssl_mode(
264264 password = "password" ,
265265 ssl_mode = ssl_mode ,
266266 ) # pyright: ignore[reportCallIssue]
267+
268+
269+ def test_postgresql_database_configuration_gss_encmode (subtests : SubTests ) -> None :
270+ """Test the PostgreSQLDatabaseConfiguration model."""
271+ gss_encmodes = ("disable" , "prefer" , "require" )
272+
273+ for gss_encmode in gss_encmodes :
274+ with subtests .test (msg = f"GSS encmode { gss_encmode } " ):
275+ # pylint: disable=no-member
276+ c = PostgreSQLDatabaseConfiguration (
277+ db = "db" ,
278+ user = "user" ,
279+ password = "password" ,
280+ gss_encmode = gss_encmode ,
281+ ) # pyright: ignore[reportCallIssue]
282+
283+ # most attributes are set to default values
284+ assert c is not None
285+ assert c .host == "localhost"
286+ assert c .port == 5432
287+ assert c .db == "db"
288+ assert c .user == "user"
289+ assert c .password .get_secret_value () == "password"
290+ assert c .ssl_mode == POSTGRES_DEFAULT_SSL_MODE
291+ assert c .gss_encmode == gss_encmode
292+ assert c .namespace == "public"
293+ assert c .ca_cert_path is None
294+
295+
296+ def test_postgresql_database_configuration_improper_gss_encmode (
297+ subtests : SubTests ,
298+ ) -> None :
299+ """Test the PostgreSQLDatabaseConfiguration model."""
300+ gss_encmodes = ("foo" , "bar" , "baz" , "" )
301+
302+ for gss_encmode in gss_encmodes :
303+ with subtests .test (msg = f"GSS encmode { gss_encmode } " ):
304+ with pytest .raises (ValueError , match = "Input should be 'disable'" ):
305+ # pylint: disable=no-member
306+ PostgreSQLDatabaseConfiguration (
307+ db = "db" ,
308+ user = "user" ,
309+ password = "password" ,
310+ gss_encmode = gss_encmode ,
311+ ) # pyright: ignore[reportCallIssue]
0 commit comments