[Telepathy-commits] [telepathy-gabble/master] steal caps_helper from Salut

Guillaume Desmottes guillaume.desmottes at collabora.co.uk
Tue Jan 27 03:34:59 PST 2009


---
 tests/twisted/caps_helper.py |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)
 create mode 100644 tests/twisted/caps_helper.py

diff --git a/tests/twisted/caps_helper.py b/tests/twisted/caps_helper.py
new file mode 100644
index 0000000..d142caa
--- /dev/null
+++ b/tests/twisted/caps_helper.py
@@ -0,0 +1,25 @@
+import hashlib
+import base64
+
+def compute_caps_hash(identities, features, dataforms):
+    S = ''
+
+    for identity in sorted(identities):
+        S += '%s<' % identity
+
+    for feature in sorted(features):
+        S += '%s<' % feature
+
+    # FIXME: support dataforms
+
+    m = hashlib.sha1()
+    m.update(S)
+    return base64.b64encode(m.digest())
+
+if __name__ == '__main__':
+    # example from XEP-0115
+    assert compute_caps_hash(['client/pc//Exodus 0.9.1'],
+        ["http://jabber.org/protocol/disco#info",
+        "http://jabber.org/protocol/disco#items",
+        "http://jabber.org/protocol/muc", "http://jabber.org/protocol/caps"],
+        []) == 'QgayPKawpkPSDYmwT/WM94uAlu0='
-- 
1.5.6.5




More information about the Telepathy-commits mailing list