summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill Thompson <will.thompson@collabora.co.uk>2012-11-23 18:26:20 +0000
committerWill Thompson <will.thompson@collabora.co.uk>2012-11-23 18:30:12 +0000
commitecee60dfc33f05e56eb2d2b34faf188943ff8931 (patch)
tree284de7fc853caccf982d1b0f422b756c8a350301
parent1e107a46a34f2251968478052dd4a8239ec2356b (diff)
jingle: correctly send back unknown-session errors
I broke this in c1be75d9 but it wasn't tested. Luckily WOCKY_JINGLE_ERROR_UNKNOWN_SESSION (2) is a valid WockyXmppError too so we didn't crash before, we just sent <gone> instead. https://bugs.freedesktop.org/show_bug.cgi?id=33789 is relevant.
-rw-r--r--src/jingle-factory.c2
-rw-r--r--tests/twisted/Makefile.am1
-rw-r--r--tests/twisted/jingle/unknown-session.py38
-rw-r--r--tests/twisted/ns.py1
4 files changed, 41 insertions, 1 deletions
diff --git a/src/jingle-factory.c b/src/jingle-factory.c
index 0e9f6f73f..2451dd63d 100644
--- a/src/jingle-factory.c
+++ b/src/jingle-factory.c
@@ -367,7 +367,7 @@ ensure_session (GabbleJingleFactory *self,
}
else
{
- g_set_error (error, WOCKY_XMPP_ERROR,
+ g_set_error (error, WOCKY_JINGLE_ERROR,
WOCKY_JINGLE_ERROR_UNKNOWN_SESSION,
"session %s is unknown", sid);
return NULL;
diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index eff6454a1..bd3929048 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -215,6 +215,7 @@ TWISTED_JINGLE_TESTS = \
jingle/test-wait-for-caps-incomplete.py \
jingle/test-wait-for-caps.py \
jingle/transport-info-parsing.py \
+ jingle/unknown-session.py \
$(NULL)
TWISTED_FT_TESTS = \
diff --git a/tests/twisted/jingle/unknown-session.py b/tests/twisted/jingle/unknown-session.py
new file mode 100644
index 000000000..68c97c662
--- /dev/null
+++ b/tests/twisted/jingle/unknown-session.py
@@ -0,0 +1,38 @@
+"""
+Tests that Gabble doesn't explode if it gets Jingle stanzas for unknown
+sessions.
+"""
+
+from gabbletest import exec_test
+from servicetest import assertEquals
+from jingletest2 import JingleProtocol031
+import ns
+
+def assertHasChild(node, uri, name):
+ try:
+ node.elements(uri=uri, name=name).next()
+ except StopIteration:
+ raise AssertionError(
+ "Expected <%s xmlns='%s'> to be a child of\n %s" % (
+ name, uri, node.toXml()))
+
+def test_send_action_for_unknown_session(q, bus, conn, stream):
+ jp = JingleProtocol031()
+ peer = 'guybrush@threepwo.od'
+
+ iq = jp.SetIq(peer, 'test@localhost',
+ [ jp.Jingle('fine-leather-jackets', peer, 'session-info', [])
+ ])
+ stream.send(jp.xml(iq))
+
+ e = q.expect('stream-iq', iq_type='error', iq_id=iq[2]['id'])
+ stanza = e.stanza
+ error_node = stanza.children[-1]
+ assertEquals('error', error_node.name)
+
+ # http://xmpp.org/extensions/xep-0166.html#example-29
+ assertHasChild(error_node, ns.STANZA, 'item-not-found')
+ assertHasChild(error_node, ns.JINGLE_ERRORS, 'unknown-session')
+
+if __name__ == '__main__':
+ exec_test(test_send_action_for_unknown_session)
diff --git a/tests/twisted/ns.py b/tests/twisted/ns.py
index 458e4e156..48b656b30 100644
--- a/tests/twisted/ns.py
+++ b/tests/twisted/ns.py
@@ -26,6 +26,7 @@ JINGLE_015 = "http://jabber.org/protocol/jingle"
JINGLE_015_AUDIO = "http://jabber.org/protocol/jingle/description/audio"
JINGLE_015_VIDEO = "http://jabber.org/protocol/jingle/description/video"
JINGLE = "urn:xmpp:jingle:1"
+JINGLE_ERRORS = "urn:xmpp:jingle:errors:1"
JINGLE_RTP = "urn:xmpp:jingle:apps:rtp:1"
JINGLE_RTP_AUDIO = "urn:xmpp:jingle:apps:rtp:audio"
JINGLE_RTP_VIDEO = "urn:xmpp:jingle:apps:rtp:video"