]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
webapi: add verifycap (spelled 'verify_url') to the t=json output on files and direct...
authorBrian Warner <warner@allmydata.com>
Wed, 4 Feb 2009 02:22:48 +0000 (19:22 -0700)
committerBrian Warner <warner@allmydata.com>
Wed, 4 Feb 2009 02:22:48 +0000 (19:22 -0700)
docs/frontends/webapi.txt
src/allmydata/test/common.py
src/allmydata/test/test_web.py
src/allmydata/web/directory.py
src/allmydata/web/filenode.py

index 86da8807518f437221e1ba4d4868a1c6bfb55ee2..46eaf77f3fdeab4276c3a51eb1809c5e20e92ea6 100644 (file)
@@ -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 ===
index 5c40ba3e4e35f7ebd9c29f02a4363cd62d1b0d41..50ca7a823c39cd1fecd088b29b2b84566443c78b 100644 (file)
@@ -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):
index 5967e41d3ee7ca6b630cc0d0f247e84b29c4a56b..381441e8b7a4cf6d8e901f8c521e99c906f2e0a3 100644 (file)
@@ -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"],
index a4c401f6024f30d4614193b80e5b0e28cdfb414c..2f00f08827b0bfa74f9ca623ddfadeee74e83d77 100644 (file)
@@ -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"
index 36f8922150c763ff17ea3417ddca5d02cca273f5..a5a6976d4026b9e330e353518db77389587f7d7f 100644 (file)
@@ -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)