Changeset 74:355afce3af27 in ralphm-patches for server-stream-manager.patch


Ignore:
Timestamp:
Aug 19, 2014, 4:31:19 PM (6 years ago)
Author:
Ralph Meijer <ralphm@…>
Branch:
default
Message:

Refactor Component to match changes to StreamManager?.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • server-stream-manager.patch

    r72 r74  
    11# HG changeset patch
    2 # Parent 3f3fe954b1975c2d9115e0fa8177ae7b28a708a8
     2# Parent 71082c22f73200a0b8b4b5c6e5d2773f9f68dd4d
    33Generalize StreamManager and add ServerStreamManager.
    44
     
    3232 
    3333     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):
    3455diff --git a/wokkel/subprotocols.py b/wokkel/subprotocols.py
    3556--- a/wokkel/subprotocols.py
    3657+++ b/wokkel/subprotocols.py
    37 @@ -118,7 +118,7 @@
     58@@ -120,7 +120,7 @@
    3859 
    3960 
     
    4465     Business logic representing a managed XMPP connection.
    4566 
    46 @@ -129,43 +129,39 @@
     67@@ -131,43 +131,39 @@
    4768 
    4869     @ivar xmlstream: currently managed XML stream
     
    95116             from twisted.internet import reactor
    96117         self._reactor = reactor
    97 @@ -191,7 +187,7 @@
     118@@ -193,7 +189,7 @@
    98119             handler.connectionInitialized()
    99120 
     
    104125         Called when the transport connection has been established.
    105126 
    106 @@ -209,13 +205,17 @@
     127@@ -211,13 +207,17 @@
    107128             xs.rawDataInFn = logDataIn
    108129             xs.rawDataOutFn = logDataOut
     
    123144         Called when the stream has been initialized.
    124145 
    125 @@ -238,21 +238,8 @@
     146@@ -240,21 +240,8 @@
    126147             e.connectionInitialized()
    127148 
     
    146167         Called when the stream has been closed.
    147168 
    148 @@ -379,6 +366,60 @@
     169@@ -464,6 +451,60 @@
    149170 
    150171 
     
    230251 
    231252 
     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     """
    232297diff --git a/wokkel/test/test_subprotocols.py b/wokkel/test/test_subprotocols.py
    233298--- a/wokkel/test/test_subprotocols.py
Note: See TracChangeset for help on using the changeset viewer.