from foolscap.api import eventually
from allmydata.interfaces import IMutableFileNode, ICheckable, ICheckResults, \
NotEnoughSharesError, MDMF_VERSION, SDMF_VERSION, IMutableUploadable, \
- IMutableFileVersion, IWritable
+ IMutableFileVersion, IWriteable
from allmydata.util import hashutil, log, consumer, deferredutil, mathutil
from allmydata.util.assertutil import precondition
from allmydata.uri import WriteableSSKFileURI, ReadonlySSKFileURI, \
- WritableMDMFFileURI, ReadonlyMDMFFileURI
+ WriteableMDMFFileURI, ReadonlyMDMFFileURI
from allmydata.monitor import Monitor
from pycryptopp.cipher.aes import AES
# verification key, nor things like 'k' or 'N'. If and when someone
# wants to get our contents, we'll pull from shares and fill those
# in.
- if isinstance(filecap, (WritableMDMFFileURI, ReadonlyMDMFFileURI)):
+ if isinstance(filecap, (WriteableMDMFFileURI, ReadonlyMDMFFileURI)):
self._protocol_version = MDMF_VERSION
elif isinstance(filecap, (ReadonlySSKFileURI, WriteableSSKFileURI)):
self._protocol_version = SDMF_VERSION
self._encprivkey = self._encrypt_privkey(self._writekey, privkey_s)
self._fingerprint = hashutil.ssk_pubkey_fingerprint_hash(pubkey_s)
if version == MDMF_VERSION:
- self._uri = WritableMDMFFileURI(self._writekey, self._fingerprint)
+ self._uri = WriteableMDMFFileURI(self._writekey, self._fingerprint)
self._protocol_version = version
elif version == SDMF_VERSION:
self._uri = WriteableSSKFileURI(self._writekey, self._fingerprint)
overwrite or modify the contents of the mutable file that I
reference.
"""
- implements(IMutableFileVersion, IWritable)
+ implements(IMutableFileVersion, IWriteable)
def __init__(self,
node,
def init_from_cap(self, filecap):
assert isinstance(filecap, (uri.WriteableSSKFileURI,
uri.ReadonlySSKFileURI,
- uri.WritableMDMFFileURI,
+ uri.WriteableMDMFFileURI,
uri.ReadonlyMDMFFileURI))
self.my_uri = filecap
self.storage_index = self.my_uri.get_storage_index()
- if isinstance(filecap, (uri.WritableMDMFFileURI,
+ if isinstance(filecap, (uri.WriteableMDMFFileURI,
uri.ReadonlyMDMFFileURI)):
self.file_types[self.storage_index] = MDMF_VERSION
def get_best_mutable_version(self):
return defer.succeed(self)
- # Ditto for this, which is an implementation of IWritable.
+ # Ditto for this, which is an implementation of IWriteable.
# XXX: Declare that the same is implemented.
def update(self, data, offset):
assert not self.is_readonly()
fingerprint=os.urandom(32))
def make_mdmf_mutable_file_cap():
- return uri.WritableMDMFFileURI(writekey=os.urandom(16),
+ return uri.WriteableMDMFFileURI(writekey=os.urandom(16),
fingerprint=os.urandom(32))
def make_mutable_file_uri(mdmf=False):
def test_writable_mdmf_cap(self):
- u1 = uri.WritableMDMFFileURI(self.writekey, self.fingerprint)
+ u1 = uri.WriteableMDMFFileURI(self.writekey, self.fingerprint)
cap = u1.to_string()
- u = uri.WritableMDMFFileURI.init_from_string(cap)
+ u = uri.WriteableMDMFFileURI.init_from_string(cap)
self.failUnless(IMutableFileURI.providedBy(u))
self.failUnlessReallyEqual(u.fingerprint, self.fingerprint)
u1 = uri.ReadonlyMDMFFileURI(self.readkey, self.fingerprint)
cap = u1.to_string()
self.failUnlessRaises(uri.BadURIError,
- uri.WritableMDMFFileURI.init_from_string,
+ uri.WriteableMDMFFileURI.init_from_string,
cap)
def test_create_writable_mdmf_cap_from_verifycap(self):
u1 = uri.MDMFVerifierURI(self.storage_index, self.fingerprint)
cap = u1.to_string()
self.failUnlessRaises(uri.BadURIError,
- uri.WritableMDMFFileURI.init_from_string,
+ uri.WriteableMDMFFileURI.init_from_string,
cap)
def test_create_readonly_mdmf_cap_from_verifycap(self):
def test_mdmf_cap_extra_information(self):
# MDMF caps can be arbitrarily extended after the fingerprint
# and key/storage index fields.
- u1 = uri.WritableMDMFFileURI(self.writekey, self.fingerprint)
+ u1 = uri.WriteableMDMFFileURI(self.writekey, self.fingerprint)
self.failUnlessEqual([], u1.get_extension_params())
cap = u1.to_string()
cap += (":%s" % e)
expected_extensions.append(e)
- u2 = uri.WritableMDMFFileURI.init_from_string(cap)
+ u2 = uri.WriteableMDMFFileURI.init_from_string(cap)
self.failUnlessReallyEqual(self.writekey, u2.writekey)
self.failUnlessReallyEqual(self.fingerprint, u2.fingerprint)
self.failIf(u2.is_readonly())
self.failUnless(u2.is_mutable())
c2 = u2.to_string()
- u2n = uri.WritableMDMFFileURI.init_from_string(c2)
+ u2n = uri.WriteableMDMFFileURI.init_from_string(c2)
self.failUnlessReallyEqual(u2, u2n)
# We should get the extra back when we ask for it.
def test_extension_character_range(self):
# As written now, we shouldn't put things other than numbers in
# the extension fields.
- writecap = uri.WritableMDMFFileURI(self.writekey, self.fingerprint).to_string()
+ writecap = uri.WriteableMDMFFileURI(self.writekey, self.fingerprint).to_string()
readcap = uri.ReadonlyMDMFFileURI(self.readkey, self.fingerprint).to_string()
vcap = uri.MDMFVerifierURI(self.storage_index, self.fingerprint).to_string()
self.failUnlessRaises(uri.BadURIError,
- uri.WritableMDMFFileURI.init_from_string,
+ uri.WriteableMDMFFileURI.init_from_string,
("%s:invalid" % writecap))
self.failUnlessRaises(uri.BadURIError,
uri.ReadonlyMDMFFileURI.init_from_string,
# With a cap on the end. For each of the cap types, we need to
# test that a valid cap (with and without the traditional
# separators) is recognized and accepted by the classes.
- w1 = uri.WritableMDMFFileURI(self.writekey, self.fingerprint)
- w2 = uri.WritableMDMFFileURI(self.writekey, self.fingerprint,
+ w1 = uri.WriteableMDMFFileURI(self.writekey, self.fingerprint)
+ w2 = uri.WriteableMDMFFileURI(self.writekey, self.fingerprint,
['131073', '3'])
r1 = uri.ReadonlyMDMFFileURI(self.readkey, self.fingerprint)
r2 = uri.ReadonlyMDMFFileURI(self.readkey, self.fingerprint,
# With a cap on the end. For each of the cap types, we need to
# test that a valid cap (with and without the traditional
# separators) is recognized and accepted by the classes.
- w1 = uri.WritableMDMFFileURI(self.writekey, self.fingerprint)
- w2 = uri.WritableMDMFFileURI(self.writekey, self.fingerprint,
+ w1 = uri.WriteableMDMFFileURI(self.writekey, self.fingerprint)
+ w2 = uri.WriteableMDMFFileURI(self.writekey, self.fingerprint,
['131073', '3'])
r1 = uri.ReadonlyMDMFFileURI(self.readkey, self.fingerprint)
r2 = uri.ReadonlyMDMFFileURI(self.readkey, self.fingerprint,
# With a cap on the end. For each of the cap types, we need to
# test that a valid cap (with and without the traditional
# separators) is recognized and accepted by the classes.
- w1 = uri.WritableMDMFFileURI(self.writekey, self.fingerprint)
- w2 = uri.WritableMDMFFileURI(self.writekey, self.fingerprint,
+ w1 = uri.WriteableMDMFFileURI(self.writekey, self.fingerprint)
+ w2 = uri.WriteableMDMFFileURI(self.writekey, self.fingerprint,
['131073', '3'])
r1 = uri.ReadonlyMDMFFileURI(self.readkey, self.fingerprint)
r2 = uri.ReadonlyMDMFFileURI(self.readkey, self.fingerprint,
def test_mdmf_from_string(self):
# Make sure that the from_string utility function works with
# MDMF caps.
- u1 = uri.WritableMDMFFileURI(self.writekey, self.fingerprint)
+ u1 = uri.WriteableMDMFFileURI(self.writekey, self.fingerprint)
cap = u1.to_string()
self.failUnless(uri.is_uri(cap))
u2 = uri.from_string(cap)
self.failUnlessEqual(u3, u1)
# XXX: We should refactor the extension field into setUp
- u1 = uri.WritableMDMFFileURI(self.writekey, self.fingerprint,
+ u1 = uri.WriteableMDMFFileURI(self.writekey, self.fingerprint,
['131073', '3'])
cap = u1.to_string()
self.failUnless(uri.is_uri(cap))
def test_mdmf(self):
writekey = "\x01" * 16
fingerprint = "\x02" * 32
- uri1 = uri.WritableMDMFFileURI(writekey, fingerprint)
+ uri1 = uri.WriteableMDMFFileURI(writekey, fingerprint)
d1 = uri.MDMFDirectoryURI(uri1)
self.failIf(d1.is_readonly())
self.failUnless(d1.is_mutable())
def test_mdmf_with_extensions(self):
writekey = "\x01" * 16
fingerprint = "\x02" * 32
- uri1 = uri.WritableMDMFFileURI(writekey, fingerprint)
+ uri1 = uri.WriteableMDMFFileURI(writekey, fingerprint)
d1 = uri.MDMFDirectoryURI(uri1)
d1_uri = d1.to_string()
# Add some extensions, verify that the URI is interpreted
writekey = "\x01" * 16
fingerprint = "\x02" * 32
- uri1 = uri.WritableMDMFFileURI(writekey, fingerprint)
+ uri1 = uri.WriteableMDMFFileURI(writekey, fingerprint)
d1 = uri.MDMFDirectoryURI(uri1)
self.failUnless(d1.is_mutable())
self.failIf(d1.is_readonly())
# I'm not sure what I want to write here yet.
writekey = "\x01" * 16
fingerprint = "\x02" * 32
- uri1 = uri.WritableMDMFFileURI(writekey, fingerprint)
+ uri1 = uri.WriteableMDMFFileURI(writekey, fingerprint)
d1 = uri.MDMFDirectoryURI(uri1)
v1 = d1.get_verify_cap()
self.failUnlessIsInstance(v1, uri.MDMFDirectoryURIVerifier)
def set_extension_params(self, params):
pass
-class WritableMDMFFileURI(_BaseURI):
+class WriteableMDMFFileURI(_BaseURI):
implements(IURI, IMutableFileURI)
BASE_STRING='URI:MDMF:'
BASE_STRING='URI:DIR2-MDMF:'
BASE_STRING_RE=re.compile('^'+BASE_STRING)
BASE_HUMAN_RE=re.compile('^'+OPTIONALHTTPLEAD+'URI'+SEP+'DIR2-MDMF'+SEP)
- INNER_URI_CLASS=WritableMDMFFileURI
+ INNER_URI_CLASS=WriteableMDMFFileURI
def __init__(self, filenode_uri=None):
if filenode_uri:
return ImmutableDirectoryURI(filecap)
if isinstance(filecap, LiteralFileURI):
return LiteralDirectoryURI(filecap)
- if isinstance(filecap, WritableMDMFFileURI):
+ if isinstance(filecap, WriteableMDMFFileURI):
return MDMFDirectoryURI(filecap)
if isinstance(filecap, ReadonlyMDMFFileURI):
return ReadonlyMDMFDirectoryURI(filecap)
elif s.startswith('URI:SSK-Verifier:'):
return SSKVerifierURI.init_from_string(s)
elif s.startswith('URI:MDMF:'):
- return WritableMDMFFileURI.init_from_string(s)
+ return WriteableMDMFFileURI.init_from_string(s)
elif s.startswith('URI:MDMF-RO:'):
return ReadonlyMDMFFileURI.init_from_string(s)
elif s.startswith('URI:MDMF-Verifier:'):