from allmydata import uri
from allmydata.util.idlib import a2b
from base64 import b32decode
+ import urlparse, urllib
cap = config.cap
- u = uri.from_string(cap)
nodeid = None
if config['nodeid']:
nodeid = b32decode(config['nodeid'].upper())
except EnvironmentError:
pass
+ if cap.startswith("http"):
+ scheme, netloc, path, params, query, fragment = urlparse.urlparse(cap)
+ assert path.startswith("/uri/")
+ cap = urllib.unquote(path[len("/uri/"):])
+
+ u = uri.from_string(cap)
+
print >>out
dump_uri_instance(u, nodeid, secret, out, err)
from twisted.trial import unittest
from cStringIO import StringIO
+import urllib
from allmydata.util import fileutil, hashutil
from allmydata import uri
self.failUnless("k/N: 25/100" in output)
self.failUnless("storage index: p3w849k9whqhw6b9fkf4xjs5xc" in output)
+ prefixed_u = "http://127.0.0.1/uri/%s" % urllib.quote(u.to_string())
+ output = self._dump_cap(prefixed_u)
+ self.failUnless("CHK File:" in output)
+ self.failUnless("key: yyyoryarywdyqnyjbefoadeqbh" in output)
+ self.failUnless("UEB hash: hd7rwri6djiapo6itg5hcxa7ze5im7z9qwcdu8oka6qinahsbiuo" in output)
+ self.failUnless("size: 1234" in output)
+ self.failUnless("k/N: 25/100" in output)
+ self.failUnless("storage index: p3w849k9whqhw6b9fkf4xjs5xc" in output)
+
def test_dump_cap_lit(self):
u = uri.LiteralFileURI("this is some data")
output = self._dump_cap(u.to_string())