telepathy-gabble: gabbletest: properly support domains other than @ localhost

Will Thompson wjt at kemper.freedesktop.org
Thu Dec 6 04:29:03 PST 2012


Module: telepathy-gabble
Branch: master
Commit: c342df10d1a2e7f04bd40afd46549cc0a9f8ca8c
URL:    http://cgit.freedesktop.org/telepathy/telepathy-gabble/commit/?id=c342df10d1a2e7f04bd40afd46549cc0a9f8ca8c

Author: Will Thompson <will.thompson at collabora.co.uk>
Date:   Fri Nov 23 09:47:25 2012 +0000

gabbletest: properly support domains other than @localhost

I need to be able to vary the domain to do a variety of STUN SRV tests.
Previously, whatever domain Gabble tried to connect as, the server would
just bind you back to @localhost. The only test which tried to do
something exotic was the Facebook own-message test, and that one seemed
to work anyway… oh well!

---

 tests/twisted/gabbletest.py |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/tests/twisted/gabbletest.py b/tests/twisted/gabbletest.py
index e83fdbd..83cfd58 100644
--- a/tests/twisted/gabbletest.py
+++ b/tests/twisted/gabbletest.py
@@ -130,6 +130,7 @@ class JabberAuthenticator(GabbleAuthenticator):
     def streamStarted(self, root=None):
         if root:
             self.xmlstream.sid = '%x' % random.randint(1, sys.maxint)
+            self.xmlstream.domain = root.getAttribute('to')
 
         self.xmlstream.sendHeader()
         self.xmlstream.addOnetimeObserver(
@@ -175,7 +176,7 @@ class JabberAuthenticator(GabbleAuthenticator):
         if self.resource is not None:
             assertEquals(self.resource, str(resource[0]))
 
-        self.bare_jid = '%s at localhost' % self.username
+        self.bare_jid = '%s@%s' % (self.username, self.xmlstream.domain)
         self.full_jid = '%s/%s' % (self.bare_jid, resource)
 
         result = IQ(self.xmlstream, "result")
@@ -193,6 +194,7 @@ class XmppAuthenticator(GabbleAuthenticator):
     def streamInitialize(self, root):
         if root:
             self.xmlstream.sid = root.getAttribute('id')
+            self.xmlstream.domain = root.getAttribute('to')
 
         if self.xmlstream.sid is None:
             self.xmlstream.sid = '%x' % random.randint(1, sys.maxint)
@@ -248,7 +250,7 @@ class XmppAuthenticator(GabbleAuthenticator):
         result = IQ(self.xmlstream, "result")
         result["id"] = iq["id"]
         bind = result.addElement((ns.NS_XMPP_BIND, 'bind'))
-        self.bare_jid = '%s at localhost' % self.username
+        self.bare_jid = '%s@%s' % (self.username, self.xmlstream.domain)
         self.full_jid = '%s/%s' % (self.bare_jid, resource)
         jid = bind.addElement('jid', content=self.full_jid)
         self.xmlstream.send(result)
@@ -415,7 +417,7 @@ class BaseXmlStream(xmlstream.XmlStream):
         assert self.authenticator.bare_jid is not None
 
         self.addObserver(
-            "/iq[@to='localhost']/query[@xmlns='http://jabber.org/protocol/disco#info']",
+            "/iq[@to='%s']/query[@xmlns='http://jabber.org/protocol/disco#info']" % self.domain,
             self._cb_disco_iq)
         self.addObserver(
             "/iq[@to='%s']/query[@xmlns='http://jabber.org/protocol/disco#info']"



More information about the telepathy-commits mailing list