Skip to content

Commit

Permalink
Merge branch 'trunk' into 8267-circular-reporter
Browse files Browse the repository at this point in the history
  • Loading branch information
twm committed Jul 21, 2019
2 parents 0a6f84c + ab6156f commit 6e3c05c
Show file tree
Hide file tree
Showing 19 changed files with 1,375 additions and 1,143 deletions.
4 changes: 3 additions & 1 deletion src/twisted/conch/ssh/transport.py
Expand Up @@ -1063,7 +1063,9 @@ def _getKey(self, c, sharedSecret, exchangeHash):
k1 = hashProcessor(sharedSecret + exchangeHash + c + self.sessionID)
k1 = k1.digest()
k2 = hashProcessor(sharedSecret + exchangeHash + k1).digest()
return k1 + k2
k3 = hashProcessor(sharedSecret + exchangeHash + k1 + k2).digest()
k4 = hashProcessor(sharedSecret + exchangeHash + k1 + k2 + k3).digest()
return k1 + k2 + k3 + k4


def _keySetup(self, sharedSecret, exchangeHash):
Expand Down
5 changes: 4 additions & 1 deletion src/twisted/conch/test/test_transport.py
Expand Up @@ -1238,7 +1238,10 @@ def test_getKey(self):
k1 = self.hashProcessor(
b'AB' + b'CD' + b'K' + self.proto.sessionID).digest()
k2 = self.hashProcessor(b'ABCD' + k1).digest()
self.assertEqual(self.proto._getKey(b'K', b'AB', b'CD'), k1 + k2)
k3 = self.hashProcessor(b'ABCD' + k1 + k2).digest()
k4 = self.hashProcessor(b'ABCD' + k1 + k2 + k3).digest()
self.assertEqual(
self.proto._getKey(b'K', b'AB', b'CD'), k1 + k2 + k3 + k4)



Expand Down
2 changes: 1 addition & 1 deletion src/twisted/internet/test/_awaittests.py.3only
Expand Up @@ -15,7 +15,7 @@ from twisted.internet.defer import (
Deferred, maybeDeferred, ensureDeferred, fail
)
from twisted.trial.unittest import TestCase
from twisted.test.proto_helpers import Clock
from twisted.internet.task import Clock

class SampleException(Exception):
"""
Expand Down
2 changes: 1 addition & 1 deletion src/twisted/internet/test/_yieldfromtests.py.3only
Expand Up @@ -12,7 +12,7 @@ import types

from twisted.internet.defer import Deferred, ensureDeferred, fail
from twisted.trial.unittest import TestCase
from twisted.test.proto_helpers import Clock
from twisted.internet.task import Clock


class YieldFromTests(TestCase):
Expand Down
8 changes: 4 additions & 4 deletions src/twisted/internet/test/test_endpoints.py
Expand Up @@ -18,9 +18,9 @@
from zope.interface.verify import verifyObject, verifyClass

from twisted.trial import unittest
from twisted.test.proto_helpers import MemoryReactorClock as MemoryReactor
from twisted.test.proto_helpers import RaisingMemoryReactor, StringTransport
from twisted.test.proto_helpers import StringTransportWithDisconnection
from twisted.internet.testing import MemoryReactorClock as MemoryReactor
from twisted.internet.testing import RaisingMemoryReactor, StringTransport
from twisted.internet.testing import StringTransportWithDisconnection

from twisted import plugins
from twisted.internet import error, interfaces, defer, endpoints, protocol
Expand Down Expand Up @@ -1981,7 +1981,7 @@ def test_deprecation(self):
self.assertTrue(warnings[0]['message'].startswith(
'Passing HostnameEndpoint a reactor that does not provide'
' IReactorPluggableNameResolver'
' (twisted.test.proto_helpers.MemoryReactorClock)'
' (twisted.internet.testing.MemoryReactorClock)'
' was deprecated in Twisted 17.5.0;'
' please use a reactor that provides'
' IReactorPluggableNameResolver instead'))
Expand Down
Expand Up @@ -2,24 +2,38 @@
# See LICENSE for details.

"""
Tests for L{twisted.test.proto_helpers}.
Tests for L{twisted.internet.testing}.
"""

from zope.interface.verify import verifyObject

from twisted.internet.interfaces import (ITransport, IPushProducer, IConsumer,
IReactorTCP, IReactorSSL, IReactorUNIX, IAddress, IListeningPort,
IConnector)
from twisted.internet.interfaces import (
ITransport,
IPushProducer,
IConsumer,
IReactorTCP,
IReactorSSL,
IReactorUNIX,
IAddress,
IListeningPort,
IConnector
)
from twisted.internet.address import IPv4Address
from twisted.trial.unittest import TestCase
from twisted.test.proto_helpers import (StringTransport, MemoryReactor,
RaisingMemoryReactor, NonStreamingProducer)
from twisted.internet.testing import (
StringTransport,
MemoryReactor,
RaisingMemoryReactor,
NonStreamingProducer
)
from twisted.internet.protocol import ClientFactory, Factory
from twisted.python.reflect import namedAny



class StringTransportTests(TestCase):
"""
Tests for L{twisted.test.proto_helpers.StringTransport}.
Tests for L{twisted.internet.testing.StringTransport}.
"""
def setUp(self):
self.transport = StringTransport()
Expand Down Expand Up @@ -399,3 +413,103 @@ def test_cannotPauseProduction(self):
producer.resumeProducing()

self.assertRaises(RuntimeError, producer.pauseProducing)



class DeprecationTests(TestCase):
"""
Deprecations in L{twisted.test.proto_helpers}.
"""
def helper(self, test, obj):
new_path = 'twisted.internet.testing.{}'.format(obj.__name__)
warnings = self.flushWarnings(
[test])
self.assertEqual(DeprecationWarning, warnings[0]['category'])
self.assertEqual(1, len(warnings))
self.assertIn(new_path, warnings[0]['message'])
self.assertIs(obj, namedAny(new_path))

def test_accumulatingProtocol(self):
from twisted.test.proto_helpers import AccumulatingProtocol
self.helper(self.test_accumulatingProtocol,
AccumulatingProtocol)


def test_lineSendingProtocol(self):
from twisted.test.proto_helpers import LineSendingProtocol
self.helper(self.test_lineSendingProtocol,
LineSendingProtocol)


def test_fakeDatagramTransport(self):
from twisted.test.proto_helpers import FakeDatagramTransport
self.helper(self.test_fakeDatagramTransport,
FakeDatagramTransport)


def test_stringTransport(self):
from twisted.test.proto_helpers import StringTransport
self.helper(self.test_stringTransport,
StringTransport)


def test_stringTransportWithDisconnection(self):
from twisted.test.proto_helpers import (
StringTransportWithDisconnection)
self.helper(self.test_stringTransportWithDisconnection,
StringTransportWithDisconnection)


def test_stringIOWithoutClosing(self):
from twisted.test.proto_helpers import StringIOWithoutClosing
self.helper(self.test_stringIOWithoutClosing,
StringIOWithoutClosing)


def test__fakeConnector(self):
from twisted.test.proto_helpers import _FakeConnector
self.helper(self.test__fakeConnector,
_FakeConnector)


def test__fakePort(self):
from twisted.test.proto_helpers import _FakePort
self.helper(self.test__fakePort,
_FakePort)


def test_memoryReactor(self):
from twisted.test.proto_helpers import MemoryReactor
self.helper(self.test_memoryReactor,
MemoryReactor)


def test_memoryReactorClock(self):
from twisted.test.proto_helpers import MemoryReactorClock
self.helper(self.test_memoryReactorClock,
MemoryReactorClock)


def test_raisingMemoryReactor(self):
from twisted.test.proto_helpers import RaisingMemoryReactor
self.helper(self.test_raisingMemoryReactor,
RaisingMemoryReactor)


def test_nonStreamingProducer(self):
from twisted.test.proto_helpers import NonStreamingProducer
self.helper(self.test_nonStreamingProducer,
NonStreamingProducer)


def test_waitUntilAllDisconnected(self):
from twisted.test.proto_helpers import (
waitUntilAllDisconnected)
self.helper(self.test_waitUntilAllDisconnected,
waitUntilAllDisconnected)


def test_eventLoggingObserver(self):
from twisted.test.proto_helpers import EventLoggingObserver
self.helper(self.test_eventLoggingObserver,
EventLoggingObserver)

0 comments on commit 6e3c05c

Please sign in to comment.