Esempio n. 1
0
 def testUnencrypted(self):
     url, portnum = self.makeServer(False)
     client = pb.PBService(encrypted=False)
     client.startService()
     self.services.append(client)
     d = client.getReference(url)
     return d
Esempio n. 2
0
 def testUnauthenticated(self):
     url, portnum = self.makeServer(False)
     client = UnauthenticatedTub()
     client.startService()
     self.services.append(client)
     d = client.getReference(url)
     return d
Esempio n. 3
0
 def testUnauthenticated(self):
     url, portnum = self.makeServer(False)
     client = UnauthenticatedTub()
     client.startService()
     self.services.append(client)
     d = client.getReference(url)
     return d
Esempio n. 4
0
 def testUnencrypted(self):
     url, portnum = self.makeServer(False)
     client = pb.PBService(encrypted=False)
     client.startService()
     self.services.append(client)
     d = client.getReference(url)
     return d
Esempio n. 5
0
 def testHalfAuthenticated2(self):
     if not crypto_available:
         raise unittest.SkipTest("crypto not available")
     url, portnum = self.makeServer(False)
     client = Tub()
     client.startService()
     self.services.append(client)
     d = client.getReference(url)
     return d
Esempio n. 6
0
 def testHalfAuthenticated2(self):
     if not crypto_available:
         raise unittest.SkipTest("crypto not available")
     url, portnum = self.makeServer(False)
     client = Tub()
     client.startService()
     self.services.append(client)
     d = client.getReference(url)
     return d
Esempio n. 7
0
 def testHalfEncrypted2(self):
     if not crypto:
         raise unittest.SkipTest("crypto not available")
     url, portnum = self.makeServer(False)
     client = pb.PBService(encrypted=True)
     client.startService()
     self.services.append(client)
     d = client.getReference(url)
     return d
Esempio n. 8
0
 def _testNoConnection_1(self, res, url):
     self.services.remove(self.tub)
     client = pb.PBService(encrypted=False)
     client.startService()
     self.services.append(client)
     d = client.getReference(url)
     d.addCallbacks(lambda res: self.fail("this is supposed to fail"),
                    self._testNoConnection_fail)
     return d
Esempio n. 9
0
 def testHalfEncrypted2(self):
     if not crypto:
         raise unittest.SkipTest("crypto not available")
     url, portnum = self.makeServer(False)
     client = pb.PBService(encrypted=True)
     client.startService()
     self.services.append(client)
     d = client.getReference(url)
     return d
Esempio n. 10
0
 def _testNoConnection_1(self, res, url):
     self.services.remove(self.tub)
     client = UnauthenticatedTub()
     client.startService()
     self.services.append(client)
     d = client.getReference(url)
     d.addCallbacks(lambda res: self.fail("this is supposed to fail"),
                    self._testNoConnection_fail)
     return d
Esempio n. 11
0
 def testClientTimeout(self):
     portnum = self.makeNullServer()
     client = pb.PBService(encrypted=False, options={'connect_timeout': 1})
     client.startService()
     self.services.append(client)
     url = "pbu://localhost:%d/target" % portnum
     d = client.getReference(url)
     d.addCallbacks(lambda res: self.fail("hey! this is supposed to fail"),
                    lambda f: f.trap(tokens.NegotiationError))
     return d
Esempio n. 12
0
 def connect(self, url, encrypted=True):
     self.clientPhases = []
     opts = {"debug_stall_second_connection": True,
             "debug_gatherPhases": self.clientPhases}
     self.client = client = pb.PBService(encrypted=encrypted,
                                         options=opts)
     client.startService()
     self.services.append(client)
     d = client.getReference(url)
     return d
Esempio n. 13
0
 def connect(self, url, encrypted=True):
     self.clientPhases = []
     opts = {
         "debug_stall_second_connection": True,
         "debug_gatherPhases": self.clientPhases
     }
     self.client = client = pb.PBService(encrypted=encrypted, options=opts)
     client.startService()
     self.services.append(client)
     d = client.getReference(url)
     return d
Esempio n. 14
0
 def testVersusHTTPServerUnencrypted(self):
     portnum = self.makeHTTPServer()
     client = pb.PBService(encrypted=False)
     client.startService()
     self.services.append(client)
     url = "pbu://localhost:%d/target" % portnum
     d = client.getReference(url)
     d.addCallbacks(lambda res: self.fail("this is supposed to fail"),
                    lambda f: f.trap(pb.BananaError))
     d.addCallback(self.stall, 1)  # same reason as above
     return d
Esempio n. 15
0
 def testVersusHTTPServerUnencrypted(self):
     portnum = self.makeHTTPServer()
     client = pb.PBService(encrypted=False)
     client.startService()
     self.services.append(client)
     url = "pbu://localhost:%d/target" % portnum
     d = client.getReference(url)
     d.addCallbacks(lambda res: self.fail("this is supposed to fail"),
                    lambda f: f.trap(pb.BananaError))
     d.addCallback(self.stall, 1) # same reason as above
     return d
Esempio n. 16
0
 def testClientTimeout(self):
     portnum = self.makeNullServer()
     # lower the connection timeout to 2 seconds
     client = UnauthenticatedTub(options={'connect_timeout': 1})
     client.startService()
     self.services.append(client)
     url = "pbu://127.0.0.1:%d/target" % portnum
     d = client.getReference(url)
     d.addCallbacks(lambda res: self.fail("hey! this is supposed to fail"),
                    lambda f: f.trap(tokens.NegotiationError))
     return d
Esempio n. 17
0
 def testVersusHTTPServerUnauthenticated(self):
     portnum = self.makeHTTPServer()
     client = UnauthenticatedTub()
     client.startService()
     self.services.append(client)
     url = "pbu://127.0.0.1:%d/target" % portnum
     d = client.getReference(url)
     d.addCallbacks(lambda res: self.fail("this is supposed to fail"),
                    lambda f: f.trap(BananaError))
     d.addCallback(self.stall, 1) # same reason as above
     return d
Esempio n. 18
0
 def testVersusHTTPServerUnauthenticated(self):
     portnum = self.makeHTTPServer()
     client = UnauthenticatedTub()
     client.startService()
     self.services.append(client)
     url = "pbu://127.0.0.1:%d/target" % portnum
     d = client.getReference(url)
     d.addCallbacks(lambda res: self.fail("this is supposed to fail"),
                    lambda f: f.trap(BananaError))
     d.addCallback(self.stall, 1)  # same reason as above
     return d
Esempio n. 19
0
 def testClientTimeout(self):
     portnum = self.makeNullServer()
     # lower the connection timeout to 2 seconds
     client = UnauthenticatedTub(options={'connect_timeout': 1})
     client.startService()
     self.services.append(client)
     url = "pbu://127.0.0.1:%d/target" % portnum
     d = client.getReference(url)
     d.addCallbacks(lambda res: self.fail("hey! this is supposed to fail"),
                    lambda f: f.trap(tokens.NegotiationError))
     return d
Esempio n. 20
0
 def connect(self, url, authenticated=True):
     self.clientPhases = []
     opts = {"debug_stall_second_connection": True,
             "debug_gatherPhases": self.clientPhases}
     if authenticated:
         self.client = client = Tub(options=opts)
     else:
         self.client = client = UnauthenticatedTub(options=opts)
     client.startService()
     self.services.append(client)
     d = client.getReference(url)
     return d
Esempio n. 21
0
 def testVersusHTTPServerEncrypted(self):
     if not crypto:
         raise unittest.SkipTest("crypto not available")
     portnum = self.makeHTTPServer()
     client = pb.PBService(encrypted=True)
     client.startService()
     self.services.append(client)
     url = "pb://1234@localhost:%d/target" % portnum
     d = client.getReference(url)
     d.addCallbacks(lambda res: self.fail("this is supposed to fail"),
                    lambda f: f.trap(pb.BananaError))
     d.addCallback(self.stall, 1)
     return d
Esempio n. 22
0
 def testFuture3(self):
     # same as testFuture1, but it is the listening server that
     # understands [1,2]
     self.requireCrypto()
     url, portnum = self.makeSpecificServer(certData_high, NegotiationVbig)
     client = Tub(certData=certData_low)
     client.startService()
     self.services.append(client)
     d = client.getReference(url)
     def _check_version(rref):
         ver = rref.tracker.broker._banana_decision_version
         self.failUnlessEqual(ver, MAX_HANDLED_VERSION)
     d.addCallback(_check_version)
     return d
Esempio n. 23
0
 def connect(self, url, authenticated=True):
     self.clientPhases = []
     opts = {
         "debug_stall_second_connection": True,
         "debug_gatherPhases": self.clientPhases
     }
     if authenticated:
         self.client = client = Tub(options=opts)
     else:
         self.client = client = UnauthenticatedTub(options=opts)
     client.startService()
     self.services.append(client)
     d = client.getReference(url)
     return d
Esempio n. 24
0
 def testVersusHTTPServerAuthenticated(self):
     if not crypto_available:
         raise unittest.SkipTest("crypto not available")
     portnum = self.makeHTTPServer()
     client = Tub()
     client.startService()
     self.services.append(client)
     url = "pb://%[email protected]:%d/target" % (tubid_low, portnum)
     d = client.getReference(url)
     d.addCallbacks(lambda res: self.fail("this is supposed to fail"),
                    lambda f: f.trap(BananaError))
     # the HTTP server needs a moment to notice that the connection has
     # gone away. Without this, trial flunks the test because of the
     # leftover HTTP server socket.
     d.addCallback(self.stall, 1)
     return d
Esempio n. 25
0
 def testVersusHTTPServerEncrypted(self):
     if not crypto:
         raise unittest.SkipTest("crypto not available")
     portnum = self.makeHTTPServer()
     client = pb.PBService(encrypted=True)
     client.startService()
     self.services.append(client)
     url = "pb://1234@localhost:%d/target" % portnum
     d = client.getReference(url)
     d.addCallbacks(lambda res: self.fail("this is supposed to fail"),
                    lambda f: f.trap(pb.BananaError))
     # the HTTP server needs a moment to notice that the connection has
     # gone away. Without this, trial flunks the test because of the
     # leftover HTTP server socket.
     d.addCallback(self.stall, 1)
     return d
Esempio n. 26
0
 def testFuture2(self):
     # same as before, but the connecting Tub will have the higher tubID,
     # and thus make the negotiation decision
     self.requireCrypto()
     url, portnum = self.makeSpecificServer(certData_low)
     # the client
     client = Tub(certData=certData_high)
     client.negotiationClass = NegotiationVbig
     client.startService()
     self.services.append(client)
     d = client.getReference(url)
     def _check_version(rref):
         ver = rref.tracker.broker._banana_decision_version
         self.failUnlessEqual(ver, MAX_HANDLED_VERSION)
     d.addCallback(_check_version)
     return d
Esempio n. 27
0
 def testVersusHTTPServerAuthenticated(self):
     if not crypto_available:
         raise unittest.SkipTest("crypto not available")
     portnum = self.makeHTTPServer()
     client = Tub()
     client.startService()
     self.services.append(client)
     url = "pb://%[email protected]:%d/target" % (tubid_low, portnum)
     d = client.getReference(url)
     d.addCallbacks(lambda res: self.fail("this is supposed to fail"),
                    lambda f: f.trap(BananaError))
     # the HTTP server needs a moment to notice that the connection has
     # gone away. Without this, trial flunks the test because of the
     # leftover HTTP server socket.
     d.addCallback(self.stall, 1)
     return d
Esempio n. 28
0
    def testFuture3(self):
        # same as testFuture1, but it is the listening server that
        # understands [1,2]
        self.requireCrypto()
        url, portnum = self.makeSpecificServer(certData_high, NegotiationVbig)
        client = Tub(certData=certData_low)
        client.startService()
        self.services.append(client)
        d = client.getReference(url)

        def _check_version(rref):
            ver = rref.tracker.broker._banana_decision_version
            self.failUnlessEqual(ver, MAX_HANDLED_VERSION)

        d.addCallback(_check_version)
        return d
Esempio n. 29
0
 def testTooFarInFuture2(self):
     # same as before, but the connecting Tub will have the higher tubID,
     # and thus make the negotiation decision
     self.requireCrypto()
     url, portnum = self.makeSpecificServer(certData_low)
     client = Tub(certData=certData_high)
     client.negotiationClass = NegotiationVbigOnly
     client.startService()
     self.services.append(client)
     d = client.getReference(url)
     def _oops_succeeded(rref):
         self.fail("hey! this is supposed to fail")
     def _check_failure(f):
         f.trap(tokens.NegotiationError, tokens.RemoteNegotiationError)
     d.addCallbacks(_oops_succeeded, _check_failure)
     return d
Esempio n. 30
0
 def testTooFarInFuture4(self):
     # same as testTooFarInFuture2, but it is the listening server which
     # only understands [2]
     self.requireCrypto()
     url, portnum = self.makeSpecificServer(certData_low,
                                            NegotiationVbigOnly)
     client = Tub(certData=certData_high)
     client.startService()
     self.services.append(client)
     d = client.getReference(url)
     def _oops_succeeded(rref):
         self.fail("hey! this is supposed to fail")
     def _check_failure(f):
         f.trap(tokens.NegotiationError, tokens.RemoteNegotiationError)
     d.addCallbacks(_oops_succeeded, _check_failure)
     return d
Esempio n. 31
0
 def testVersusHTTPServerEncrypted(self):
     if not crypto:
         raise unittest.SkipTest("crypto not available")
     portnum = self.makeHTTPServer()
     client = pb.PBService(encrypted=True)
     client.startService()
     self.services.append(client)
     url = "pb://1234@localhost:%d/target" % portnum
     d = client.getReference(url)
     d.addCallbacks(lambda res: self.fail("this is supposed to fail"),
                    lambda f: f.trap(pb.BananaError))
     # the HTTP server needs a moment to notice that the connection has
     # gone away. Without this, trial flunks the test because of the
     # leftover HTTP server socket.
     d.addCallback(self.stall, 1)
     return d
Esempio n. 32
0
    def testFuture2(self):
        # same as before, but the connecting Tub will have the higher tubID,
        # and thus make the negotiation decision
        self.requireCrypto()
        url, portnum = self.makeSpecificServer(certData_low)
        # the client
        client = Tub(certData=certData_high)
        client.negotiationClass = NegotiationVbig
        client.startService()
        self.services.append(client)
        d = client.getReference(url)

        def _check_version(rref):
            ver = rref.tracker.broker._banana_decision_version
            self.failUnlessEqual(ver, MAX_HANDLED_VERSION)

        d.addCallback(_check_version)
        return d
Esempio n. 33
0
    def testTooFarInFuture4(self):
        # same as testTooFarInFuture2, but it is the listening server which
        # only understands [2]
        self.requireCrypto()
        url, portnum = self.makeSpecificServer(certData_low,
                                               NegotiationVbigOnly)
        client = Tub(certData=certData_high)
        client.startService()
        self.services.append(client)
        d = client.getReference(url)

        def _oops_succeeded(rref):
            self.fail("hey! this is supposed to fail")

        def _check_failure(f):
            f.trap(tokens.NegotiationError, tokens.RemoteNegotiationError)

        d.addCallbacks(_oops_succeeded, _check_failure)
        return d
Esempio n. 34
0
    def testFuture1(self):
        # when a peer that understands version=[1] that connects to a peer
        # that understands version=[1,2], they should pick version=1

        # the listening Tub will have the higher tubID, and thus make the
        # negotiation decision
        self.requireCrypto()
        url, portnum = self.makeSpecificServer(certData_high)
        # the client
        client = Tub(certData=certData_low)
        client.negotiationClass = NegotiationVbig
        client.startService()
        self.services.append(client)
        d = client.getReference(url)
        def _check_version(rref):
            ver = rref.tracker.broker._banana_decision_version
            self.failUnlessEqual(ver, MAX_HANDLED_VERSION)
        d.addCallback(_check_version)
        return d
Esempio n. 35
0
    def testTooFarInFuture2(self):
        # same as before, but the connecting Tub will have the higher tubID,
        # and thus make the negotiation decision
        self.requireCrypto()
        url, portnum = self.makeSpecificServer(certData_low)
        client = Tub(certData=certData_high)
        client.negotiationClass = NegotiationVbigOnly
        client.startService()
        self.services.append(client)
        d = client.getReference(url)

        def _oops_succeeded(rref):
            self.fail("hey! this is supposed to fail")

        def _check_failure(f):
            f.trap(tokens.NegotiationError, tokens.RemoteNegotiationError)

        d.addCallbacks(_oops_succeeded, _check_failure)
        return d
Esempio n. 36
0
    def testTooFarInFuture1(self):
        # when a peer that understands version=[1] that connects to a peer
        # that only understands version=[2], they should fail to negotiate

        # the listening Tub will have the higher tubID, and thus make the
        # negotiation decision
        self.requireCrypto()
        url, portnum = self.makeSpecificServer(certData_high)
        # the client
        client = Tub(certData=certData_low)
        client.negotiationClass = NegotiationVbigOnly
        client.startService()
        self.services.append(client)
        d = client.getReference(url)
        def _oops_succeeded(rref):
            self.fail("hey! this is supposed to fail")
        def _check_failure(f):
            f.trap(tokens.NegotiationError, tokens.RemoteNegotiationError)
        d.addCallbacks(_oops_succeeded, _check_failure)
        return d
Esempio n. 37
0
    def testFuture1(self):
        # when a peer that understands version=[1] that connects to a peer
        # that understands version=[1,2], they should pick version=1

        # the listening Tub will have the higher tubID, and thus make the
        # negotiation decision
        self.requireCrypto()
        url, portnum = self.makeSpecificServer(certData_high)
        # the client
        client = Tub(certData=certData_low)
        client.negotiationClass = NegotiationVbig
        client.startService()
        self.services.append(client)
        d = client.getReference(url)

        def _check_version(rref):
            ver = rref.tracker.broker._banana_decision_version
            self.failUnlessEqual(ver, MAX_HANDLED_VERSION)

        d.addCallback(_check_version)
        return d
Esempio n. 38
0
    def testTooFarInFuture1(self):
        # when a peer that understands version=[1] that connects to a peer
        # that only understands version=[2], they should fail to negotiate

        # the listening Tub will have the higher tubID, and thus make the
        # negotiation decision
        self.requireCrypto()
        url, portnum = self.makeSpecificServer(certData_high)
        # the client
        client = Tub(certData=certData_low)
        client.negotiationClass = NegotiationVbigOnly
        client.startService()
        self.services.append(client)
        d = client.getReference(url)

        def _oops_succeeded(rref):
            self.fail("hey! this is supposed to fail")

        def _check_failure(f):
            f.trap(tokens.NegotiationError, tokens.RemoteNegotiationError)

        d.addCallbacks(_oops_succeeded, _check_failure)
        return d