From 05bf34860df571199806e8176650237823c174a3 Mon Sep 17 00:00:00 2001 From: Vladmir Gaydamaka Date: Tue, 17 Sep 2019 13:09:51 +0300 Subject: [PATCH 1/2] Added test SFTPWrongServerTest --- tests/Functional/Net/SFTPWrongServerTest.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 tests/Functional/Net/SFTPWrongServerTest.php diff --git a/tests/Functional/Net/SFTPWrongServerTest.php b/tests/Functional/Net/SFTPWrongServerTest.php new file mode 100644 index 00000000..0a715f1e --- /dev/null +++ b/tests/Functional/Net/SFTPWrongServerTest.php @@ -0,0 +1,18 @@ +login('username', 'password'); + static::fail('The connection to the non-existent server must not succeed.'); + } catch (UnableToConnectException $e) { + static::assertSame('Cannot connect to dummy-server:22. Error 0. php_network_getaddresses: getaddrinfo failed: Name or service not known', $e->getMessage()); + } + } +} From c14557ec8bdb351cf31197738fb9527dd6f90f09 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Mon, 16 Sep 2019 23:31:46 -0500 Subject: [PATCH 2/2] SSH2: fix typo in exception --- phpseclib/Net/SSH2.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index f39e3786..f10201da 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -67,7 +67,7 @@ use phpseclib\Exception\NoSupportedAlgorithmsException; use phpseclib\Exception\UnsupportedAlgorithmException; use phpseclib\Exception\UnsupportedCurveException; use phpseclib\Exception\ConnectionClosedException; -use phpseclib\Exception\UnableToConectException; +use phpseclib\Exception\UnableToConnectException; use phpseclib\Exception\InsufficientSetupException; use phpseclib\Common\Functions\Strings; @@ -1189,7 +1189,7 @@ class SSH2 $this->fsock = @fsockopen($this->host, $this->port, $errno, $errstr, $this->curTimeout == 0 ? 100000 : $this->curTimeout); if (!$this->fsock) { $host = $this->host . ':' . $this->port; - throw new UnableToConectException(rtrim("Cannot connect to $host. Error $errno. $errstr")); + throw new UnableToConnectException(rtrim("Cannot connect to $host. Error $errno. $errstr")); } $elapsed = microtime(true) - $start; @@ -1280,7 +1280,7 @@ class SSH2 } if (version_compare($matches[3], '1.99', '<')) { - throw new UnableToConectException("Cannot connect to SSH $matches[3] servers"); + throw new UnableToConnectException("Cannot connect to SSH $matches[3] servers"); } if (!$this->send_id_string_first) {