def test_set_location(self): t = GoodEnoughTub() t.listenOn("tcp:0") t.setServiceParent(self.s) t.setLocation("127.0.0.1:12345") # setLocation may only be called once self.failUnlessRaises(PBError, t.setLocation, "127.0.0.1:12345")
def test_set_location(self): t = GoodEnoughTub() t.listenOn("tcp:0") t.setServiceParent(self.s) t.setLocation("127.0.0.1:12345") # setLocation may only be called once self.failUnlessRaises(PBError, t.setLocation, "127.0.0.1:12345")
def test_unrouteable(self): # bug #129: a FURL with no location hints causes a synchronous # exception in Tub.getReference(), instead of an errback'ed Deferred. tubA = GoodEnoughTub() tubA.setServiceParent(self.s) tubB = GoodEnoughTub() tubB.setServiceParent(self.s) # "-unrouteable-" is interpreted as a "location hint format from the # future", which we're supposed to ignore, and are thus left with no # hints tubB.setLocation("-unrouteable-") r = Receiver(tubB) furl = tubB.registerReference(r) # the buggy behavior is that the following call raises an exception d = tubA.getReference(furl) # whereas it ought to return a Deferred self.failUnless(isinstance(d, defer.Deferred)) def _check(f): self.failUnless(isinstance(f, failure.Failure), f) self.failUnless(f.check(NoLocationHintsError), f) # unparseable FURL d.addBoth(_check) return d
def test_referenceables_die(self): # serialized data will not keep the referenceable alive t1 = GoodEnoughTub() t1.setServiceParent(self.s) l = t1.listenOn("tcp:0:interface=127.0.0.1") t1.setLocation("127.0.0.1:%d" % l.getPortnum()) r1 = Referenceable() t2 = GoodEnoughTub() t2.setServiceParent(self.s) obj = ("graph tangly", r1) d = t1.serialize(obj) del r1; del obj gc.collect() d.addCallback(lambda data: self.shouldFail(KeyError, "test_referenceables_die", "unable to find reference for name", t2.unserialize, data)) return d
def test_empty_location2(self): tubA = GoodEnoughTub() tubA.setServiceParent(self.s) tubB = GoodEnoughTub() tubB.setServiceParent(self.s) # "," is two empty locations. This passes the regexp, unlike "". tubB.setLocation(",") r = Receiver(tubB) furl = tubB.registerReference(r) # the buggy behavior is that the following call raises an exception d = tubA.getReference(furl) # whereas it ought to return a Deferred self.failUnless(isinstance(d, defer.Deferred)) def _check(f): self.failUnless(isinstance(f, failure.Failure), f) self.failUnless(f.check(NoLocationHintsError), f) # unparseable FURL d.addBoth(_check) return d
def test_set_location_automatically(self): t = GoodEnoughTub() l = t.listenOn("tcp:0") t.setServiceParent(self.s) d = t.setLocationAutomatically() d.addCallback(lambda res: t.registerReference(Referenceable())) def _check(furl): sr = SturdyRef(furl) portnum = l.getPortnum() if sr.encrypted: for lh in sr.locationHints: self.failUnlessEqual(lh[2], portnum, lh) self.failUnless( ("tcp", "127.0.0.1", portnum) in sr.locationHints) else: # TODO: unauthenticated tubs need review, I think they # deserve to have tubids and multiple connection hints pass d.addCallback(_check) return d
def test_empty_location(self): # bug #129: a FURL with no location hints causes a synchronous # exception in Tub.getReference(), instead of an errback'ed Deferred. tubA = GoodEnoughTub() tubA.setServiceParent(self.s) tubB = GoodEnoughTub() tubB.setServiceParent(self.s) tubB.setLocation("") # this is how you say "unrouteable" r = Receiver(tubB) furl = tubB.registerReference(r) # the buggy behavior is that the following call raises an exception d = tubA.getReference(furl) # whereas it ought to return a Deferred self.failUnless(isinstance(d, defer.Deferred)) def _check(f): self.failUnless(isinstance(f, failure.Failure), f) self.failUnless(f.check(NoLocationHintsError), f) d.addBoth(_check) return d
def test_empty_location2(self): tubA = GoodEnoughTub() tubA.setServiceParent(self.s) tubB = GoodEnoughTub() tubB.setServiceParent(self.s) # "," is two empty locations. This passes the regexp, unlike "". tubB.setLocation(",") r = Receiver(tubB) furl = tubB.registerReference(r) # the buggy behavior is that the following call raises an exception d = tubA.getReference(furl) # whereas it ought to return a Deferred self.failUnless(isinstance(d, defer.Deferred)) def _check(f): self.failUnless(isinstance(f, failure.Failure), f) self.failUnless(f.check(NoLocationHintsError), f) # unparseable FURL d.addBoth(_check) return d
def test_set_location_automatically(self): t = GoodEnoughTub() l = t.listenOn("tcp:0") t.setServiceParent(self.s) d = t.setLocationAutomatically() d.addCallback(lambda res: t.registerReference(Referenceable())) def _check(furl): sr = SturdyRef(furl) portnum = l.getPortnum() if sr.encrypted: for lh in sr.locationHints: self.failUnlessEqual(lh[2], portnum, lh) self.failUnless(("ipv4", "127.0.0.1", portnum) in sr.locationHints) else: # TODO: unauthenticated tubs need review, I think they # deserve to have tubids and multiple connection hints pass d.addCallback(_check) return d
def test_empty_location(self): # bug #129: a FURL with no location hints causes a synchronous # exception in Tub.getReference(), instead of an errback'ed Deferred. tubA = GoodEnoughTub() tubA.setServiceParent(self.s) tubB = GoodEnoughTub() tubB.setServiceParent(self.s) tubB.setLocation("") r = Receiver(tubB) furl = tubB.registerReference(r) # the buggy behavior is that the following call raises an exception d = tubA.getReference(furl) # whereas it ought to return a Deferred self.failUnless(isinstance(d, defer.Deferred)) def _check(f): self.failUnless(isinstance(f, failure.Failure), f) self.failUnless(f.check(ValueError), f) # unparseable FURL d.addBoth(_check) return d
def test_future(self): # bug #129: a FURL with no location hints causes a synchronous # exception in Tub.getReference(), instead of an errback'ed Deferred. tubA = GoodEnoughTub() tubA.setServiceParent(self.s) tubB = GoodEnoughTub() tubB.setServiceParent(self.s) # "future:stuff" is interpreted as a "location hint format from the # future", which we're supposed to ignore, and are thus left with no # hints tubB.setLocation("future:stuff") r = Receiver(tubB) furl = tubB.registerReference(r) # the buggy behavior is that the following call raises an exception d = tubA.getReference(furl) # whereas it ought to return a Deferred self.failUnless(isinstance(d, defer.Deferred)) def _check(f): self.failUnless(isinstance(f, failure.Failure), f) self.failUnless(f.check(NoLocationHintsError), f) d.addBoth(_check) return d
def test_referenceable(self): t1 = GoodEnoughTub() t1.setServiceParent(self.s) l = t1.listenOn("tcp:0:interface=127.0.0.1") t1.setLocation("127.0.0.1:%d" % l.getPortnum()) r1 = Referenceable() # the serialized blob can't keep the reference alive, so you must # arrange for that separately t1.registerReference(r1) t2 = GoodEnoughTub() t2.setServiceParent(self.s) obj = ("graph tangly", r1) d = t1.serialize(obj) del r1; del obj def _done(data): self.failUnless("their-reference" in data) return data d.addCallback(_done) d.addCallback(lambda data: t2.unserialize(data)) def _check(obj2): self.failUnlessEqual(obj2[0], "graph tangly") self.failUnless(isinstance(obj2[1], RemoteReference)) d.addCallback(_check) return d