Exemple #1
0
def filenodes():
    """
    Build JSON-compatible descriptions of Tahoe-LAFS filenode metadata.
    """
    return fixed_dictionaries({
        "ro_uri":
        tahoe_lafs_chk_capabilities().map(
            lambda cap_text: cap_from_string(cap_text.encode("ascii"), ).
            get_readonly().to_string().decode("ascii", ), ),
        "size":
        integers(min_value=0),
        "format":
        just(u"CHK"),
        "metadata":
        fixed_dictionaries({
            "version":
            integers(min_value=0),
            "deleted":
            booleans(),
            "tahoe":
            fixed_dictionaries({
                "linkmotime":
                integers(min_value=0, max_value=2**31 - 1),
                "linkcrtime":
                integers(min_value=0, max_value=2**31 - 1),
            }),
        }),
    })
Exemple #2
0
def dirnode_json(cap_text, children):
    cap = cap_from_string(cap_text.encode("ascii"))
    info = {
        "verify_uri": cap.get_verify_cap().to_string(),
        "ro_uri": cap.get_readonly().to_string(),
        "children": children,
    }
    if cap.is_mutable():
        info["rw_uri"] = cap.to_string()
    return ["dirnode", info]
Exemple #3
0
 def test_dir_roundtrips(self, cap_text):
     """
     Values built by ``tahoe_lafs_dir_capabilities`` round-trip through ASCII
     and ``allmydata.uri.from_string`` and their ``to_string`` method.
     """
     cap = cap_from_string(cap_text.encode("ascii"))
     serialized = cap.to_string().decode("ascii")
     self.assertThat(
         cap_text,
         Equals(serialized),
     )
Exemple #4
0
def magic_folder_uri_hierarchy_from_magic_folder_json(
    folders,
    collective_dircap,
    collective_json,
    upload_dircap,
    upload_json,
    token,
):
    upload = Data(
        dumps(upload_json),
        b"text/plain",
    )
    collective = Data(
        dumps(collective_json),
        b"text/plain",
    )

    uri = Resource()
    uri.putChild(
        upload_dircap,
        upload,
    )
    uri.putChild(
        cap_from_string(
            upload_dircap.encode("ascii")).get_readonly().to_string(),
        upload,
    )
    uri.putChild(
        collective_dircap,
        collective,
    )

    api = MagicFolderWebApi(
        get_magic_folder=lambda name: folders[name.decode("utf-8")],
        get_auth_token=lambda: token,
    )

    root = Resource()
    # Unfortunately the following two resource hierarchies should live at
    # different servers.  However, we lack multi-server support in our web
    # testing library.  So, they live side-by-side.  I hope that if the
    # implementation mistakenly sends requests to the wrong server it will be
    # blindingly obvious and this test shortcoming will not hurt us much.
    root.putChild(b"uri", uri)
    root.putChild(b"api", api)

    return root