mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-11-16 10:15:14 +00:00
Tests/SSH2: add more expansive unit test
This commit is contained in:
parent
184a984e97
commit
06f45881f9
@ -542,4 +542,21 @@ class SSH2Test extends PhpseclibFunctionalTestCase
|
|||||||
'Failed asserting that exec channel identifier is maintained as last opened channel.'
|
'Failed asserting that exec channel identifier is maintained as last opened channel.'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testReadingOfClosedChannel()
|
||||||
|
{
|
||||||
|
$ssh = $this->getSSH2Login();
|
||||||
|
$this->assertSame(0, $ssh->getOpenChannelCount());
|
||||||
|
$ssh->enablePTY();
|
||||||
|
$ssh->exec('ping -c 3 127.0.0.1; exit');
|
||||||
|
$ssh->write("ping 127.0.0.2\n", SSH2::CHANNEL_SHELL);
|
||||||
|
$ssh->setTimeout(3);
|
||||||
|
$output = $ssh->read('', SSH2::READ_SIMPLE, SSH2::CHANNEL_SHELL);
|
||||||
|
$this->assertStringContainsString('PING 127.0.0.2', $output);
|
||||||
|
$output = $ssh->read('', SSH2::READ_SIMPLE, SSH2::CHANNEL_EXEC);
|
||||||
|
$this->assertStringContainsString('PING 127.0.0.1', $output);
|
||||||
|
$this->assertSame(1, $ssh->getOpenChannelCount());
|
||||||
|
$ssh->reset(SSH2::CHANNEL_SHELL);
|
||||||
|
$this->assertSame(0, $ssh->getOpenChannelCount());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user