diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2010-06-09 11:33:59 +0200 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2010-06-09 11:33:59 +0200 |
commit | 742246dc15b4145b03e2f1295d57fe136b80e836 (patch) | |
tree | 03e83055fed13d946cdea0ced196a0b04f438bf1 /tests/twisted/pep-support.py | |
parent | f68a31f67b5e64a8cee28c09f6fd039b7496e2cf (diff) |
BaseXmlStream: implement standard PEP disco
BaseXmlStream should implement the standard protocol and pep-support.py test
the legacy one.
Diffstat (limited to 'tests/twisted/pep-support.py')
-rw-r--r-- | tests/twisted/pep-support.py | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/tests/twisted/pep-support.py b/tests/twisted/pep-support.py index b97a27f81..4552e327b 100644 --- a/tests/twisted/pep-support.py +++ b/tests/twisted/pep-support.py @@ -11,6 +11,29 @@ import ns # PEP supports is advertised in Server's disco which is wrong but that's what # old ejabberd used to do. +class PepInServerDiscoXmlStream(BaseXmlStream): + version = (1, 0) + + def _cb_disco_iq(self, iq): + # Advertise PEP support in server disco rather than when discoing our + # bare JID + nodes = xpath.queryForNodes( + "/iq/query[@xmlns='http://jabber.org/protocol/disco#info']", + iq) + query = nodes[0] + identity = query.addElement('identity') + identity['category'] = 'pubsub' + identity['type'] = 'pep' + + iq['type'] = 'result' + iq['from'] = 'localhost' + self.send(iq) + + def _cb_bare_jid_disco_iq(self, iq): + iq['type'] = 'result' + iq['from'] = iq['to'] + self.send(iq) + def test_legacy(q, bus, conn, stream): conn.Connect() @@ -61,30 +84,7 @@ def test_pep(q, bus, conn, stream): acknowledge_iq(stream, event.stanza) q.expect('dbus-return', method='SetLocation') -class PEPinJidDiscoXmppStream(BaseXmlStream): - version = (1, 0) - - def _cb_disco_iq(self, iq): - # Server disco doesn't contain PEP - iq['type'] = 'result' - iq['from'] = 'localhost' - self.send(iq) - - def _cb_bare_jid_disco_iq(self, iq): - # ...but our own jid disco does - nodes = xpath.queryForNodes( - "/iq/query[@xmlns='http://jabber.org/protocol/disco#info']", - iq) - query = nodes[0] - identity = query.addElement('identity') - identity['category'] = 'pubsub' - identity['type'] = 'pep' - - iq['type'] = 'result' - iq['from'] = iq['to'] - self.send(iq) - if __name__ == '__main__': - exec_test(test_legacy) + exec_test(test_legacy, protocol=PepInServerDiscoXmlStream) exec_test(test_no_pep, protocol=GoogleXmlStream) - exec_test(test_pep, protocol=PEPinJidDiscoXmppStream) + exec_test(test_pep) |