mirror of
https://github.com/curl/curl.git
synced 2026-08-24 23:43:40 +03:00
pytest: add tests using sshd
With either /usr/sbin/sshd found or configured via --with-test-sshd=path add tests for SCP down- and uploads, insecure, with known hosts or not, with authorized user key or unauthorized one. Working now with libssh and libssh2, using a hashed known_hosts file. Closes #19934
This commit is contained in:
parent
407d2f3d57
commit
eb39fee40b
12 changed files with 883 additions and 3 deletions
|
|
@ -298,6 +298,35 @@ class EnvConfig:
|
|||
except Exception:
|
||||
self.danted = None
|
||||
|
||||
self.sshd = self.config['sshd']['sshd']
|
||||
if self.sshd == '':
|
||||
self.sshd = None
|
||||
self._sshd_version = None
|
||||
if self.sshd is not None:
|
||||
try:
|
||||
p = subprocess.run(args=[self.sshd, '-V'],
|
||||
capture_output=True, text=True)
|
||||
assert p.returncode == 0
|
||||
if p.returncode != 0:
|
||||
self.sshd = None
|
||||
else:
|
||||
m = re.match(r'^OpenSSH_(\d+\.\d+.*),.*', p.stderr)
|
||||
assert m, f'version: {p.stderr}'
|
||||
if m:
|
||||
self._sshd_version = m.group(1)
|
||||
else:
|
||||
self.sshd = None
|
||||
raise Exception(f'Unable to determine sshd version from: {p.stderr}')
|
||||
except Exception:
|
||||
self.sshd = None
|
||||
|
||||
if self.sshd:
|
||||
self.sftpd = self.config['sshd']['sftpd']
|
||||
if self.sftpd == '':
|
||||
self.sftpd = None
|
||||
else:
|
||||
self.sftpd = None
|
||||
|
||||
self._tcpdump = shutil.which('tcpdump')
|
||||
|
||||
@property
|
||||
|
|
@ -576,6 +605,14 @@ class Env:
|
|||
def has_danted() -> bool:
|
||||
return Env.CONFIG.danted is not None
|
||||
|
||||
@staticmethod
|
||||
def has_sshd() -> bool:
|
||||
return Env.CONFIG.sshd is not None
|
||||
|
||||
@staticmethod
|
||||
def has_sftpd() -> bool:
|
||||
return Env.has_sshd() and Env.CONFIG.sftpd is not None
|
||||
|
||||
@staticmethod
|
||||
def tcpdump() -> Optional[str]:
|
||||
return Env.CONFIG.tcpdmp
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue