File tree 2 files changed +27
-3
lines changed
2 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -552,10 +552,19 @@ def default_conf(self,
552
552
553
553
# replication-related settings
554
554
if allow_streaming :
555
+ # get auth method for host or local users
556
+ def get_auth_method (t ):
557
+ return next ((s .split ()[- 1 ] for s in lines
558
+ if s .startswith (t )), 'trust' )
559
+
560
+ # get auth methods
561
+ auth_local = get_auth_method ('local' )
562
+ auth_host = get_auth_method ('host' )
563
+
555
564
new_lines = [
556
- "local\t replication\t all\t \t \t trust \n " ,
557
- "host\t replication\t all\t 127.0.0.1/32\t trust \n " ,
558
- "host\t replication\t all\t ::1/128\t \t trust \n "
565
+ "local\t replication\t all\t \t \t {} \n " . format ( auth_local ) ,
566
+ "host\t replication\t all\t 127.0.0.1/32\t {} \n " . format ( auth_host ) ,
567
+ "host\t replication\t all\t ::1/128\t \t {} \n " . format ( auth_host )
559
568
]
560
569
561
570
# write missing lines
Original file line number Diff line number Diff line change @@ -35,6 +35,21 @@ def test_custom_init(self):
35
35
node .init (initdb_params = ['-k' ]).start ()
36
36
node .safe_psql ('postgres' , 'select 1' )
37
37
38
+ with get_new_node ('test' ) as node :
39
+ node .init (allow_streaming = True ,
40
+ initdb_params = ['--auth-local=reject' ,
41
+ '--auth-host=reject' ])
42
+
43
+ hba_file = os .path .join (node .data_dir , 'pg_hba.conf' )
44
+ with open (hba_file , 'r' ) as conf :
45
+ lines = conf .readlines ()
46
+
47
+ # check number of lines
48
+ self .assertGreaterEqual (len (lines ), 6 )
49
+
50
+ # there should be no trust entries at all
51
+ self .assertFalse (any ('trust' in s for s in lines ))
52
+
38
53
def test_double_init (self ):
39
54
with get_new_node ('test' ) as node :
40
55
# can't initialize node more than once
You can’t perform that action at this time.
0 commit comments