1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2025-04-08 16:54:08 +02:00

fix auth_test

This commit is contained in:
sfalkon 2017-12-05 20:45:44 +03:00
parent 3f650ed2f1
commit 942b2df4a9
2 changed files with 10 additions and 7 deletions

View File

@ -83,6 +83,11 @@ class AuthTest(unittest.TestCase):
'-U', 'backup',
'-b', 'FULL'
]
self.pgpass_file = os.path.join(os.path.expanduser('~'), '.pgpass')
try:
os.remove(self.pgpass_file)
except FileNotFoundError:
pass
def tearDown(self):
pass
@ -142,9 +147,8 @@ class AuthTest(unittest.TestCase):
self.fail(e)
def test_pgpass(self):
path = os.path.join(os.path.expanduser('~'), '.pgpass')
line = ":".join(['127.0.0.1', str(self.node.port), 'postgres', 'backup', 'password'])
create_pgpass(path, line)
create_pgpass(self.pgpass_file, line)
try:
self.assertEqual(
"OK",
@ -155,9 +159,8 @@ class AuthTest(unittest.TestCase):
self.fail(e)
def test_pgpassword(self):
path = os.path.join(os.path.expanduser('~'), '.pgpass')
line = ":".join(['127.0.0.1', str(self.node.port), 'postgres', 'backup', 'wrong_password'])
create_pgpass(path, line)
create_pgpass(self.pgpass_file, line)
os.environ["PGPASSWORD"] = 'password'
try:
self.assertEqual(
@ -201,7 +204,7 @@ def modify_pg_hba(node):
def create_pgpass(path, line):
with open(path, 'w+') as passfile:
with open(path, 'w') as passfile:
# host:port:db:username:password
passfile.write(line)
os.chmod(path, 0600)
os.chmod(path, 0o600)

View File

@ -3,7 +3,7 @@ import unittest
from .helpers.ptrack_helpers import ProbackupTest, ProbackupException
from datetime import datetime, timedelta
import subprocess
from testgres import ClusterException
from testgres import ClusterTestgresException as ClusterException
import shutil, sys, time