def test_static_servers(self):
        broker = StorageFarmBroker(True, lambda h: Mock())

        key_s = 'v0-1234-1'
        servers_yaml = """\
storage:
  v0-1234-1:
    ann:
      anonymous-storage-FURL: pb://ge@nowhere/fake
      permutation-seed-base32: aaaaaaaaaaaaaaaaaaaaaaaa
"""
        servers = yamlutil.safe_load(servers_yaml)
        permseed = base32.a2b("aaaaaaaaaaaaaaaaaaaaaaaa")
        broker.set_static_servers(servers["storage"])
        self.failUnlessEqual(len(broker._static_server_ids), 1)
        s = broker.servers[key_s]
        self.failUnlessEqual(s.announcement,
                             servers["storage"]["v0-1234-1"]["ann"])
        self.failUnlessEqual(s.get_serverid(), key_s)
        self.assertEqual(s.get_permutation_seed(), permseed)

        # if the Introducer announces the same thing, we're supposed to
        # ignore it

        ann2 = {
            "service-name": "storage",
            "anonymous-storage-FURL": "pb://{}@nowhere/fake2".format(base32.b2a(str(1))),
            "permutation-seed-base32": "bbbbbbbbbbbbbbbbbbbbbbbb",
        }
        broker._got_announcement(key_s, ann2)
        s2 = broker.servers[key_s]
        self.assertIdentical(s2, s)
        self.assertEqual(s2.get_permutation_seed(), permseed)
 def test_static_permutation_seed_pubkey(self):
     broker = StorageFarmBroker(True, lambda h: Mock())
     server_id = "v0-4uazse3xb6uu5qpkb7tel2bm6bpea4jhuigdhqcuvvse7hugtsia"
     k = "4uazse3xb6uu5qpkb7tel2bm6bpea4jhuigdhqcuvvse7hugtsia"
     ann = {
         "anonymous-storage-FURL": "pb://abcde@nowhere/fake",
     }
     broker.set_static_servers({server_id.decode("ascii"): {"ann": ann}})
     s = broker.servers[server_id]
     self.assertEqual(s.get_permutation_seed(), base32.a2b(k))
 def test_static_permutation_seed_hashed(self):
     broker = StorageFarmBroker(True, lambda h: Mock())
     server_id = "unparseable"
     ann = {
         "anonymous-storage-FURL": "pb://abcde@nowhere/fake",
     }
     broker.set_static_servers({server_id.decode("ascii"): {"ann": ann}})
     s = broker.servers[server_id]
     self.assertEqual(s.get_permutation_seed(),
                      hashlib.sha256(server_id).digest())
Exemple #4
0
 def test_static_permutation_seed_pubkey(self):
     broker = StorageFarmBroker(True, lambda h: Mock())
     server_id = "v0-4uazse3xb6uu5qpkb7tel2bm6bpea4jhuigdhqcuvvse7hugtsia"
     k = "4uazse3xb6uu5qpkb7tel2bm6bpea4jhuigdhqcuvvse7hugtsia"
     ann = {
         "anonymous-storage-FURL": "pb://abcde@nowhere/fake",
     }
     broker.set_static_servers({server_id.decode("ascii"): {"ann": ann}})
     s = broker.servers[server_id]
     self.assertEqual(s.get_permutation_seed(), base32.a2b(k))
Exemple #5
0
 def test_static_permutation_seed_hashed(self):
     broker = StorageFarmBroker(True, lambda h: Mock())
     server_id = "unparseable"
     ann = {
         "anonymous-storage-FURL": "pb://abcde@nowhere/fake",
     }
     broker.set_static_servers({server_id.decode("ascii"): {"ann": ann}})
     s = broker.servers[server_id]
     self.assertEqual(s.get_permutation_seed(),
                      hashlib.sha256(server_id).digest())
 def test_static_permutation_seed_explicit(self):
     broker = StorageFarmBroker(True, lambda h: Mock())
     server_id = "v0-4uazse3xb6uu5qpkb7tel2bm6bpea4jhuigdhqcuvvse7hugtsia"
     k = "w5gl5igiexhwmftwzhai5jy2jixn7yx7"
     ann = {
         "anonymous-storage-FURL": "pb://abcde@nowhere/fake",
         "permutation-seed-base32": k,
     }
     broker.set_static_servers({server_id.decode("ascii"): {"ann": ann}})
     s = broker.servers[server_id]
     self.assertEqual(s.get_permutation_seed(), base32.a2b(k))
Exemple #7
0
 def test_static_permutation_seed_explicit(self):
     broker = StorageFarmBroker(True, lambda h: Mock())
     server_id = "v0-4uazse3xb6uu5qpkb7tel2bm6bpea4jhuigdhqcuvvse7hugtsia"
     k = "w5gl5igiexhwmftwzhai5jy2jixn7yx7"
     ann = {
         "anonymous-storage-FURL": "pb://abcde@nowhere/fake",
         "permutation-seed-base32": k,
     }
     broker.set_static_servers({server_id.decode("ascii"): {"ann": ann}})
     s = broker.servers[server_id]
     self.assertEqual(s.get_permutation_seed(), base32.a2b(k))
Exemple #8
0
    def test_static_servers(self):
        broker = StorageFarmBroker(True, lambda h: Mock())

        key_s = 'v0-1234-1'
        servers_yaml = """\
storage:
  v0-1234-1:
    ann:
      anonymous-storage-FURL: pb://ge@nowhere/fake
      permutation-seed-base32: aaaaaaaaaaaaaaaaaaaaaaaa
"""
        servers = yamlutil.safe_load(servers_yaml)
        permseed = base32.a2b("aaaaaaaaaaaaaaaaaaaaaaaa")
        broker.set_static_servers(servers["storage"])
        self.failUnlessEqual(len(broker._static_server_ids), 1)
        s = broker.servers[key_s]
        self.failUnlessEqual(s.announcement,
                             servers["storage"]["v0-1234-1"]["ann"])
        self.failUnlessEqual(s.get_serverid(), key_s)
        self.assertEqual(s.get_permutation_seed(), permseed)

        # if the Introducer announces the same thing, we're supposed to
        # ignore it

        ann2 = {
            "service-name":
            "storage",
            "anonymous-storage-FURL":
            "pb://{}@nowhere/fake2".format(base32.b2a(str(1))),
            "permutation-seed-base32":
            "bbbbbbbbbbbbbbbbbbbbbbbb",
        }
        broker._got_announcement(key_s, ann2)
        s2 = broker.servers[key_s]
        self.assertIdentical(s2, s)
        self.assertEqual(s2.get_permutation_seed(), permseed)