Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbd4eb3c

Browse files
committed
fix authentication for replication in pg_hba.conf
1 parenta0fa95e commitbd4eb3c

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

‎testgres/testgres.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -552,10 +552,19 @@ def default_conf(self,
552552

553553
# replication-related settings
554554
ifallow_streaming:
555+
# get auth method for host or local users
556+
defget_auth_method(t):
557+
returnnext((s.split()[-1]forsinlines
558+
ifs.startswith(t)),'trust')
559+
560+
# get auth methods
561+
auth_local=get_auth_method('local')
562+
auth_host=get_auth_method('host')
563+
555564
new_lines= [
556-
"local\treplication\tall\t\t\ttrust\n",
557-
"host\treplication\tall\t127.0.0.1/32\ttrust\n",
558-
"host\treplication\tall\t::1/128\t\ttrust\n"
565+
"local\treplication\tall\t\t\t{}\n".format(auth_local),
566+
"host\treplication\tall\t127.0.0.1/32\t{}\n".format(auth_host),
567+
"host\treplication\tall\t::1/128\t\t{}\n".format(auth_host)
559568
]
560569

561570
# write missing lines

‎tests/test_simple.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,21 @@ def test_custom_init(self):
3535
node.init(initdb_params=['-k']).start()
3636
node.safe_psql('postgres','select 1')
3737

38+
withget_new_node('test')asnode:
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+
withopen(hba_file,'r')asconf:
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'insforsinlines))
52+
3853
deftest_double_init(self):
3954
withget_new_node('test')asnode:
4055
# can't initialize node more than once

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp