mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-18 18:56:28 +00:00
webapi: add verifycap (spelled 'verify_url') to the t=json output on files and directories. Closes #559.
This commit is contained in:
parent
91a28da3aa
commit
4e572a5f24
@ -377,6 +377,7 @@ GET /uri/$DIRCAP/[SUBDIRS../]FILENAME?t=json
|
||||
GET /uri/$DIRCAP/[SUBDIRS../]FILENAME?t=json :
|
||||
|
||||
[ "filenode", { "ro_uri": file_uri,
|
||||
"verify_uri": verify_uri,
|
||||
"size": bytes,
|
||||
"mutable": false,
|
||||
"metadata": {"ctime": 1202777696.7564139,
|
||||
@ -396,6 +397,7 @@ GET /uri/$DIRCAP/[SUBDIRS../]FILENAME?t=json
|
||||
|
||||
[ "dirnode", { "rw_uri": read_write_uri,
|
||||
"ro_uri": read_only_uri,
|
||||
"verify_uri": verify_uri,
|
||||
"mutable": true,
|
||||
"children": {
|
||||
"foo.txt": [ "filenode", { "ro_uri": uri,
|
||||
@ -422,7 +424,9 @@ GET /uri/$DIRCAP/[SUBDIRS../]FILENAME?t=json
|
||||
that is stored on the directory edge).
|
||||
|
||||
Then the rw_uri field will be present in the information about a directory
|
||||
if and only if you have read-write access to that directory,
|
||||
if and only if you have read-write access to that directory. The verify_uri
|
||||
field will be presend if and only if the object has a verify-cap
|
||||
(non-distributed LIT files do not have verify-caps).
|
||||
|
||||
|
||||
=== Attaching an existing File or Directory by its read- or write- cap ===
|
||||
|
@ -173,6 +173,8 @@ class FakeMutableFileNode:
|
||||
return self.my_uri.get_readonly()
|
||||
def get_readonly_uri(self):
|
||||
return self.my_uri.get_readonly().to_string()
|
||||
def get_verify_cap(self):
|
||||
return self.my_uri.get_verify_cap()
|
||||
def is_readonly(self):
|
||||
return self.my_uri.is_readonly()
|
||||
def is_mutable(self):
|
||||
|
@ -146,12 +146,14 @@ class WebMixin(object):
|
||||
self._foo_node = foo
|
||||
self._foo_uri = foo.get_uri()
|
||||
self._foo_readonly_uri = foo.get_readonly_uri()
|
||||
self._foo_verifycap = foo.get_verify_cap().to_string()
|
||||
# NOTE: we ignore the deferred on all set_uri() calls, because we
|
||||
# know the fake nodes do these synchronously
|
||||
self.public_root.set_uri(u"foo", foo.get_uri())
|
||||
|
||||
self.BAR_CONTENTS, n, self._bar_txt_uri = self.makefile(0)
|
||||
foo.set_uri(u"bar.txt", self._bar_txt_uri)
|
||||
self._bar_txt_verifycap = n.get_verify_cap().to_string()
|
||||
|
||||
foo.set_uri(u"empty", res[3][1].get_uri())
|
||||
sub_uri = res[4][1].get_uri()
|
||||
@ -216,6 +218,7 @@ class WebMixin(object):
|
||||
self.failIf(data[1]["mutable"])
|
||||
self.failIf("rw_uri" in data[1]) # immutable
|
||||
self.failUnlessEqual(data[1]["ro_uri"], self._bar_txt_uri)
|
||||
self.failUnlessEqual(data[1]["verify_uri"], self._bar_txt_verifycap)
|
||||
self.failUnlessEqual(data[1]["size"], len(self.BAR_CONTENTS))
|
||||
|
||||
def failUnlessIsFooJSON(self, res):
|
||||
@ -227,6 +230,7 @@ class WebMixin(object):
|
||||
self.failUnless("rw_uri" in data[1]) # mutable
|
||||
self.failUnlessEqual(data[1]["rw_uri"], self._foo_uri)
|
||||
self.failUnlessEqual(data[1]["ro_uri"], self._foo_readonly_uri)
|
||||
self.failUnlessEqual(data[1]["verify_uri"], self._foo_verifycap)
|
||||
|
||||
kidnames = sorted([unicode(n) for n in data[1]["children"]])
|
||||
self.failUnlessEqual(kidnames,
|
||||
@ -242,6 +246,8 @@ class WebMixin(object):
|
||||
self.failUnlessEqual(kids[u"bar.txt"][0], "filenode")
|
||||
self.failUnlessEqual(kids[u"bar.txt"][1]["size"], len(self.BAR_CONTENTS))
|
||||
self.failUnlessEqual(kids[u"bar.txt"][1]["ro_uri"], self._bar_txt_uri)
|
||||
self.failUnlessEqual(kids[u"bar.txt"][1]["verify_uri"],
|
||||
self._bar_txt_verifycap)
|
||||
self.failUnlessEqual(kids[u"bar.txt"][1]["metadata"]["ctime"],
|
||||
self._bar_txt_metadata["ctime"])
|
||||
self.failUnlessEqual(kids[u"n\u00fc.txt"][1]["ro_uri"],
|
||||
|
@ -671,6 +671,9 @@ def DirectoryJSONMetadata(ctx, dirnode):
|
||||
kiddata[1]["ro_uri"] = ro_uri
|
||||
if rw_uri:
|
||||
kiddata[1]["rw_uri"] = rw_uri
|
||||
verifycap = childnode.get_verify_cap()
|
||||
if verifycap:
|
||||
kiddata[1]['verify_uri'] = verifycap.to_string()
|
||||
kiddata[1]['mutable'] = childnode.is_mutable()
|
||||
kids[name] = kiddata
|
||||
if dirnode.is_readonly():
|
||||
@ -684,6 +687,9 @@ def DirectoryJSONMetadata(ctx, dirnode):
|
||||
contents['ro_uri'] = dro_uri
|
||||
if drw_uri:
|
||||
contents['rw_uri'] = drw_uri
|
||||
verifycap = dirnode.get_verify_cap()
|
||||
if verifycap:
|
||||
contents['verify_uri'] = verifycap.to_string()
|
||||
contents['mutable'] = dirnode.is_mutable()
|
||||
data = ("dirnode", contents)
|
||||
return simplejson.dumps(data, indent=1) + "\n"
|
||||
|
@ -432,6 +432,9 @@ def FileJSONMetadata(ctx, filenode):
|
||||
data[1]['ro_uri'] = ro_uri
|
||||
if rw_uri:
|
||||
data[1]['rw_uri'] = rw_uri
|
||||
verifycap = filenode.get_verify_cap()
|
||||
if verifycap:
|
||||
data[1]['verify_uri'] = verifycap.to_string()
|
||||
data[1]['mutable'] = filenode.is_mutable()
|
||||
return text_plain(simplejson.dumps(data, indent=1) + "\n", ctx)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user