[Telepathy-commits] [telepathy-gabble/master] Twisted tests: Move BlockForeverTlsAuthenticator from gabbletest.py to test-connect-twice.py

Alban Crequy alban.crequy at collabora.co.uk
Tue Aug 19 10:52:54 PDT 2008


20080603163144-a41c0-f47cf9a30662004b58047606520ec588343ef971.gz
---
 tests/twisted/gabbletest.py         |   36 -----------------------------
 tests/twisted/test-connect-twice.py |   43 ++++++++++++++++++++++++++++++++++-
 2 files changed, 42 insertions(+), 37 deletions(-)

diff --git a/tests/twisted/gabbletest.py b/tests/twisted/gabbletest.py
index 2708c3f..da08cb5 100644
--- a/tests/twisted/gabbletest.py
+++ b/tests/twisted/gabbletest.py
@@ -19,7 +19,6 @@ import dbus
 
 NS_XMPP_SASL = 'urn:ietf:params:xml:ns:xmpp-sasl'
 NS_XMPP_BIND = 'urn:ietf:params:xml:ns:xmpp-bind'
-NS_XMPP_TLS = 'urn:ietf:params:xml:ns:xmpp-tls'
 
 def make_result_iq(stream, iq):
     result = IQ(stream, "result")
@@ -86,41 +85,6 @@ class JabberAuthenticator(xmlstream.Authenticator):
         self.xmlstream.send(result)
         self.xmlstream.dispatch(self.xmlstream, xmlstream.STREAM_AUTHD_EVENT)
 
-class BlockForeverTlsAuthenticator(xmlstream.Authenticator):
-    """A TLS stream authenticator that is deliberately broken. It sends
-    <proceed/> to the client but then do nothing, so the TLS handshake will
-    not work. Useful for testing regression of bug #14341."""
-
-    def __init__(self, username, password):
-        xmlstream.Authenticator.__init__(self)
-        self.username = username
-        self.password = password
-        self.authenticated = False
-
-    def streamStarted(self, root=None):
-        if root:
-            self.xmlstream.sid = root.getAttribute('id')
-
-        self.xmlstream.sendHeader()
-
-        features = domish.Element((xmlstream.NS_STREAMS, 'features'))
-        mechanisms = features.addElement((NS_XMPP_SASL, 'mechanisms'))
-        mechanism = mechanisms.addElement('mechanism', content='DIGEST-MD5')
-        starttls = features.addElement((NS_XMPP_TLS, 'starttls'))
-        starttls.addElement('required')
-        self.xmlstream.send(features)
-
-        self.xmlstream.addOnetimeObserver("/starttls", self.auth)
-
-    def auth(self, auth):
-        proceed = domish.Element((NS_XMPP_TLS, 'proceed'))
-        self.xmlstream.send(proceed)
-
-        return; # auth blocks
-
-        self.xmlstream.reset()
-        self.authenticated = True
-
 
 class XmppAuthenticator(xmlstream.Authenticator):
     def __init__(self, username, password):
diff --git a/tests/twisted/test-connect-twice.py b/tests/twisted/test-connect-twice.py
index 446edbd..cebc0cf 100644
--- a/tests/twisted/test-connect-twice.py
+++ b/tests/twisted/test-connect-twice.py
@@ -10,11 +10,52 @@ import dbus
 import servicetest
 
 import twisted
+from twisted.words.xish import domish, xpath
+from twisted.words.protocols.jabber import xmlstream
 
 from gabbletest import make_connection, make_stream, JabberAuthenticator, \
-                       XmppAuthenticator, BlockForeverTlsAuthenticator, \
+                       XmppAuthenticator, \
                        XmppXmlStream, JabberXmlStream
 
+NS_XMPP_TLS = 'urn:ietf:params:xml:ns:xmpp-tls'
+NS_XMPP_SASL = 'urn:ietf:params:xml:ns:xmpp-sasl'
+
+class BlockForeverTlsAuthenticator(xmlstream.Authenticator):
+    """A TLS stream authenticator that is deliberately broken. It sends
+    <proceed/> to the client but then do nothing, so the TLS handshake will
+    not work. Useful for testing regression of bug #14341."""
+
+    def __init__(self, username, password):
+        xmlstream.Authenticator.__init__(self)
+        self.username = username
+        self.password = password
+        self.authenticated = False
+
+    def streamStarted(self, root=None):
+        if root:
+            self.xmlstream.sid = root.getAttribute('id')
+
+        self.xmlstream.sendHeader()
+
+        features = domish.Element((xmlstream.NS_STREAMS, 'features'))
+        mechanisms = features.addElement((NS_XMPP_SASL, 'mechanisms'))
+        mechanism = mechanisms.addElement('mechanism', content='DIGEST-MD5')
+        starttls = features.addElement((NS_XMPP_TLS, 'starttls'))
+        starttls.addElement('required')
+        self.xmlstream.send(features)
+
+        self.xmlstream.addOnetimeObserver("/starttls", self.auth)
+
+    def auth(self, auth):
+        proceed = domish.Element((NS_XMPP_TLS, 'proceed'))
+        self.xmlstream.send(proceed)
+
+        return; # auth blocks
+
+        self.xmlstream.reset()
+        self.authenticated = True
+
+
 def test(q, bus, conn1, conn2, stream1, stream2):
     # Connection 1
     conn1.Connect()
-- 
1.5.6.3




More information about the Telepathy-commits mailing list