Ejemplo n.º 1
0
 def random_fsnode(self):
     coin = random.randrange(0, 3)
     if coin == 0:
         cap = uri.CHKFileURI(randutil.insecurerandstr(16),
                              randutil.insecurerandstr(32),
                              random.randrange(1, 5),
                              random.randrange(6, 15),
                              random.randrange(99, 1000000000000))
         return ImmutableFileNode(cap, None, None, None, None, None)
     elif coin == 1:
         cap = uri.WriteableSSKFileURI(randutil.insecurerandstr(16),
                                       randutil.insecurerandstr(32))
         n = MutableFileNode(None, None, encoding_parameters, None)
         return n.init_from_cap(cap)
     else:
         assert coin == 2
         cap = uri.WriteableSSKFileURI(randutil.insecurerandstr(16),
                                       randutil.insecurerandstr(32))
         n = MutableFileNode(None, None, encoding_parameters, None)
         n.init_from_cap(cap)
         return dirnode.DirectoryNode(n, self.nodemaker, uploader=None)
Ejemplo n.º 2
0
 def test_chk_filenode(self):
     u = uri.CHKFileURI(key="\x00" * 16,
                        uri_extension_hash="\x00" * 32,
                        needed_shares=3,
                        total_shares=10,
                        size=1000)
     fn1 = ImmutableFileNode(u, None, None, None, None)
     fn2 = ImmutableFileNode(u, None, None, None, None)
     self.failUnlessEqual(fn1, fn2)
     self.failIfEqual(fn1, "I am not a filenode")
     self.failIfEqual(fn1, NotANode())
     self.failUnlessEqual(fn1.get_uri(), u.to_string())
     self.failUnlessEqual(fn1.get_cap(), u)
     self.failUnlessEqual(fn1.get_readcap(), u)
     self.failUnless(fn1.is_readonly())
     self.failIf(fn1.is_mutable())
     self.failIf(fn1.is_unknown())
     self.failUnless(fn1.is_allowed_in_immutable_directory())
     self.failUnlessEqual(fn1.get_write_uri(), None)
     self.failUnlessEqual(fn1.get_readonly_uri(), u.to_string())
     self.failUnlessEqual(fn1.get_size(), 1000)
     self.failUnlessEqual(fn1.get_storage_index(), u.get_storage_index())
     fn1.raise_error()
     fn2.raise_error()
     d = {}
     d[fn1] = 1  # exercise __hash__
     v = fn1.get_verify_cap()
     self.failUnless(isinstance(v, uri.CHKFileVerifierURI))
     self.failUnlessEqual(fn1.get_repair_cap(), v)
     self.failUnless(v.is_readonly())
     self.failIf(v.is_mutable())
Ejemplo n.º 3
0
 def _create_immutable(self, cap):
     return ImmutableFileNode(cap, self.storage_broker, self.secret_holder,
                              self.terminator, self.history)
Ejemplo n.º 4
0
 def test_chk_filenode(self):
     u = uri.CHKFileURI(key="\x00"*16,
                        uri_extension_hash="\x00"*32,
                        needed_shares=3,
                        total_shares=10,
                        size=1000)
     fn1 = ImmutableFileNode(u, None, None, None, None)
     fn2 = ImmutableFileNode(u, None, None, None, None)
     self.failUnlessEqual(fn1, fn2)
     self.failIfEqual(fn1, "I am not a filenode")
     self.failIfEqual(fn1, NotANode())
     self.failUnlessEqual(fn1.get_uri(), u.to_string())
     self.failUnlessEqual(fn1.get_cap(), u)
     self.failUnlessEqual(fn1.get_readcap(), u)
     self.failUnless(fn1.is_readonly())
     self.failIf(fn1.is_mutable())
     self.failIf(fn1.is_unknown())
     self.failUnless(fn1.is_allowed_in_immutable_directory())
     self.failUnlessEqual(fn1.get_write_uri(), None)
     self.failUnlessEqual(fn1.get_readonly_uri(), u.to_string())
     self.failUnlessEqual(fn1.get_size(), 1000)
     self.failUnlessEqual(fn1.get_storage_index(), u.get_storage_index())
     fn1.raise_error()
     fn2.raise_error()
     d = {}
     d[fn1] = 1 # exercise __hash__
     v = fn1.get_verify_cap()
     self.failUnless(isinstance(v, uri.CHKFileVerifierURI))
     self.failUnlessEqual(fn1.get_repair_cap(), v)
     self.failUnless(v.is_readonly())
     self.failIf(v.is_mutable())