Changeset 83:255aae0cf8c5 in ralphm-patches


Ignore:
Timestamp:
Sep 21, 2016, 10:32:11 PM (2 years ago)
Author:
Ralph Meijer <ralphm@…>
Branch:
default
Parents:
82:276bc45eb40b (diff), 74:355afce3af27 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Tags:
tip
Message:

Merge in changes for Component to match changes to StreamManager?.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • server-stream-manager.patch

    r74 r83  
    11# HG changeset patch
    2 # Parent 71082c22f73200a0b8b4b5c6e5d2773f9f68dd4d
     2# Parent 3f3fe954b1975c2d9115e0fa8177ae7b28a708a8
    33Generalize StreamManager and add ServerStreamManager.
    44
     
    5656--- a/wokkel/subprotocols.py
    5757+++ b/wokkel/subprotocols.py
    58 @@ -120,7 +120,7 @@
     58@@ -118,7 +118,7 @@
    5959 
    6060 
     
    6565     Business logic representing a managed XMPP connection.
    6666 
    67 @@ -131,43 +131,39 @@
     67@@ -129,43 +129,39 @@
    6868 
    6969     @ivar xmlstream: currently managed XML stream
     
    116116             from twisted.internet import reactor
    117117         self._reactor = reactor
    118 @@ -193,7 +189,7 @@
     118@@ -191,7 +187,7 @@
    119119             handler.connectionInitialized()
    120120 
     
    125125         Called when the transport connection has been established.
    126126 
    127 @@ -211,13 +207,17 @@
     127@@ -209,13 +205,17 @@
    128128             xs.rawDataInFn = logDataIn
    129129             xs.rawDataOutFn = logDataOut
     
    144144         Called when the stream has been initialized.
    145145 
    146 @@ -240,21 +240,8 @@
     146@@ -238,21 +238,8 @@
    147147             e.connectionInitialized()
    148148 
     
    167167         Called when the stream has been closed.
    168168 
    169 @@ -464,6 +451,60 @@
     169@@ -379,6 +366,60 @@
    170170 
    171171 
     
    298298--- a/wokkel/test/test_subprotocols.py
    299299+++ b/wokkel/test/test_subprotocols.py
    300 @@ -189,20 +189,7 @@
     300@@ -189,22 +189,7 @@
    301301 
    302302 
     
    315315-        self.xmlstream.transport = self.transport
    316316-
    317 -        self.request = IQGetStanza()
     317-        self.request = IQGetStanza(recipient=JID('other@example.org'),
     318-                                   sender=JID('user@example.org'))
     319-
    318320+class BaseStreamManagerTestsMixin(object):
    319321 
     
    588590         self.assertFailure(d, ConnectionDone)
    589591         self.assertFalse(self.clock.calls)
    590 @@ -778,6 +753,56 @@
     592@@ -778,6 +753,58 @@
    591593 
    592594 
     
    605607+        self.xmlstream.transport = self.transport
    606608+
    607 +        self.request = IQGetStanza()
     609+        self.request = IQGetStanza(recipient=JID('other@example.org'),
     610+                                   sender=JID('user@example.org'))
    608611+
    609612+
     
    638641+                                   self.streamManager.makeConnection)
    639642+
    640 +        self.request = IQGetStanza()
     643+        self.request = IQGetStanza(recipient=JID('other@example.org'),
     644+                                   sender=JID('user@example.org'))
    641645+
    642646+
  • server-stream-manager.patch

    r79 r83  
    11# HG changeset patch
    22# Parent 3f3fe954b1975c2d9115e0fa8177ae7b28a708a8
    3 # Parent  e198cebf36146a768eda902efa5ee741e947fda8
    43Generalize StreamManager and add ServerStreamManager.
    54
     
    3332 
    3433     def initializationFailed(self, reason):
     34diff --git a/wokkel/component.py b/wokkel/component.py
     35--- a/wokkel/component.py
     36+++ b/wokkel/component.py
     37@@ -36,7 +36,7 @@
     38         StreamManager.__init__(self, factory)
     39 
     40 
     41-    def _authd(self, xs):
     42+    def connectionInitialized(self, xs):
     43         """
     44         Called when stream initialization has completed.
     45 
     46@@ -53,7 +53,7 @@
     47             old_send(obj)
     48 
     49         xs.send = send
     50-        StreamManager._authd(self, xs)
     51+        StreamManager.connectionInitialized(self, xs)
     52 
     53 
     54     def initializationFailed(self, reason):
    3555diff --git a/wokkel/subprotocols.py b/wokkel/subprotocols.py
    3656--- a/wokkel/subprotocols.py
    3757+++ b/wokkel/subprotocols.py
    38 @@ -122,7 +122,7 @@
     58@@ -118,7 +118,7 @@
    3959 
    4060 
     
    4565     Business logic representing a managed XMPP connection.
    4666 
    47 @@ -133,43 +133,39 @@
     67@@ -129,43 +129,39 @@
    4868 
    4969     @ivar xmlstream: currently managed XML stream
     
    96116             from twisted.internet import reactor
    97117         self._reactor = reactor
    98 @@ -195,7 +191,7 @@
     118@@ -191,7 +187,7 @@
    99119             handler.connectionInitialized()
    100120 
     
    105125         Called when the transport connection has been established.
    106126 
    107 @@ -213,13 +209,17 @@
     127@@ -209,13 +205,17 @@
    108128             xs.rawDataInFn = logDataIn
    109129             xs.rawDataOutFn = logDataOut
     
    124144         Called when the stream has been initialized.
    125145 
    126 @@ -242,21 +242,8 @@
     146@@ -238,21 +238,8 @@
    127147             e.connectionInitialized()
    128148 
     
    147167         Called when the stream has been closed.
    148168 
    149 @@ -468,6 +455,60 @@
     169@@ -379,6 +366,60 @@
    150170 
    151171 
     
    231251 
    232252 
     253diff --git a/wokkel/test/test_component.py b/wokkel/test/test_component.py
     254--- a/wokkel/test/test_component.py
     255+++ b/wokkel/test/test_component.py
     256@@ -49,11 +49,18 @@
     257     def __init__(self, *args, **kwargs):
     258         component.Component.__init__(self, *args, **kwargs)
     259         self.factory.clock = Clock()
     260+        self.output = []
     261 
     262 
     263     def _getConnection(self):
     264         c = FakeConnector(self.factory, None, None)
     265         c.connect()
     266+        xs = self.factory.buildProtocol(None)
     267+        xs.send = self.output.append
     268+        xs.connectionMade()
     269+        self.makeConnection(xs)
     270+        xs.thisEntity = xs.otherEntity
     271+        xs.dispatch(xs, xmlstream.STREAM_AUTHD_EVENT)
     272         return c
     273 
     274 
     275@@ -104,6 +111,21 @@
     276         self.assertEqual(1, connector.connects)
     277 
     278 
     279+    def test_stampFrom(self):
     280+        """
     281+        Outgoing elements with missing sender address get component JID.
     282+        """
     283+        comp = TestableComponent('example.org', 5347,
     284+                                 'test.example.org', 'secret')
     285+        comp.startService()
     286+
     287+        element = domish.Element((component.NS_COMPONENT_ACCEPT, "message"))
     288+        element["to"] = "test@example.org"
     289+        comp.xmlstream.send(element)
     290+
     291+        self.assertEqual('test.example.org', element.getAttribute("from"))
     292+
     293+
     294 
     295 class InternalComponentTest(unittest.TestCase):
     296     """
    233297diff --git a/wokkel/test/test_subprotocols.py b/wokkel/test/test_subprotocols.py
    234298--- a/wokkel/test/test_subprotocols.py
    235299+++ b/wokkel/test/test_subprotocols.py
    236 @@ -190,22 +190,7 @@
     300@@ -189,22 +189,7 @@
    237301 
    238302 
     
    258322     def _streamStarted(self):
    259323         """
    260 @@ -219,25 +204,14 @@
     324@@ -216,25 +203,14 @@
    261325         self.xmlstream.dispatch(self.xmlstream, "//event/stream/authd")
    262326 
     
    288352         Test that protocol handlers have their connectionMade method called
    289353         when the XML stream is connected.
    290 @@ -245,27 +219,27 @@
     354@@ -242,27 +218,27 @@
    291355         sm = self.streamManager
    292356         handler = DummyXMPPHandler()
     
    322386         Test raw data functions set when logTraffic is set to True.
    323387         """
    324 @@ -273,13 +247,13 @@
     388@@ -270,13 +246,13 @@
    325389         sm.logTraffic = True
    326390         handler = DummyXMPPHandler()
     
    339403         Test that protocol handlers have their connectionInitialized method
    340404         called when the XML stream is initialized.
    341 @@ -287,27 +261,27 @@
     405@@ -284,27 +260,27 @@
    342406         sm = self.streamManager
    343407         handler = DummyXMPPHandler()
     
    372436         A L{STREAM_END_EVENT} results in L{StreamManager} firing the handlers
    373437         L{connectionLost} methods, passing a L{failure.Failure} reason.
    374 @@ -316,7 +290,7 @@
     438@@ -313,7 +289,7 @@
    375439         handler = FailureReasonXMPPHandler()
    376440         handler.setHandlerParent(sm)
     
    381445 
    382446 
    383 @@ -338,8 +312,8 @@
     447@@ -335,8 +311,8 @@
    384448         Adding a handler when connected doesn't call connectionInitialized.
    385449         """
     
    392456         handler.setHandlerParent(sm)
    393457 
    394 @@ -361,10 +335,10 @@
     458@@ -358,10 +334,10 @@
    395459                 self.nestedHandler.setHandlerParent(self.parent)
    396460 
     
    405469         self.assertEquals(1, handler.doneMade)
    406470         self.assertEquals(0, handler.doneInitialized)
    407 @@ -386,9 +360,9 @@
     471@@ -383,9 +359,9 @@
    408472         called.
    409473         """
     
    418482         handler.setHandlerParent(sm)
    419483 
    420 @@ -410,11 +384,11 @@
     484@@ -407,11 +383,11 @@
    421485                 self.nestedHandler.setHandlerParent(self.parent)
    422486 
     
    433497         self.assertEquals(1, handler.doneMade)
    434498         self.assertEquals(1, handler.doneInitialized)
    435 @@ -438,12 +412,12 @@
     499@@ -435,12 +411,12 @@
    436500                 self.nestedHandler.setHandlerParent(self.parent)
    437501 
     
    450514         self.assertEquals(1, handler.doneMade)
    451515         self.assertEquals(1, handler.doneInitialized)
    452 @@ -473,16 +447,13 @@
     516@@ -470,16 +446,13 @@
    453517 
    454518         The data should be sent directly over the XML stream.
     
    469533 
    470534 
    471 @@ -493,12 +464,11 @@
     535@@ -490,12 +463,11 @@
    472536         The data should be cached until an XML stream has been established and
    473537         initialized.
     
    484548         sm.send("<presence/>")
    485549         self.assertEquals("", xs.transport.value())
    486 @@ -525,7 +495,7 @@
     550@@ -522,7 +494,7 @@
    487551         """
    488552         factory = xmlstream.XmlStreamFactory(xmlstream.Authenticator())
     
    493557         xs.connectionMade()
    494558         xs.dataReceived("<stream:stream xmlns='jabber:client' "
    495 @@ -548,7 +518,7 @@
     559@@ -545,7 +517,7 @@
    496560         handler = DummyXMPPHandler()
    497561         sm.addHandler(handler)
     
    502566         xs.transport = proto_helpers.StringTransport()
    503567         xs.connectionLost(None)
    504 @@ -720,6 +690,7 @@
     568@@ -677,6 +649,7 @@
    505569         """
    506570         d = self.streamManager.request(self.request)
     
    510574         self.assertFailure(d, ConnectionDone)
    511575         return d
    512 @@ -735,6 +706,7 @@
     576@@ -692,6 +665,7 @@
    513577             d = xmlstream.IQ(self.xmlstream).send()
    514578             d.addErrback(eb)
     
    518582         d.addErrback(eb)
    519583         self.xmlstream.connectionLost(failure.Failure(ConnectionDone()))
    520 @@ -780,6 +752,7 @@
     584@@ -736,6 +710,7 @@
    521585         self.request.timeout = 60
    522586         d = self.streamManager.request(self.request)
     
    526590         self.assertFailure(d, ConnectionDone)
    527591         self.assertFalse(self.clock.calls)
    528 @@ -822,6 +795,58 @@
     592@@ -778,6 +753,58 @@
    529593 
    530594 
Note: See TracChangeset for help on using the changeset viewer.