@@ -217,6 +217,7 @@ def test_db_default(self):
217217 "HOST" : "foo" ,
218218 "NAME" : "foo" ,
219219 "OPTIONS" : {
220+ "pool" : False ,
220221 "sslcert" : "foo" ,
221222 "sslkey" : "foo" ,
222223 "sslmode" : "foo" ,
@@ -267,6 +268,7 @@ def test_db_read_replicas(self):
267268 "HOST" : "foo" ,
268269 "NAME" : "foo" ,
269270 "OPTIONS" : {
271+ "pool" : False ,
270272 "sslcert" : "foo" ,
271273 "sslkey" : "foo" ,
272274 "sslmode" : "foo" ,
@@ -285,6 +287,7 @@ def test_db_read_replicas(self):
285287 "HOST" : "bar" ,
286288 "NAME" : "foo" ,
287289 "OPTIONS" : {
290+ "pool" : False ,
288291 "sslcert" : "foo" ,
289292 "sslkey" : "foo" ,
290293 "sslmode" : "foo" ,
@@ -333,6 +336,7 @@ def test_db_read_replicas_pgbouncer(self):
333336 "HOST" : "foo" ,
334337 "NAME" : "foo" ,
335338 "OPTIONS" : {
339+ "pool" : False ,
336340 "sslcert" : "foo" ,
337341 "sslkey" : "foo" ,
338342 "sslmode" : "foo" ,
@@ -351,6 +355,7 @@ def test_db_read_replicas_pgbouncer(self):
351355 "HOST" : "bar" ,
352356 "NAME" : "foo" ,
353357 "OPTIONS" : {
358+ "pool" : False ,
354359 "sslcert" : "foo" ,
355360 "sslkey" : "foo" ,
356361 "sslmode" : "foo" ,
@@ -394,6 +399,7 @@ def test_db_read_replicas_pgpool(self):
394399 "HOST" : "foo" ,
395400 "NAME" : "foo" ,
396401 "OPTIONS" : {
402+ "pool" : False ,
397403 "sslcert" : "foo" ,
398404 "sslkey" : "foo" ,
399405 "sslmode" : "foo" ,
@@ -412,6 +418,7 @@ def test_db_read_replicas_pgpool(self):
412418 "HOST" : "bar" ,
413419 "NAME" : "foo" ,
414420 "OPTIONS" : {
421+ "pool" : False ,
415422 "sslcert" : "foo" ,
416423 "sslkey" : "foo" ,
417424 "sslmode" : "foo" ,
@@ -451,6 +458,7 @@ def test_db_read_replicas_diff_ssl(self):
451458 "HOST" : "foo" ,
452459 "NAME" : "foo" ,
453460 "OPTIONS" : {
461+ "pool" : False ,
454462 "sslcert" : "foo" ,
455463 "sslkey" : "foo" ,
456464 "sslmode" : "foo" ,
@@ -469,6 +477,7 @@ def test_db_read_replicas_diff_ssl(self):
469477 "HOST" : "bar" ,
470478 "NAME" : "foo" ,
471479 "OPTIONS" : {
480+ "pool" : False ,
472481 "sslcert" : "bar" ,
473482 "sslkey" : "foo" ,
474483 "sslmode" : "foo" ,
@@ -484,3 +493,87 @@ def test_db_read_replicas_diff_ssl(self):
484493 },
485494 },
486495 )
496+
497+ def test_db_pool (self ):
498+ """Test DB Config with pool"""
499+ config = ConfigLoader ()
500+ config .set ("postgresql.host" , "foo" )
501+ config .set ("postgresql.name" , "foo" )
502+ config .set ("postgresql.user" , "foo" )
503+ config .set ("postgresql.password" , "foo" )
504+ config .set ("postgresql.port" , "foo" )
505+ config .set ("postgresql.test.name" , "foo" )
506+ config .set ("postgresql.use_pool" , True )
507+ conf = django_db_config (config )
508+ self .assertEqual (
509+ conf ,
510+ {
511+ "default" : {
512+ "ENGINE" : "authentik.root.db" ,
513+ "HOST" : "foo" ,
514+ "NAME" : "foo" ,
515+ "OPTIONS" : {
516+ "pool" : True ,
517+ "sslcert" : None ,
518+ "sslkey" : None ,
519+ "sslmode" : None ,
520+ "sslrootcert" : None ,
521+ },
522+ "PASSWORD" : "foo" ,
523+ "PORT" : "foo" ,
524+ "TEST" : {"NAME" : "foo" },
525+ "USER" : "foo" ,
526+ "CONN_MAX_AGE" : 0 ,
527+ "CONN_HEALTH_CHECKS" : False ,
528+ "DISABLE_SERVER_SIDE_CURSORS" : False ,
529+ }
530+ },
531+ )
532+
533+ def test_db_pool_options (self ):
534+ """Test DB Config with pool"""
535+ config = ConfigLoader ()
536+ config .set ("postgresql.host" , "foo" )
537+ config .set ("postgresql.name" , "foo" )
538+ config .set ("postgresql.user" , "foo" )
539+ config .set ("postgresql.password" , "foo" )
540+ config .set ("postgresql.port" , "foo" )
541+ config .set ("postgresql.test.name" , "foo" )
542+ config .set ("postgresql.use_pool" , True )
543+ config .set (
544+ "postgresql.pool_options" ,
545+ base64 .b64encode (
546+ dumps (
547+ {
548+ "max_size" : 15 ,
549+ }
550+ ).encode ()
551+ ).decode (),
552+ )
553+ conf = django_db_config (config )
554+ self .assertEqual (
555+ conf ,
556+ {
557+ "default" : {
558+ "ENGINE" : "authentik.root.db" ,
559+ "HOST" : "foo" ,
560+ "NAME" : "foo" ,
561+ "OPTIONS" : {
562+ "pool" : {
563+ "max_size" : 15 ,
564+ },
565+ "sslcert" : None ,
566+ "sslkey" : None ,
567+ "sslmode" : None ,
568+ "sslrootcert" : None ,
569+ },
570+ "PASSWORD" : "foo" ,
571+ "PORT" : "foo" ,
572+ "TEST" : {"NAME" : "foo" },
573+ "USER" : "foo" ,
574+ "CONN_MAX_AGE" : 0 ,
575+ "CONN_HEALTH_CHECKS" : False ,
576+ "DISABLE_SERVER_SIDE_CURSORS" : False ,
577+ }
578+ },
579+ )
0 commit comments