30 changes: 12 additions & 18 deletions twisted/internet/tcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,18 @@
ClientMixin as _TLSClientMixin,
ServerMixin as _TLSServerMixin)
except ImportError:
try:
if _PY3:
# We're never going to port the old SSL code to Python 3:
raise
# Try to get the socket BIO based startTLS implementation, available in
# all pyOpenSSL versions
from twisted.internet._oldtls import (
ConnectionMixin as _TLSConnectionMixin,
ClientMixin as _TLSClientMixin,
ServerMixin as _TLSServerMixin)
except ImportError:
# There is no version of startTLS available
class _TLSConnectionMixin(object):
TLS = False
class _TLSClientMixin(object):
pass
class _TLSServerMixin(object):
pass
# There is no version of startTLS available
class _TLSConnectionMixin(object):
TLS = False


class _TLSClientMixin(object):
pass


class _TLSServerMixin(object):
pass


if platformType == 'win32':
# no such thing as WSAEPERM or error code 10001 according to winsock.h or MSDN
Expand Down
53 changes: 1 addition & 52 deletions twisted/internet/test/test_tls.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@

__metaclass__ = type

import sys, operator

from zope.interface import implementer

from twisted.python.compat import _PY3
from twisted.internet.test.reactormixins import ReactorBuilder
from twisted.internet.protocol import ServerFactory, ClientFactory, Protocol
from twisted.internet.interfaces import (
Expand All @@ -23,7 +20,7 @@
SSL4ServerEndpoint, SSL4ClientEndpoint, TCP4ClientEndpoint)
from twisted.internet.error import ConnectionClosed
from twisted.internet.task import Cooperator
from twisted.trial.unittest import TestCase, SkipTest
from twisted.trial.unittest import SkipTest
from twisted.python.runtime import platform

from twisted.internet.test.test_core import ObjectModelIntegrationMixin
Expand Down Expand Up @@ -388,51 +385,3 @@ def setUp(self):
raise SkipTest("OpenSSL not available.")

globals().update(AbortSSLConnectionTest.makeTestCaseClasses())

class OldTLSDeprecationTest(TestCase):
"""
Tests for the deprecation of L{twisted.internet._oldtls}, the implementation
module for L{IReactorSSL} used when only an old version of pyOpenSSL is
available.
"""
if _PY3:
skip = "_oldtls not supported on Python 3."

def test_warning(self):
"""
The use of L{twisted.internet._oldtls} is deprecated, and emits a
L{DeprecationWarning}.
"""
# Since _oldtls depends on OpenSSL, just skip this test if it isn't
# installed on the system. Faking it would be error prone.
try:
import OpenSSL
except ImportError:
raise SkipTest("OpenSSL not available.")

# Change the apparent version of OpenSSL to one support for which is
# deprecated. And have it change back again after the test.
self.patch(OpenSSL, '__version__', '0.5')

# If the module was already imported, the import statement below won't
# execute its top-level code. Take it out of sys.modules so the import
# system re-evaluates it. Arrange to put the original back afterwards.
# Also handle the case where it hasn't yet been imported.
try:
oldtls = sys.modules['twisted.internet._oldtls']
except KeyError:
self.addCleanup(sys.modules.pop, 'twisted.internet._oldtls')
else:
del sys.modules['twisted.internet._oldtls']
self.addCleanup(
operator.setitem, sys.modules, 'twisted.internet._oldtls',
oldtls)

# The actual test.
import twisted.internet._oldtls
warnings = self.flushWarnings()
self.assertEqual(warnings[0]['category'], DeprecationWarning)
self.assertEqual(
warnings[0]['message'],
"Support for pyOpenSSL 0.5 is deprecated. "
"Upgrade to pyOpenSSL 0.10 or newer.")
1 change: 1 addition & 0 deletions twisted/topfiles/5014.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Support for versions of pyOpenSSL older than 0.10 has been removed. Affected users should upgrade pyOpenSSL.