summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2011-06-20 16:25:56 -0700
committerLance Stout <lancestout@gmail.com>2011-06-20 16:25:56 -0700
commitd8d9e8df16c07bd13bbac72e4445a2930407b244 (patch)
treeb2a02ebf569eb24bf5d91618af8f2575dae4628b /tests
parent58aa944a5e07032fc8d5770347f82e7c2ce6c948 (diff)
downloadslixmpp-d8d9e8df16c07bd13bbac72e4445a2930407b244.tar.gz
slixmpp-d8d9e8df16c07bd13bbac72e4445a2930407b244.tar.bz2
slixmpp-d8d9e8df16c07bd13bbac72e4445a2930407b244.tar.xz
slixmpp-d8d9e8df16c07bd13bbac72e4445a2930407b244.zip
Fix stanza clobbering when replying to errors.sleek-1.0.0-beta5sleek-1.0-Beta51.0.0-beta51.0-Beta5
If a stanza handler raised an exception, the exception was processed and replied by the modified stanza, not a stanza with the original content. A copy is now made before handler processing, and if an exception occurs it is the copy that processes the exception using the original content.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_stream_exceptions.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/test_stream_exceptions.py b/tests/test_stream_exceptions.py
index bc01c2a7..1143ce28 100644
--- a/tests/test_stream_exceptions.py
+++ b/tests/test_stream_exceptions.py
@@ -15,6 +15,35 @@ class TestStreamExceptions(SleekTest):
sys.excepthook = sys.__excepthook__
self.stream_close()
+ def testExceptionReply(self):
+ """Test that raising an exception replies with the original stanza."""
+
+ def message(msg):
+ msg.reply()
+ msg['body'] = 'Body changed'
+ raise XMPPError(clear=False)
+
+
+ sys.excepthook = lambda *args, **kwargs: None
+ self.stream_start()
+ self.xmpp.add_event_handler('message', message)
+
+ self.recv("""
+ <message>
+ <body>This is going to cause an error.</body>
+ </message>
+ """)
+
+ self.send("""
+ <message type="error">
+ <body>This is going to cause an error.</body>
+ <error type="cancel" code="500">
+ <undefined-condition
+ xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" />
+ </error>
+ </message>
+ """)
+
def testXMPPErrorException(self):
"""Test raising an XMPPError exception."""