mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2026-06-21 01:34:15 +02:00
fix auth_test
This commit is contained in:
+12
-12
@@ -11,8 +11,8 @@ skip_test = False
|
|||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import pexpect
|
from pexpect import *
|
||||||
except:
|
except ImportError:
|
||||||
skip_test = True
|
skip_test = True
|
||||||
|
|
||||||
|
|
||||||
@@ -90,7 +90,7 @@ class AuthTest(unittest.TestCase):
|
|||||||
run_pb_with_auth(self.cmd, '\0\r\n'))
|
run_pb_with_auth(self.cmd, '\0\r\n'))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
except (pexpect.TIMEOUT, pexpect.ExceptionPexpect) as e:
|
except (TIMEOUT, ExceptionPexpect) as e:
|
||||||
self.fail(e.value)
|
self.fail(e.value)
|
||||||
|
|
||||||
def test_wrong_password(self):
|
def test_wrong_password(self):
|
||||||
@@ -100,7 +100,7 @@ class AuthTest(unittest.TestCase):
|
|||||||
run_pb_with_auth(self.cmd, 'wrong_password\r\n'))
|
run_pb_with_auth(self.cmd, 'wrong_password\r\n'))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
except (pexpect.TIMEOUT, pexpect.ExceptionPexpect) as e:
|
except (TIMEOUT, ExceptionPexpect) as e:
|
||||||
self.fail(e.value)
|
self.fail(e.value)
|
||||||
|
|
||||||
def test_right_password(self):
|
def test_right_password(self):
|
||||||
@@ -110,13 +110,13 @@ class AuthTest(unittest.TestCase):
|
|||||||
run_pb_with_auth(self.cmd, 'password\r\n'))
|
run_pb_with_auth(self.cmd, 'password\r\n'))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
except (pexpect.TIMEOUT, pexpect.ExceptionPexpect) as e:
|
except (TIMEOUT, ExceptionPexpect) as e:
|
||||||
self.fail(e.value)
|
self.fail(e.value)
|
||||||
|
|
||||||
def test_ctrl_c_event(self):
|
def test_ctrl_c_event(self):
|
||||||
try:
|
try:
|
||||||
run_pb_with_auth(self.cmd, kill=True)
|
run_pb_with_auth(self.cmd, kill=True)
|
||||||
except pexpect.TIMEOUT:
|
except TIMEOUT:
|
||||||
self.fail("Error: CTRL+C event ignored")
|
self.fail("Error: CTRL+C event ignored")
|
||||||
|
|
||||||
|
|
||||||
@@ -130,7 +130,7 @@ def modify_pg_hba(node):
|
|||||||
|
|
||||||
def run_pb_with_auth(cmd, password=None, kill=False):
|
def run_pb_with_auth(cmd, password=None, kill=False):
|
||||||
try:
|
try:
|
||||||
with pexpect.spawn(" ".join(cmd), timeout=10) as probackup:
|
with spawn(" ".join(cmd), timeout=10) as probackup:
|
||||||
result = probackup.expect("Password for user .*:", 5)
|
result = probackup.expect("Password for user .*:", 5)
|
||||||
if kill:
|
if kill:
|
||||||
probackup.kill(signal.SIGINT)
|
probackup.kill(signal.SIGINT)
|
||||||
@@ -138,8 +138,8 @@ def run_pb_with_auth(cmd, password=None, kill=False):
|
|||||||
probackup.sendline(password)
|
probackup.sendline(password)
|
||||||
return probackup.readlines()
|
return probackup.readlines()
|
||||||
else:
|
else:
|
||||||
raise pexpect.TIMEOUT("")
|
raise TIMEOUT("")
|
||||||
except pexpect.TIMEOUT:
|
except TIMEOUT:
|
||||||
raise pexpect.TIMEOUT("Timeout error.")
|
raise TIMEOUT("Timeout error.")
|
||||||
except pexpect.ExceptionPexpect:
|
except ExceptionPexpect:
|
||||||
raise pexpect.ExceptionPexpect("Pexpect error.")
|
raise ExceptionPexpect("Pexpect error.")
|
||||||
|
|||||||
Reference in New Issue
Block a user