Add test for jabber-disco hashing

Use example from XEP-0115.
This commit is contained in:
Magnus Henoch 2015-03-05 01:37:31 +00:00
parent 255f6804af
commit a9238d2b04
2 changed files with 52 additions and 0 deletions

View File

@ -2,4 +2,5 @@
# check" or "make distcheck" to work with earlier versions.
LOG_COMPILER = env top_builddir=$(top_builddir) $(EMACS) -batch -L $(top_builddir) -L $(top_srcdir) -L $(srcdir) -l
TESTS = load-all.el skip-tag-forward.el history.el jabberd.el nick-change-fail.el
TESTS += caps-hash.el
dist_noinst_DATA = $(TESTS)

51
tests/caps-hash.el Normal file
View File

@ -0,0 +1,51 @@
;; Test disco hash against examples in XEP-0115
(message "Let's go")
(condition-case e
(require 'jabber-disco)
(error
(message "disco bad! %S" e)))
(message "more")
(condition-case e
(require 'jabber-widget)
(error
(message "bad! %S" e)))
(message "done!")
(let ((query
(with-temp-buffer
(insert "<query xmlns='http://jabber.org/protocol/disco#info'
node='http://psi-im.org#q07IKJEyjvHSyhy//CH0CxmKi8w='>
<identity xml:lang='en' category='client' name='Psi 0.11' type='pc'/>
<identity xml:lang='el' category='client' name= 0.11' type='pc'/>
<feature var='http://jabber.org/protocol/caps'/>
<feature var='http://jabber.org/protocol/disco#info'/>
<feature var='http://jabber.org/protocol/disco#items'/>
<feature var='http://jabber.org/protocol/muc'/>
<x xmlns='jabber:x:data' type='result'>
<field var='FORM_TYPE' type='hidden'>
<value>urn:xmpp:dataforms:softwareinfo</value>
</field>
<field var='ip_version'>
<value>ipv4</value>
<value>ipv6</value>
</field>
<field var='os'>
<value>Mac</value>
</field>
<field var='os_version'>
<value>10.5.1</value>
</field>
<field var='software'>
<value>Psi</value>
</field>
<field var='software_version'>
<value>0.11</value>
</field>
</x>
</query>")
(car (xml-parse-region (point-min) (point-max))))))
(message "parsed xml")
(unless (equal "q07IKJEyjvHSyhy//CH0CxmKi8w="
(jabber-caps-ver-string query "sha-1"))
(error "Incorrect caps hash")))