From 34d00869e5409573b2d2cc264c14570670b1381a Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sun, 5 Mar 2023 01:57:02 -0600 Subject: [PATCH 1/2] SSH2: backport getTimeout() --- phpseclib/Net/SSH2.php | 10 ++++++++++ tests/Unit/Net/SSH2UnitTest.php | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index c1105e1a..f5a149db 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -2872,6 +2872,16 @@ class Net_SSH2 return $this->_disconnect(NET_SSH2_DISCONNECT_BY_APPLICATION); } + /** + * Return the currently configured timeout + * + * @return int + */ + function getTimeout() + { + return $this->timeout; + } + /** * Set Timeout * diff --git a/tests/Unit/Net/SSH2UnitTest.php b/tests/Unit/Net/SSH2UnitTest.php index 1c8436b9..a13923fa 100644 --- a/tests/Unit/Net/SSH2UnitTest.php +++ b/tests/Unit/Net/SSH2UnitTest.php @@ -106,6 +106,16 @@ class Unit_Net_SSH2UnitTest extends PhpseclibTestCase $this->assertFalse($ssh->isQuietModeEnabled()); } + public function testGetTimeout() + { + $ssh = new Net_SSH2('localhost'); + $this->assertEquals(10, $ssh->getTimeout()); + $ssh->setTimeout(0); + $this->assertEquals(0, $ssh->getTimeout()); + $ssh->setTimeout(20); + $this->assertEquals(20, $ssh->getTimeout()); + } + /** * @return Net_SSH2 */ From 8339322eb99240c3776c01d81158ab4da525cc01 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sun, 5 Mar 2023 04:19:20 -0600 Subject: [PATCH 2/2] Tests/SSH2: CS adjustment --- tests/Unit/Net/SSH2UnitTest.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/Unit/Net/SSH2UnitTest.php b/tests/Unit/Net/SSH2UnitTest.php index 15735add..ffe9709b 100644 --- a/tests/Unit/Net/SSH2UnitTest.php +++ b/tests/Unit/Net/SSH2UnitTest.php @@ -6,6 +6,8 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +use phpseclib\Net\SSH2; + class Unit_Net_SSH2UnitTest extends PhpseclibTestCase { public function formatLogDataProvider() @@ -112,7 +114,7 @@ class Unit_Net_SSH2UnitTest extends PhpseclibTestCase public function testGetTimeout() { - $ssh = new Net_SSH2('localhost'); + $ssh = new SSH2('localhost'); $this->assertEquals(10, $ssh->getTimeout()); $ssh->setTimeout(0); $this->assertEquals(0, $ssh->getTimeout());