summaryrefslogtreecommitdiff
path: root/tests/twisted/caps
diff options
context:
space:
mode:
authorWill Thompson <will.thompson@collabora.co.uk>2009-10-03 02:03:38 +0100
committerWill Thompson <will.thompson@collabora.co.uk>2009-10-07 18:10:48 +0100
commit84c6be681b3ba3a3bef4233e8ec23798ff08cb22 (patch)
tree60a39451c5a4acc9065e8e6f911d3126b9347fe9 /tests/twisted/caps
parent834ed44caea0cd4dee5233fb04b4945581cfc233 (diff)
Cache our own caps before announcing them.
Previously, Gabble didn't put its own capabilities in the cache. So, when it received its own presence echoed back by the server, it would... disco itself.
Diffstat (limited to 'tests/twisted/caps')
-rw-r--r--tests/twisted/caps/trust-thyself.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/twisted/caps/trust-thyself.py b/tests/twisted/caps/trust-thyself.py
new file mode 100644
index 000000000..8732dc585
--- /dev/null
+++ b/tests/twisted/caps/trust-thyself.py
@@ -0,0 +1,33 @@
+"""
+Test that we cache our own capabilities, so that we don't disco other people
+with the same caps hash.
+"""
+from twisted.words.xish import xpath
+
+from gabbletest import exec_test, make_presence, sync_stream
+from servicetest import EventPattern
+import ns
+
+def test(q, bus, conn, stream):
+ conn.Connect()
+ self_presence = q.expect('stream-presence')
+
+ c = xpath.queryForNodes('/presence/c', self_presence.stanza)[0]
+
+ jid = 'lol@great.big/omg'
+ p = make_presence(jid,
+ caps={'node': c['node'],
+ 'hash': c['hash'],
+ 'ver': c['ver'],
+ })
+ stream.send(p)
+
+ uri = c['node'] + '#' + c['ver']
+ q.forbid_events([
+ EventPattern('stream-iq', to=jid, query_ns=ns.DISCO_INFO,
+ query_node=uri)
+ ])
+ sync_stream(q, stream)
+
+if __name__ == '__main__':
+ exec_test(test)