Пример #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)
Пример #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)
Пример #3
0
    def test_id_collision(self):
        # test replacement case where tubid equals a keyid (one should
        # not replace the other)
        ic = IntroducerClient(None, "introducer.furl", u"my_nickname",
                              "my_version", "oldest_version", {})
        announcements = []
        ic.subscribe_to("storage",
                        lambda key_s, ann: announcements.append(ann))
        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")
        furl2 = "pb://%[email protected]:36106/swissnum" % keyid
        ann_t = ic.create_announcement("storage", make_ann(furl1), sk)
        ic.remote_announce_v2([ann_t])
        d = fireEventually()

        def _then(ign):
            # first announcement has been processed
            self.failUnlessEqual(len(announcements), 1)
            self.failUnlessEqual(announcements[0]["anonymous-storage-FURL"],
                                 furl1)
            # now submit a second one, with a tubid that happens to look just
            # like the pubkey-based serverid we just processed. They should
            # not overlap.
            ann2 = (furl2, "storage", "RIStorage", "nick1", "ver23", "ver0")
            ca = WrapV2ClientInV1Interface(ic)
            ca.remote_announce([ann2])
            return fireEventually()

        d.addCallback(_then)

        def _then2(ign):
            # if they overlapped, the second announcement would be ignored
            self.failUnlessEqual(len(announcements), 2)
            self.failUnlessEqual(announcements[1]["anonymous-storage-FURL"],
                                 furl2)

        d.addCallback(_then2)
        return d
Пример #4
0
 def test_id_collision(self):
     # test replacement case where tubid equals a keyid (one should
     # not replace the other)
     ic = IntroducerClient(None,
                           "introducer.furl", u"my_nickname",
                           "my_version", "oldest_version", {})
     announcements = []
     ic.subscribe_to("storage",
                     lambda key_s,ann: announcements.append(ann))
     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")
     furl2 = "pb://%[email protected]:36106/swissnum" % keyid
     ann_t = ic.create_announcement("storage", make_ann(furl1), sk)
     ic.remote_announce_v2([ann_t])
     d = fireEventually()
     def _then(ign):
         # first announcement has been processed
         self.failUnlessEqual(len(announcements), 1)
         self.failUnlessEqual(announcements[0]["anonymous-storage-FURL"],
                              furl1)
         # now submit a second one, with a tubid that happens to look just
         # like the pubkey-based serverid we just processed. They should
         # not overlap.
         ann2 = (furl2, "storage", "RIStorage", "nick1", "ver23", "ver0")
         ca = WrapV2ClientInV1Interface(ic)
         ca.remote_announce([ann2])
         return fireEventually()
     d.addCallback(_then)
     def _then2(ign):
         # if they overlapped, the second announcement would be ignored
         self.failUnlessEqual(len(announcements), 2)
         self.failUnlessEqual(announcements[1]["anonymous-storage-FURL"],
                              furl2)
     d.addCallback(_then2)
     return d