twisted.conch.test.test_endpoints.SSHCommandClientEndpointTestsMixin(object)
class documentationtwisted.conch.test.test_endpoints
(View In Hierarchy)
Known subclasses: twisted.conch.test.test_endpoints.ExistingConnectionTests, twisted.conch.test.test_endpoints.NewConnectionTests
Tests for SSHCommandClientEndpoint
,
an IStreamClientEndpoint
implementations which connects a protocol with the stdin and stdout of a
command running in an SSH session.
These tests apply to SSHCommandClientEndpoint
whether it is constructed using SSHCommandClientEndpoint.existingConnection
or SSHCommandClientEndpoint.newConnection
.
Subclasses must override create
,
assertClientTransportState
,
and finishConnection
.
Method | setUp | Undocumented |
Method | create | Create and return a new SSHCommandClientEndpoint
to be tested. Override this to implement creation in an interesting way the
endpoint. |
Method | assertClientTransportState | Make an assertion about the connectedness of the given protocol's transport. Override this to implement either a check for the connection still being open or having been closed as appropriate. |
Method | finishConnection | Do any remaining work necessary to complete an in-memory connection
attempted initiated using self.reactor . |
Method | connectedServerAndClient | Set up an in-memory connection between protocols created by
serverFactory and clientFactory . |
Method | test_channelOpenFailure | If a channel cannot be opened on the authenticated SSH connection, the
Deferred
returned by SSHCommandClientEndpoint.connect
fires with a Failure
wrapping the reason given by the server. |
Method | test_execFailure | If execution of the command fails, the Deferred
returned by SSHCommandClientEndpoint.connect
fires with a Failure
wrapping the reason given by the server. |
Method | test_execCancelled | If execution of the command is cancelled via the Deferred
returned by SSHCommandClientEndpoint.connect ,
the connection is closed immediately. |
Method | test_buildProtocol | No summary |
Method | test_makeConnection | No summary |
Method | test_dataReceived | After establishing the connection, when the command on the SSH server
produces output, it is delivered to the protocol's
dataReceived method. |
Method | test_connectionLost | When the command closes the channel, the protocol's
connectionLost method is called. |
Method | test_zeroExitCode | When the command exits with a non-zero status, the protocol's
connectionLost method is called with a Failure
wrapping an exception which encapsulates that status. |
Method | test_nonZeroExitStatus | When the command exits with a non-zero status, the protocol's
connectionLost method is called with a Failure
wrapping an exception which encapsulates that status. |
Method | test_nonZeroExitSignal | When the command exits with a non-zero signal, the protocol's
connectionLost method is called with a Failure
wrapping an exception which encapsulates that status. |
Method | record | Hook into and record events which happen to protocol . |
Method | test_write | The transport connected to the protocol has a write method
which sends bytes to the input of the command executing on the SSH
server. |
Method | test_writeSequence | The transport connected to the protocol has a writeSequence
method which sends bytes to the input of the command executing on the SSH
server. |
Method | _exitStatusTest | Test handling of non-zero exit statuses or exit signals. |
Create and return a new SSHCommandClientEndpoint
to be tested. Override this to implement creation in an interesting way the
endpoint.
Make an assertion about the connectedness of the given protocol's transport. Override this to implement either a check for the connection still being open or having been closed as appropriate.
Parameters | client | The client whose state is being checked. |
immediateClose | Boolean indicating whether the connection was closed immediately or not. |
Do any remaining work necessary to complete an in-memory connection
attempted initiated using self.reactor
.
Set up an in-memory connection between protocols created by
serverFactory
and clientFactory
.
Returns | A three-tuple. The first element is the protocol created by
serverFactory . The second element is the protocol created by
clientFactory . The third element is the IOPump
connecting them. |
If a channel cannot be opened on the authenticated SSH connection, the
Deferred
returned by SSHCommandClientEndpoint.connect
fires with a Failure
wrapping the reason given by the server.
If execution of the command fails, the Deferred
returned by SSHCommandClientEndpoint.connect
fires with a Failure
wrapping the reason given by the server.
If execution of the command is cancelled via the Deferred
returned by SSHCommandClientEndpoint.connect
,
the connection is closed immediately.
Once the necessary SSH actions have completed successfully, SSHCommandClientEndpoint.connect
uses the factory passed to it to construct a protocol instance by calling
its buildProtocol
method with an address object representing
the SSH connection and command executed.
SSHCommandClientEndpoint
establishes an SSH connection, creates a channel in it, runs a command in
that channel, and uses the protocol's makeConnection
to
associate it with a protocol representing that command's stdin and
stdout.
After establishing the connection, when the command on the SSH server
produces output, it is delivered to the protocol's
dataReceived
method.
When the command closes the channel, the protocol's
connectionLost
method is called.
Test handling of non-zero exit statuses or exit signals.
When the command exits with a non-zero status, the protocol's
connectionLost
method is called with a Failure
wrapping an exception which encapsulates that status.
When the command exits with a non-zero status, the protocol's
connectionLost
method is called with a Failure
wrapping an exception which encapsulates that status.
When the command exits with a non-zero signal, the protocol's
connectionLost
method is called with a Failure
wrapping an exception which encapsulates that status.
Additional packet contents are logged at the info
level.
Hook into and record events which happen to protocol
.
Parameters | server | The SSH server protocol over which protocol is running. (type: IProtocol
provider) |
protocol | ||
event | ||
noArgs |