def test_initRequired(self):
     """
     Passing required sets the instance variable.
     """
     self.init = xmlstream.TLSInitiatingInitializer(self.xmlstream,
                                                    required=True)
     self.assertTrue(self.init.required)
Beispiel #2
0
    def associateWithStream(self, xs):
        xmlstream.ConnectAuthenticator.associateWithStream(self, xs)

        tlsInit = xmlstream.TLSInitiatingInitializer(xs)
        xs.initializers = [client.CheckVersionInitializer(xs),
                           tlsInit,
                           CheckAuthInitializer(xs)]
Beispiel #3
0
    def associateWithStream(self, xs):
        xs.version = (0, 0)
        xmlstream.ConnectAuthenticator.associateWithStream(self, xs)

        xs.initializers = [
            xmlstream.TLSInitiatingInitializer(xs, required=False),
            IQAuthInitializer(xs),
        ]
Beispiel #4
0
    def setUp(self):
        self.output = []
        self.done = []

        self.savedSSL = xmlstream.ssl

        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 = xmlstream.TLSInitiatingInitializer(self.xmlstream)
Beispiel #5
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),
                ]
    def test_certificateVerifyContext(self):
        """
        A custom contextFactory is passed through to startTLS.
        """
        ctx = CertificateOptions()
        self.init = xmlstream.TLSInitiatingInitializer(self.xmlstream,
                                                       configurationForTLS=ctx)

        self.init.contextFactory = ctx

        def fakeStartTLS(contextFactory):
            self.assertIs(ctx, contextFactory)
            self.done.append("TLS")

        self.xmlstream.transport = proto_helpers.StringTransport()
        self.xmlstream.transport.startTLS = fakeStartTLS
        self.xmlstream.reset = lambda: self.done.append("reset")
        self.xmlstream.sendHeader = lambda: self.done.append("header")

        d = self.init.start()
        self.xmlstream.dataReceived("<proceed xmlns='%s'/>" % NS_XMPP_TLS)
        self.assertEqual(["TLS", "reset", "header"], self.done)
        return d
Beispiel #7
0
 def associateWithStream(self, xs):
     xmlstream.ConnectAuthenticator.associateWithStream(self, xs)
     xs.initializers = [
         xmlstream.TLSInitiatingInitializer(xs),
         RegisterInitializer(xs, self._jid_obj, self._password),
     ]