Skip to content

Commit

Permalink
Remove unreachable code in twisted.conch.
Browse files Browse the repository at this point in the history
  • Loading branch information
wsanchez committed Sep 25, 2020
1 parent c3e3f6a commit 527aa89
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 56 deletions.
15 changes: 0 additions & 15 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -238,21 +238,6 @@ warn_return_any = False

# Disable warn_unreachable for some modules until we clean them up

[mypy-twisted.conch.scripts.conch]
warn_unreachable = False

[mypy-twisted.conch.telnet]
warn_unreachable = False

[mypy-twisted.conch.test.test_agent]
warn_unreachable = False

[mypy-twisted.conch.test.test_connection]
warn_unreachable = False

[mypy-twisted.conch.test.test_ssh]
warn_unreachable = False

[mypy-twisted.internet.defer]
warn_unreachable = False

Expand Down
4 changes: 0 additions & 4 deletions src/twisted/conch/scripts/conch.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,6 @@ def serviceStarted(self):
conn = self
self.localForwards = []
self.remoteForwards = {}
if not isinstance(self, connection.SSHConnection):
# make these fall through
del self.__class__.requestRemoteForwarding
del self.__class__.cancelRemoteForwarding
onConnect()

def serviceStopped(self):
Expand Down
12 changes: 6 additions & 6 deletions src/twisted/conch/telnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1015,12 +1015,12 @@ def telnet_NAWS(self, data):
linemodeSubcommands = {LINEMODE_SLC: "SLC"}

def telnet_LINEMODE(self, data):
linemodeSubcommand = data[0]
if 0:
# XXX TODO: This should be enabled to parse linemode subnegotiation.
getattr(self, "linemode_" + self.linemodeSubcommands[linemodeSubcommand])(
data[1:]
)
# linemodeSubcommand = data[0]
# # XXX TODO: This should be enabled to parse linemode subnegotiation.
# getattr(self, "linemode_" + self.linemodeSubcommands[linemodeSubcommand])(
# data[1:]
# )
pass

def linemode_SLC(self, data):
chunks = zip(*[iter(data)] * 3)
Expand Down
42 changes: 18 additions & 24 deletions src/twisted/conch/test/test_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,20 @@
from twisted.test import iosim

try:
import cryptography
import cryptography as _cryptography
except ImportError:
cryptography = None # type: ignore[assignment]
cryptography = None
else:
cryptography = _cryptography

try:
import pyasn1
import pyasn1 as _pyasn1
except ImportError:
pyasn1 = None

if cryptography and pyasn1:
from twisted.conch.ssh import keys, agent
else:
keys = agent = None # type: ignore[assignment]
pyasn1 = _pyasn1

from twisted.conch.ssh import keys, agent

from twisted.conch.test import keydata
from twisted.conch.error import ConchError, MissingKeyStoreError
Expand All @@ -44,11 +45,6 @@ class AgentTestBase(unittest.TestCase):
Tests for SSHAgentServer/Client.
"""

if iosim is None:
skip = "iosim requires SSL, but SSL is not available"
elif agent is None or keys is None:
skip = "Cannot run without cryptography or PyASN1"

def setUp(self):
# wire up our client <-> server
self.client, self.server, self.pump = iosim.connectedServerAndClient(
Expand Down Expand Up @@ -120,20 +116,18 @@ def test_agentc_REMOVE_ALL_RSA_IDENTITIES(self):
return d.addCallback(self.assertEqual, b"")


if agent is not None:

class CorruptServer(agent.SSHAgentServer):
"""
A misbehaving server that returns bogus response op codes so that we can
verify that our callbacks that deal with these op codes handle such
miscreants.
"""
class CorruptServer(agent.SSHAgentServer):
"""
A misbehaving server that returns bogus response op codes so that we can
verify that our callbacks that deal with these op codes handle such
miscreants.
"""

def agentc_REQUEST_IDENTITIES(self, data):
self.sendResponse(254, b"")
def agentc_REQUEST_IDENTITIES(self, data):
self.sendResponse(254, b"")

def agentc_SIGN_REQUEST(self, data):
self.sendResponse(254, b"")
def agentc_SIGN_REQUEST(self, data):
self.sendResponse(254, b"")


class ClientWithBrokenServerTests(AgentTestBase):
Expand Down
5 changes: 0 additions & 5 deletions src/twisted/conch/test/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,6 @@ class ConnectionTests(unittest.TestCase):

if not cryptography:
skip = "Cannot run without cryptography"
if test_userauth.transport is None:
skip = "Cannot run without both cryptography and pyasn1"

def setUp(self):
self.transport = test_userauth.FakeTransport(None)
Expand Down Expand Up @@ -830,9 +828,6 @@ class CleanConnectionShutdownTests(unittest.TestCase):
if not cryptography:
skip = "Cannot run without cryptography"

if test_userauth.transport is None:
skip = "Cannot run without both cryptography and pyasn1"

def setUp(self):
self.transport = test_userauth.FakeTransport(None)
self.transport.avatar = TestAvatar()
Expand Down
2 changes: 0 additions & 2 deletions src/twisted/conch/test/test_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,6 @@ def receiveError(self, reasonCode, desc):

def receiveUnimplemented(self, seqID):
raise unittest.FailTest("got unimplemented: seqid %s" % (seqID,))
self.expectedLoseConnection = 1
self.loseConnection()

class ConchTestServer(ConchTestBase, transport.SSHServerTransport):
def connectionLost(self, reason):
Expand Down

0 comments on commit 527aa89

Please sign in to comment.