Changes in [82:276bc45eb40b:83:255aae0cf8c5] in ralphm-patches
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
server-stream-manager.patch
r79 r83 1 1 # HG changeset patch 2 2 # Parent 3f3fe954b1975c2d9115e0fa8177ae7b28a708a8 3 # Parent e198cebf36146a768eda902efa5ee741e947fda84 3 Generalize StreamManager and add ServerStreamManager. 5 4 … … 33 32 34 33 def initializationFailed(self, reason): 34 diff --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): 35 55 diff --git a/wokkel/subprotocols.py b/wokkel/subprotocols.py 36 56 --- a/wokkel/subprotocols.py 37 57 +++ b/wokkel/subprotocols.py 38 @@ -1 22,7 +122,7 @@58 @@ -118,7 +118,7 @@ 39 59 40 60 … … 45 65 Business logic representing a managed XMPP connection. 46 66 47 @@ -1 33,43 +133,39 @@67 @@ -129,43 +129,39 @@ 48 68 49 69 @ivar xmlstream: currently managed XML stream … … 96 116 from twisted.internet import reactor 97 117 self._reactor = reactor 98 @@ -19 5,7 +191,7 @@118 @@ -191,7 +187,7 @@ 99 119 handler.connectionInitialized() 100 120 … … 105 125 Called when the transport connection has been established. 106 126 107 @@ -2 13,13 +209,17 @@127 @@ -209,13 +205,17 @@ 108 128 xs.rawDataInFn = logDataIn 109 129 xs.rawDataOutFn = logDataOut … … 124 144 Called when the stream has been initialized. 125 145 126 @@ -2 42,21 +242,8 @@146 @@ -238,21 +238,8 @@ 127 147 e.connectionInitialized() 128 148 … … 147 167 Called when the stream has been closed. 148 168 149 @@ - 468,6 +455,60 @@169 @@ -379,6 +366,60 @@ 150 170 151 171 … … 231 251 232 252 253 diff --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 """ 233 297 diff --git a/wokkel/test/test_subprotocols.py b/wokkel/test/test_subprotocols.py 234 298 --- a/wokkel/test/test_subprotocols.py 235 299 +++ b/wokkel/test/test_subprotocols.py 236 @@ -1 90,22 +190,7 @@300 @@ -189,22 +189,7 @@ 237 301 238 302 … … 258 322 def _streamStarted(self): 259 323 """ 260 @@ -21 9,25 +204,14 @@324 @@ -216,25 +203,14 @@ 261 325 self.xmlstream.dispatch(self.xmlstream, "//event/stream/authd") 262 326 … … 288 352 Test that protocol handlers have their connectionMade method called 289 353 when the XML stream is connected. 290 @@ -24 5,27 +219,27 @@354 @@ -242,27 +218,27 @@ 291 355 sm = self.streamManager 292 356 handler = DummyXMPPHandler() … … 322 386 Test raw data functions set when logTraffic is set to True. 323 387 """ 324 @@ -27 3,13 +247,13 @@388 @@ -270,13 +246,13 @@ 325 389 sm.logTraffic = True 326 390 handler = DummyXMPPHandler() … … 339 403 Test that protocol handlers have their connectionInitialized method 340 404 called when the XML stream is initialized. 341 @@ -28 7,27 +261,27 @@405 @@ -284,27 +260,27 @@ 342 406 sm = self.streamManager 343 407 handler = DummyXMPPHandler() … … 372 436 A L{STREAM_END_EVENT} results in L{StreamManager} firing the handlers 373 437 L{connectionLost} methods, passing a L{failure.Failure} reason. 374 @@ -31 6,7 +290,7 @@438 @@ -313,7 +289,7 @@ 375 439 handler = FailureReasonXMPPHandler() 376 440 handler.setHandlerParent(sm) … … 381 445 382 446 383 @@ -33 8,8 +312,8 @@447 @@ -335,8 +311,8 @@ 384 448 Adding a handler when connected doesn't call connectionInitialized. 385 449 """ … … 392 456 handler.setHandlerParent(sm) 393 457 394 @@ -3 61,10 +335,10 @@458 @@ -358,10 +334,10 @@ 395 459 self.nestedHandler.setHandlerParent(self.parent) 396 460 … … 405 469 self.assertEquals(1, handler.doneMade) 406 470 self.assertEquals(0, handler.doneInitialized) 407 @@ -38 6,9 +360,9 @@471 @@ -383,9 +359,9 @@ 408 472 called. 409 473 """ … … 418 482 handler.setHandlerParent(sm) 419 483 420 @@ -4 10,11 +384,11 @@484 @@ -407,11 +383,11 @@ 421 485 self.nestedHandler.setHandlerParent(self.parent) 422 486 … … 433 497 self.assertEquals(1, handler.doneMade) 434 498 self.assertEquals(1, handler.doneInitialized) 435 @@ -43 8,12 +412,12 @@499 @@ -435,12 +411,12 @@ 436 500 self.nestedHandler.setHandlerParent(self.parent) 437 501 … … 450 514 self.assertEquals(1, handler.doneMade) 451 515 self.assertEquals(1, handler.doneInitialized) 452 @@ -47 3,16 +447,13 @@516 @@ -470,16 +446,13 @@ 453 517 454 518 The data should be sent directly over the XML stream. … … 469 533 470 534 471 @@ -49 3,12 +464,11 @@535 @@ -490,12 +463,11 @@ 472 536 The data should be cached until an XML stream has been established and 473 537 initialized. … … 484 548 sm.send("<presence/>") 485 549 self.assertEquals("", xs.transport.value()) 486 @@ -52 5,7 +495,7 @@550 @@ -522,7 +494,7 @@ 487 551 """ 488 552 factory = xmlstream.XmlStreamFactory(xmlstream.Authenticator()) … … 493 557 xs.connectionMade() 494 558 xs.dataReceived("<stream:stream xmlns='jabber:client' " 495 @@ -54 8,7 +518,7 @@559 @@ -545,7 +517,7 @@ 496 560 handler = DummyXMPPHandler() 497 561 sm.addHandler(handler) … … 502 566 xs.transport = proto_helpers.StringTransport() 503 567 xs.connectionLost(None) 504 @@ - 720,6 +690,7 @@568 @@ -677,6 +649,7 @@ 505 569 """ 506 570 d = self.streamManager.request(self.request) … … 510 574 self.assertFailure(d, ConnectionDone) 511 575 return d 512 @@ - 735,6 +706,7 @@576 @@ -692,6 +665,7 @@ 513 577 d = xmlstream.IQ(self.xmlstream).send() 514 578 d.addErrback(eb) … … 518 582 d.addErrback(eb) 519 583 self.xmlstream.connectionLost(failure.Failure(ConnectionDone())) 520 @@ -7 80,6 +752,7 @@584 @@ -736,6 +710,7 @@ 521 585 self.request.timeout = 60 522 586 d = self.streamManager.request(self.request) … … 526 590 self.assertFailure(d, ConnectionDone) 527 591 self.assertFalse(self.clock.calls) 528 @@ - 822,6 +795,58 @@592 @@ -778,6 +753,58 @@ 529 593 530 594
Note: See TracChangeset
for help on using the changeset viewer.