summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill Thompson <will.thompson@collabora.co.uk>2011-02-14 14:00:18 +0000
committerWill Thompson <will.thompson@collabora.co.uk>2011-02-14 14:00:18 +0000
commit6fc39446921e778c7cf2d1df68d42e3fe8d0234c (patch)
treeb9be2010fd825a05ecc72eaad5b47555d400661a
parenta97255f9c10dc882457288dab918db262e0a9ff0 (diff)
Add a test for jabber:iq:version
-rw-r--r--tests/twisted/Makefile.am1
-rw-r--r--tests/twisted/ns.py1
-rw-r--r--tests/twisted/version.py37
3 files changed, 39 insertions, 0 deletions
diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index ca58b1118..b5fbda631 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -87,6 +87,7 @@ TWISTED_TESTS = \
text/test-text-no-body.py \
text/test-text.py \
tls/server-tls-channel.py \
+ version.py \
$(NULL)
TWISTED_TUBE_TESTS = \
diff --git a/tests/twisted/ns.py b/tests/twisted/ns.py
index 758d00bdf..66d2ecb55 100644
--- a/tests/twisted/ns.py
+++ b/tests/twisted/ns.py
@@ -74,3 +74,4 @@ PRESENCE_INVISIBLE = 'presence-invisible'
PRIVACY = 'jabber:iq:privacy'
INVISIBLE = 'urn:xmpp:invisible:0'
GOOGLE_SHARED_STATUS = 'google:shared-status'
+VERSION = 'jabber:iq:version'
diff --git a/tests/twisted/version.py b/tests/twisted/version.py
new file mode 100644
index 000000000..8bd37d888
--- /dev/null
+++ b/tests/twisted/version.py
@@ -0,0 +1,37 @@
+# vim: set encoding=utf-8 :
+"""
+Tests Gabble's implementation of XEP-0092.
+"""
+
+from twisted.words.xish import xpath
+from servicetest import assertLength, assertEquals
+from gabbletest import exec_test, elem_iq, elem
+import ns
+
+def test(q, bus, conn, stream):
+ request = elem_iq(stream, 'get')(
+ elem(ns.VERSION, 'query')
+ )
+
+ stream.send(request)
+ reply = q.expect('stream-iq', iq_id=request['id'],
+ query_ns=ns.VERSION, query_name='query')
+
+ # Both <name/> and <version/> are REQUIRED. What they actually contain is
+ # someone else's problem™.
+ names = xpath.queryForNodes('/query/name', reply.query)
+ assertLength(1, names)
+
+ versions = xpath.queryForNodes('/query/version', reply.query)
+ assertLength(1, versions)
+
+ # <os/> is OPTIONAL. “Revealing the application's underlying operating
+ # system may open the user or system to attacks directed against that
+ # operating system; therefore, an application MUST provide a way for a
+ # human user or administrator to disable sharing of information about the
+ # operating system.” The “way” that we provide is never to send it.
+ oss = xpath.queryForNodes('/query/os', reply.query)
+ assert oss is None
+
+if __name__ == '__main__':
+ exec_test(test)