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.
def create(self):

Create and return a new SSHCommandClientEndpoint to be tested. Override this to implement creation in an interesting way the endpoint.

def assertClientTransportState(self, client, immediateClose):

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.

ParametersclientThe client whose state is being checked.
immediateCloseBoolean indicating whether the connection was closed immediately or not.
def finishConnection(self):

Do any remaining work necessary to complete an in-memory connection attempted initiated using self.reactor.

def connectedServerAndClient(self, serverFactory, clientFactory):

Set up an in-memory connection between protocols created by serverFactory and clientFactory.

ReturnsA 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.
def test_channelOpenFailure(self):

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.

def test_execFailure(self):

If execution of the command fails, the Deferred returned by SSHCommandClientEndpoint.connect fires with a Failure wrapping the reason given by the server.

def test_execCancelled(self):

If execution of the command is cancelled via the Deferred returned by SSHCommandClientEndpoint.connect, the connection is closed immediately.

def test_buildProtocol(self):

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.

def test_makeConnection(self):

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.

def test_dataReceived(self):

After establishing the connection, when the command on the SSH server produces output, it is delivered to the protocol's dataReceived method.

def test_connectionLost(self):

When the command closes the channel, the protocol's connectionLost method is called.

def _exitStatusTest(self, request, requestArg):

Test handling of non-zero exit statuses or exit signals.

def test_zeroExitCode(self):

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.

def test_nonZeroExitStatus(self):

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.

def test_nonZeroExitSignal(self):

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.

def record(self, server, protocol, event, noArgs=False):

Hook into and record events which happen to protocol.

ParametersserverThe SSH server protocol over which protocol is running. (type: IProtocol provider)
protocol
event
noArgs
def test_write(self):

The transport connected to the protocol has a write method which sends bytes to the input of the command executing on the SSH server.

def test_writeSequence(self):

The transport connected to the protocol has a writeSequence method which sends bytes to the input of the command executing on the SSH server.

API Documentation for twisted, generated by pydoctor at 2020-03-25 17:34:30.