예제 #1
0
 def createSpecificServer(self, certData,
                          negotiationClass=negotiate.Negotiation):
     tub = Tub(certData=certData)
     tub.negotiationClass = negotiationClass
     tub.startService()
     self.services.append(tub)
     l = tub.listenOn("tcp:0")
     tub.setLocation("127.0.0.1:%d" % l.getPortnum())
     target = Target()
     return tub, target, tub.registerReference(target), l.getPortnum()
예제 #2
0
 def createSpecificServer(self, certData,
                          negotiationClass=negotiate.Negotiation):
     tub = Tub(certData=certData)
     tub.negotiationClass = negotiationClass
     tub.startService()
     self.services.append(tub)
     l = tub.listenOn("tcp:0")
     tub.setLocation("127.0.0.1:%d" % l.getPortnum())
     target = Target()
     return tub, target, tub.registerReference(target), l.getPortnum()
예제 #3
0
파일: common.py 프로젝트: byrgazov/foolscap
 def createSpecificServer(self, certData,
                          negotiationClass=negotiate.Negotiation):
     tub = Tub(certData=certData)
     tub.negotiationClass = negotiationClass
     tub.startService()
     self.services.append(tub)
     portnum = allocate_tcp_port()
     tub.listenOn("tcp:%d:interface=127.0.0.1" % portnum)
     tub.setLocation("127.0.0.1:%d" % portnum)
     target = Target()
     return tub, target, tub.registerReference(target), portnum
예제 #4
0
 def createSpecificServer(self, certData,
                          negotiationClass=negotiate.Negotiation):
     tub = Tub(certData=certData)
     tub.negotiationClass = negotiationClass
     tub.startService()
     self.services.append(tub)
     portnum = allocate_tcp_port()
     tub.listenOn("tcp:%d:interface=127.0.0.1" % portnum)
     tub.setLocation("127.0.0.1:%d" % portnum)
     target = Target()
     return tub, target, tub.registerReference(target), portnum
예제 #5
0
 def testTooFarInFuture2(self):
     # same as before, but the connecting Tub will have the higher tubID,
     # and thus make the negotiation decision
     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
예제 #6
0
 def testFuture2(self):
     # same as before, but the connecting Tub will have the higher tubID,
     # and thus make the negotiation decision
     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
예제 #7
0
 def testTooFarInFuture2(self):
     # same as before, but the connecting Tub will have the higher tubID,
     # and thus make the negotiation decision
     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
예제 #8
0
 def testFuture2(self):
     # same as before, but the connecting Tub will have the higher tubID,
     # and thus make the negotiation decision
     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
예제 #9
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
        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
예제 #10
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
        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
예제 #11
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
        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
예제 #12
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
        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