mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-04-25 05:19:53 +00:00
created DirnodeURI schema
This commit is contained in:
parent
b32a0d10ca
commit
33bae16ed2
@ -13,6 +13,7 @@ Nodeid = StringConstraint(maxLength=20,
|
|||||||
FURL = StringConstraint(1000)
|
FURL = StringConstraint(1000)
|
||||||
StorageIndex = StringConstraint(16)
|
StorageIndex = StringConstraint(16)
|
||||||
URI = StringConstraint(300) # kind of arbitrary
|
URI = StringConstraint(300) # kind of arbitrary
|
||||||
|
DirnodeURI = StringConstraint(300, regexp=r'^URI:DIR(-RO)?:pb://[a-z0-9]+@[^/]+/[^:]+:[a-z0-9]+$')
|
||||||
MAX_BUCKETS = 200 # per peer
|
MAX_BUCKETS = 200 # per peer
|
||||||
ShareData = StringConstraint(400000) # 1MB segment / k=3 = 334kB
|
ShareData = StringConstraint(400000) # 1MB segment / k=3 = 334kB
|
||||||
URIExtensionData = StringConstraint(1000)
|
URIExtensionData = StringConstraint(1000)
|
||||||
@ -228,7 +229,7 @@ class RIVirtualDriveServer(RemoteInterface):
|
|||||||
|
|
||||||
If this vdrive server does not offer a public root, this will
|
If this vdrive server does not offer a public root, this will
|
||||||
raise an exception."""
|
raise an exception."""
|
||||||
return URI
|
return DirnodeURI
|
||||||
|
|
||||||
def create_directory(index=Hash, write_enabler=Hash):
|
def create_directory(index=Hash, write_enabler=Hash):
|
||||||
"""Create a new (empty) directory, unattached to anything else.
|
"""Create a new (empty) directory, unattached to anything else.
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
from twisted.trial import unittest
|
from twisted.trial import unittest
|
||||||
from allmydata import uri
|
from allmydata import uri
|
||||||
from allmydata.util import hashutil
|
from allmydata.util import hashutil
|
||||||
from allmydata.interfaces import IURI, IFileURI, IDirnodeURI
|
from allmydata.interfaces import IURI, IFileURI, IDirnodeURI, DirnodeURI
|
||||||
|
from foolscap.schema import Violation
|
||||||
|
|
||||||
class Literal(unittest.TestCase):
|
class Literal(unittest.TestCase):
|
||||||
def _help_test(self, data):
|
def _help_test(self, data):
|
||||||
@ -137,3 +138,14 @@ class Dirnode(unittest.TestCase):
|
|||||||
self.failIf(IFileURI.providedBy(u4))
|
self.failIf(IFileURI.providedBy(u4))
|
||||||
self.failUnless(IDirnodeURI.providedBy(u4))
|
self.failUnless(IDirnodeURI.providedBy(u4))
|
||||||
|
|
||||||
|
|
||||||
|
class Constraint(unittest.TestCase):
|
||||||
|
def test_constraint(self):
|
||||||
|
good = 'URI:DIR:pb://xextf3eap44o3wi27mf7ehiur6wvhzr6@207.7.153.180:56677,127.0.0.1:56677/vdrive:qj51rfpnukhjmo7cm9awe5ks5e'
|
||||||
|
DirnodeURI.checkObject(good, False)
|
||||||
|
bad = good + '==='
|
||||||
|
self.failUnlessRaises(Violation, DirnodeURI.checkObject, bad, False)
|
||||||
|
fileURI = 'URI:CHK:f3mf6az85wpcai8ma4qayfmxuc:nnw518w5hu3t5oohwtp7ah9n81z9rfg6c1ywk33ia3m64o67nsgo:3:10:345834'
|
||||||
|
self.failUnlessRaises(Violation, DirnodeURI.checkObject, fileURI, False)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user