Esempio n. 1
0
    def setUp(self):
        self.output = []

        self.authenticator = xmlstream.Authenticator()
        self.xmlstream = xmlstream.XmlStream(self.authenticator)
        self.xmlstream.send = self.output.append
        self.xmlstream.connectionMade()
        self.xmlstream.dataReceived("<stream:stream xmlns='jabber:client' "
                        "xmlns:stream='http://etherx.jabber.org/streams' "
                        "from='example.com' id='12345' version='1.0'>")

        self.init = sasl.SASLInitiatingInitializer(self.xmlstream)
Esempio n. 2
0
 def testOnFailure(self):
     """
     Test that the SASL error condition is correctly extracted.
     """
     self.authenticator = xmlstream.Authenticator()
     self.xmlstream = xmlstream.XmlStream(self.authenticator)
     init = sasl.SASLInitiatingInitializer(self.xmlstream)
     failure = domish.Element(
         ('urn:ietf:params:xml:ns:xmpp-sasl', 'failure'))
     failure.addElement('not-authorized')
     init._deferred = defer.Deferred()
     init.onFailure(failure)
     self.assertFailure(init._deferred, sasl.SASLAuthError)
     init._deferred.addCallback(
         lambda e: self.assertEquals('not-authorized', e.condition))
     return init._deferred
Esempio n. 3
0
    def associateWithStream(self, xs):
        """
        Register with the XML stream.

        Populates stream's list of initializers, along with their
        requiredness. This list is used by
        L{ConnectAuthenticator.initializeStream} to perform the initialization
        steps.
        """
        xmlstream.ConnectAuthenticator.associateWithStream(self, xs)

        xs.initializers = [
                CheckVersionInitializer(xs),
                xmlstream.TLSInitiatingInitializer(
                    xs, required=True,
                    configurationForTLS=self._configurationForTLS),
                sasl.SASLInitiatingInitializer(xs, required=True),
                BindInitializer(xs, required=True),
                SessionInitializer(xs, required=False),
                ]