Example #1
0
    def test_id_collision(self):
        # test replacement case where tubid equals a keyid (one should
        # not replace the other)
        i = IntroducerService()
        ic = IntroducerClient(None,
                              "introducer.furl", u"my_nickname",
                              "my_version", "oldest_version", {})
        sk_s, vk_s = keyutil.make_keypair()
        sk, _ignored = keyutil.parse_privkey(sk_s)
        keyid = keyutil.remove_prefix(vk_s, "pub-v0-")
        furl1 = "pb://[email protected]:123/short" # base32("short")
        ann_t = ic.create_announcement("storage", make_ann(furl1), sk)
        i.remote_publish_v2(ann_t, Referenceable())
        announcements = i.get_announcements()
        self.failUnlessEqual(len(announcements), 1)
        key1 = ("storage", "v0-"+keyid, None)
        self.failUnlessEqual(announcements[0].index, key1)
        ann1_out = announcements[0].announcement
        self.failUnlessEqual(ann1_out["anonymous-storage-FURL"], furl1)

        furl2 = "pb://%[email protected]:36106/swissnum" % keyid
        ann2 = (furl2, "storage", "RIStorage", "nick1", "ver23", "ver0")
        i.remote_publish(ann2)
        announcements = i.get_announcements()
        self.failUnlessEqual(len(announcements), 2)
        key2 = ("storage", None, keyid)
        wanted = [ad for ad in announcements if ad.index == key2]
        self.failUnlessEqual(len(wanted), 1)
        ann2_out = wanted[0].announcement
        self.failUnlessEqual(ann2_out["anonymous-storage-FURL"], furl2)
Example #2
0
    def test_id_collision(self):
        # test replacement case where tubid equals a keyid (one should
        # not replace the other)
        i = IntroducerService()
        ic = IntroducerClient(None, "introducer.furl", u"my_nickname",
                              "my_version", "oldest_version", {})
        sk_s, vk_s = keyutil.make_keypair()
        sk, _ignored = keyutil.parse_privkey(sk_s)
        keyid = keyutil.remove_prefix(vk_s, "pub-v0-")
        furl1 = "pb://[email protected]:123/short"  # base32("short")
        ann_t = ic.create_announcement("storage", make_ann(furl1), sk)
        i.remote_publish_v2(ann_t, Referenceable())
        announcements = i.get_announcements()
        self.failUnlessEqual(len(announcements), 1)
        key1 = ("storage", "v0-" + keyid, None)
        self.failUnlessEqual(announcements[0].index, key1)
        ann1_out = announcements[0].announcement
        self.failUnlessEqual(ann1_out["anonymous-storage-FURL"], furl1)

        furl2 = "pb://%[email protected]:36106/swissnum" % keyid
        ann2 = (furl2, "storage", "RIStorage", "nick1", "ver23", "ver0")
        i.remote_publish(ann2)
        announcements = i.get_announcements()
        self.failUnlessEqual(len(announcements), 2)
        key2 = ("storage", None, keyid)
        wanted = [ad for ad in announcements if ad.index == key2]
        self.failUnlessEqual(len(wanted), 1)
        ann2_out = wanted[0].announcement
        self.failUnlessEqual(ann2_out["anonymous-storage-FURL"], furl2)
Example #3
0
    def test_client_v1(self):
        introducer = IntroducerService()

        furl1 = "pb://[email protected]:0/swissnum"
        tubid = "62ubehyunnyhzs7r6vdonnm2hpi52w6y"
        ann = (furl1, "storage", "RIStorage",
               u"nick-v1".encode("utf-8"), "my_version", "oldest")
        introducer.remote_publish(ann)

        a = introducer.get_announcements()
        self.failUnlessEqual(len(a), 1)
        self.failUnlessEqual(a[0].index, ("storage", None, tubid))
        self.failUnlessEqual(a[0].canary, None)
        self.failUnlessEqual(a[0].announcement["app-versions"], {})
        self.failUnlessEqual(a[0].nickname, u"nick-v1".encode("utf-8"))
        self.failUnlessEqual(a[0].service_name, "storage")
        self.failUnlessEqual(a[0].version, "my_version")
        self.failUnlessEqual(a[0].announcement["anonymous-storage-FURL"], furl1)
Example #4
0
    def test_client_v1(self):
        introducer = IntroducerService()

        furl1 = "pb://[email protected]:0/swissnum"
        tubid = "62ubehyunnyhzs7r6vdonnm2hpi52w6y"
        ann = (furl1, "storage", "RIStorage", u"nick-v1".encode("utf-8"),
               "my_version", "oldest")
        introducer.remote_publish(ann)

        a = introducer.get_announcements()
        self.failUnlessEqual(len(a), 1)
        self.failUnlessEqual(a[0].index, ("storage", None, tubid))
        self.failUnlessEqual(a[0].canary, None)
        self.failUnlessEqual(a[0].announcement["app-versions"], {})
        self.failUnlessEqual(a[0].nickname, u"nick-v1".encode("utf-8"))
        self.failUnlessEqual(a[0].service_name, "storage")
        self.failUnlessEqual(a[0].version, "my_version")
        self.failUnlessEqual(a[0].announcement["anonymous-storage-FURL"],
                             furl1)
Example #5
0
    def test_client_v1(self):
        introducer = IntroducerService()
        subscriber = FakeRemoteReference()
        introducer.remote_subscribe(subscriber, "storage")
        # the v1 subscribe interface had no subscriber_info: that was usually
        # sent in a separate stub_client pseudo-announcement
        subs = introducer.get_subscribers()
        self.failUnlessEqual(len(subs), 1)
        s0 = subs[0]
        self.failUnlessEqual(s0.nickname, u"?") # not known yet
        self.failUnlessEqual(s0.service_name, "storage")

        # now submit the stub_client announcement
        furl1 = "pb://[email protected]:0/swissnum"
        ann = (furl1, "stub_client", "RIStubClient",
               (NICKNAME % u"v1").encode("utf-8"), "my_version", "oldest")
        introducer.remote_publish(ann)
        # the server should correlate the two
        subs = introducer.get_subscribers()
        self.failUnlessEqual(len(subs), 1)
        s0 = subs[0]
        self.failUnlessEqual(s0.service_name, "storage")
        # v1 announcements do not contain app-versions
        self.failUnlessEqual(s0.app_versions, {})
        self.failUnlessEqual(s0.nickname, NICKNAME % u"v1")
        self.failUnlessEqual(s0.version, "my_version")

        # a subscription that arrives after the stub_client announcement
        # should be correlated too
        subscriber2 = FakeRemoteReference()
        introducer.remote_subscribe(subscriber2, "thing2")

        subs = introducer.get_subscribers()
        self.failUnlessEqual(len(subs), 2)
        s0 = [s for s in subs if s.service_name == "thing2"][0]
        # v1 announcements do not contain app-versions
        self.failUnlessEqual(s0.app_versions, {})
        self.failUnlessEqual(s0.nickname, NICKNAME % u"v1")
        self.failUnlessEqual(s0.version, "my_version")
Example #6
0
    def test_client_v1(self):
        introducer = IntroducerService()
        subscriber = FakeRemoteReference()
        introducer.remote_subscribe(subscriber, "storage")
        # the v1 subscribe interface had no subscriber_info: that was usually
        # sent in a separate stub_client pseudo-announcement
        subs = introducer.get_subscribers()
        self.failUnlessEqual(len(subs), 1)
        s0 = subs[0]
        self.failUnlessEqual(s0.nickname, u"?")  # not known yet
        self.failUnlessEqual(s0.service_name, "storage")

        # now submit the stub_client announcement
        furl1 = "pb://[email protected]:0/swissnum"
        ann = (furl1, "stub_client", "RIStubClient",
               (NICKNAME % u"v1").encode("utf-8"), "my_version", "oldest")
        introducer.remote_publish(ann)
        # the server should correlate the two
        subs = introducer.get_subscribers()
        self.failUnlessEqual(len(subs), 1)
        s0 = subs[0]
        self.failUnlessEqual(s0.service_name, "storage")
        # v1 announcements do not contain app-versions
        self.failUnlessEqual(s0.app_versions, {})
        self.failUnlessEqual(s0.nickname, NICKNAME % u"v1")
        self.failUnlessEqual(s0.version, "my_version")

        # a subscription that arrives after the stub_client announcement
        # should be correlated too
        subscriber2 = FakeRemoteReference()
        introducer.remote_subscribe(subscriber2, "thing2")

        subs = introducer.get_subscribers()
        self.failUnlessEqual(len(subs), 2)
        s0 = [s for s in subs if s.service_name == "thing2"][0]
        # v1 announcements do not contain app-versions
        self.failUnlessEqual(s0.app_versions, {})
        self.failUnlessEqual(s0.nickname, NICKNAME % u"v1")
        self.failUnlessEqual(s0.version, "my_version")
Example #7
0
 def test_duplicate(self):
     i = IntroducerService()
     self.failUnlessEqual(len(i.get_announcements()), 0)
     self.failUnlessEqual(len(i.get_subscribers()), 0)
     furl1 = "pb://[email protected]:36106,127.0.0.1:36106/gydnpigj2ja2qr2srq4ikjwnl7xfgbra"
     furl2 = "pb://[email protected]:36111,127.0.0.1:36106/ttwwoogj2ja2qr2srq4ikjwnl7xfgbra"
     ann1 = (furl1, "storage", "RIStorage", "nick1", "ver23", "ver0")
     ann1b = (furl1, "storage", "RIStorage", "nick1", "ver24", "ver0")
     ann2 = (furl2, "storage", "RIStorage", "nick2", "ver30", "ver0")
     i.remote_publish(ann1)
     self.failUnlessEqual(len(i.get_announcements()), 1)
     self.failUnlessEqual(len(i.get_subscribers()), 0)
     i.remote_publish(ann2)
     self.failUnlessEqual(len(i.get_announcements()), 2)
     self.failUnlessEqual(len(i.get_subscribers()), 0)
     i.remote_publish(ann1b)
     self.failUnlessEqual(len(i.get_announcements()), 2)
     self.failUnlessEqual(len(i.get_subscribers()), 0)
Example #8
0
 def test_duplicate(self):
     i = IntroducerService()
     self.failUnlessEqual(len(i.get_announcements()), 0)
     self.failUnlessEqual(len(i.get_subscribers()), 0)
     furl1 = "pb://[email protected]:36106,127.0.0.1:36106/gydnpigj2ja2qr2srq4ikjwnl7xfgbra"
     furl2 = "pb://[email protected]:36111,127.0.0.1:36106/ttwwoogj2ja2qr2srq4ikjwnl7xfgbra"
     ann1 = (furl1, "storage", "RIStorage", "nick1", "ver23", "ver0")
     ann1b = (furl1, "storage", "RIStorage", "nick1", "ver24", "ver0")
     ann2 = (furl2, "storage", "RIStorage", "nick2", "ver30", "ver0")
     i.remote_publish(ann1)
     self.failUnlessEqual(len(i.get_announcements()), 1)
     self.failUnlessEqual(len(i.get_subscribers()), 0)
     i.remote_publish(ann2)
     self.failUnlessEqual(len(i.get_announcements()), 2)
     self.failUnlessEqual(len(i.get_subscribers()), 0)
     i.remote_publish(ann1b)
     self.failUnlessEqual(len(i.get_announcements()), 2)
     self.failUnlessEqual(len(i.get_subscribers()), 0)