From 7691cb0b55f5e0de8dc2ad48dd824419471ab710 Mon Sep 17 00:00:00 2001 From: Gert Driesen Date: Mon, 27 Nov 2017 22:24:55 +0100 Subject: [PATCH] Avoid leaking event subscriptions when an exception is thrown during initialization of ShellStream. Handle error situations when initializing ShellStream. --- .../Renci.SshNet.Tests.NET35.csproj | 36 ++++- ...eShellStream_ChannelOpenThrowsException.cs | 120 +++++++++++++++++ ...m_SendPseudoTerminalRequestReturnsFalse.cs | 120 +++++++++++++++++ ...endPseudoTerminalRequestThrowsException.cs | 122 +++++++++++++++++ ...hellStream_SendShellRequestReturnsFalse.cs | 123 +++++++++++++++++ ...lStream_SendShellRequestThrowsException.cs | 124 ++++++++++++++++++ ...eFactoryTest_CreateShellStream_Success.cs} | 17 ++- .../Renci.SshNet.Tests.csproj | 14 +- src/Renci.SshNet/ShellStream.cs | 25 +++- 9 files changed, 682 insertions(+), 19 deletions(-) create mode 100644 src/Renci.SshNet.Tests/Classes/ServiceFactoryTest_CreateShellStream_ChannelOpenThrowsException.cs create mode 100644 src/Renci.SshNet.Tests/Classes/ServiceFactoryTest_CreateShellStream_SendPseudoTerminalRequestReturnsFalse.cs create mode 100644 src/Renci.SshNet.Tests/Classes/ServiceFactoryTest_CreateShellStream_SendPseudoTerminalRequestThrowsException.cs create mode 100644 src/Renci.SshNet.Tests/Classes/ServiceFactoryTest_CreateShellStream_SendShellRequestReturnsFalse.cs create mode 100644 src/Renci.SshNet.Tests/Classes/ServiceFactoryTest_CreateShellStream_SendShellRequestThrowsException.cs rename src/Renci.SshNet.Tests/Classes/{ServiceFactoryTest_CreateShellStream.cs => ServiceFactoryTest_CreateShellStream_Success.cs} (90%) diff --git a/src/Renci.SshNet.Tests.NET35/Renci.SshNet.Tests.NET35.csproj b/src/Renci.SshNet.Tests.NET35/Renci.SshNet.Tests.NET35.csproj index b6ab71235..a42cf8ec1 100644 --- a/src/Renci.SshNet.Tests.NET35/Renci.SshNet.Tests.NET35.csproj +++ b/src/Renci.SshNet.Tests.NET35/Renci.SshNet.Tests.NET35.csproj @@ -105,6 +105,9 @@ Classes\Channels\ChannelForwardedTcpipTest_Dispose_SessionIsConnectedAndChannelIsOpen.cs + + Classes\Channels\ChannelSessionTestBase.cs + Classes\Channels\ChannelSessionTest_Disposed_Closed.cs @@ -159,6 +162,9 @@ Classes\Channels\ChannelStub.cs + + Classes\Channels\ChannelTestBase.cs + Classes\Channels\ChannelTest_Dispose_SessionIsConnectedAndChannelIsNotOpen.cs @@ -171,6 +177,12 @@ Classes\Channels\ChannelTest_Dispose_SessionIsConnectedAndChannelIsOpen_EofReceived.cs + + Classes\Channels\ChannelTest_Dispose_SessionIsConnectedAndChannelIsOpen_EofReceived_DisconnectWaitingForChannelCloseMessage.cs + + + Classes\Channels\ChannelTest_Dispose_SessionIsConnectedAndChannelIsOpen_EofReceived_TimeoutWaitingForChannelCloseMessage.cs + Classes\Channels\ChannelTest_Dispose_SessionIsNotConnectedAndChannelIsNotOpen.cs @@ -951,8 +963,23 @@ Classes\ServiceFactoryTest_CreateSftpFileReader_FileSizeIsZero.cs - - Classes\ServiceFactoryTest_CreateShellStream.cs + + Classes\ServiceFactoryTest_CreateShellStream_ChannelOpenThrowsException.cs + + + Classes\ServiceFactoryTest_CreateShellStream_SendPseudoTerminalRequestReturnsFalse.cs + + + Classes\ServiceFactoryTest_CreateShellStream_SendPseudoTerminalRequestThrowsException.cs + + + Classes\ServiceFactoryTest_CreateShellStream_SendShellRequestReturnsFalse.cs + + + Classes\ServiceFactoryTest_CreateShellStream_SendShellRequestThrowsException.cs + + + Classes\ServiceFactoryTest_CreateShellStream_Success.cs Classes\SessionTest.cs @@ -987,6 +1014,9 @@ Classes\SessionTest_Connected_ServerSendsDisconnectMessageAndShutsDownSocket.cs + + Classes\SessionTest_Connected_ServerSendsUnsupportedMessageType.cs + Classes\SessionTest_Connected_ServerShutsDownSendAfterSendingIncompletePacket.cs @@ -1710,7 +1740,7 @@ - +