def test_mdmf_from_string(self):
        # Make sure that the from_string utility function works with
        # MDMF caps.
        u1 = uri.WriteableMDMFFileURI(self.writekey, self.fingerprint)
        cap = u1.to_string()
        self.failUnless(uri.is_uri(cap))
        u2 = uri.from_string(cap)
        self.failUnlessReallyEqual(u1, u2)
        u3 = uri.from_string_mutable_filenode(cap)
        self.failUnlessEqual(u3, u1)

        u1 = uri.ReadonlyMDMFFileURI(self.readkey, self.fingerprint)
        cap = u1.to_string()
        self.failUnless(uri.is_uri(cap))
        u2 = uri.from_string(cap)
        self.failUnlessReallyEqual(u1, u2)
        u3 = uri.from_string_mutable_filenode(cap)
        self.failUnlessEqual(u3, u1)

        u1 = uri.MDMFVerifierURI(self.storage_index, self.fingerprint)
        cap = u1.to_string()
        self.failUnless(uri.is_uri(cap))
        u2 = uri.from_string(cap)
        self.failUnlessReallyEqual(u1, u2)
        u3 = uri.from_string_verifier(cap)
        self.failUnlessEqual(u3, u1)
 def test_create_writeable_mdmf_cap_from_readcap(self):
     # we shouldn't be able to create a writeable MDMF cap given only a
     # readcap.
     u1 = uri.ReadonlyMDMFFileURI(self.readkey, self.fingerprint)
     cap = u1.to_string()
     self.failUnlessRaises(uri.BadURIError,
                           uri.WriteableMDMFFileURI.init_from_string, cap)
Exemple #3
0
    def test_mdmf_valid_human_encoding(self):
        # What's a human encoding? Well, it's of the form:
        base = "https://127.0.0.1:3456/uri/"
        # With a cap on the end. For each of the cap types, we need to
        # test that a valid cap (with and without the traditional
        # separators) is recognized and accepted by the classes.
        w1 = uri.WriteableMDMFFileURI(self.writekey, self.fingerprint)
        r1 = uri.ReadonlyMDMFFileURI(self.readkey, self.fingerprint)
        v1 = uri.MDMFVerifierURI(self.storage_index, self.fingerprint)

        # These will yield three different caps.
        for o in (w1, r1, v1):
            url = base + o.to_string()
            o1 = o.__class__.init_from_human_encoding(url)
            self.failUnlessReallyEqual(o1, o)

            # Note that our cap will, by default, have : as separators.
            # But it's expected that users from, e.g., the WUI, will
            # have %3A as a separator. We need to make sure that the
            # initialization routine handles that, too.
            cap = o.to_string()
            cap = re.sub(":", "%3A", cap)
            url = base + cap
            o2 = o.__class__.init_from_human_encoding(url)
            self.failUnlessReallyEqual(o2, o)
    def test_readonly_mdmf_cap(self):
        u1 = uri.ReadonlyMDMFFileURI(self.readkey, self.fingerprint)
        cap = u1.to_string()
        u2 = uri.ReadonlyMDMFFileURI.init_from_string(cap)

        self.failUnlessReallyEqual(u2.fingerprint, self.fingerprint)
        self.failUnlessReallyEqual(u2.readkey, self.readkey)
        self.failUnless(u2.is_readonly())
        self.failUnless(u2.is_mutable())

        vu = u2.get_verify_cap()
        self.failUnlessEqual(vu.storage_index, self.storage_index)
        self.failUnlessEqual(vu.fingerprint, self.fingerprint)
Exemple #5
0
    def test_mdmf_human_encoding_invalid_base(self):
        # What's a human encoding? Well, it's of the form:
        base = "https://127.0.0.1:3456/foo/bar/bazuri/"
        # With a cap on the end. For each of the cap types, we need to
        # test that a valid cap (with and without the traditional
        # separators) is recognized and accepted by the classes.
        w1 = uri.WriteableMDMFFileURI(self.writekey, self.fingerprint)
        r1 = uri.ReadonlyMDMFFileURI(self.readkey, self.fingerprint)
        v1 = uri.MDMFVerifierURI(self.storage_index, self.fingerprint)

        # These will yield three different caps.
        for o in (w1, r1, v1):
            url = base + o.to_string()
            self.failUnlessRaises(uri.BadURIError,
                                  o.__class__.init_from_human_encoding,
                                  url)
Exemple #6
0
    def test_mdmf_human_encoding_invalid_cap(self):
        base = "https://127.0.0.1:3456/uri/"
        # With a cap on the end. For each of the cap types, we need to
        # test that a valid cap (with and without the traditional
        # separators) is recognized and accepted by the classes.
        w1 = uri.WriteableMDMFFileURI(self.writekey, self.fingerprint)
        r1 = uri.ReadonlyMDMFFileURI(self.readkey, self.fingerprint)
        v1 = uri.MDMFVerifierURI(self.storage_index, self.fingerprint)

        # These will yield three different caps.
        for o in (w1, r1, v1):
            # not exhaustive, obviously...
            url = base + o.to_string() + "foobarbaz"
            url2 = base + "foobarbaz" + o.to_string()
            url3 = base + o.to_string()[:25] + "foo" + o.to_string()[:25]
            for u in (url, url2, url3):
                self.failUnlessRaises(uri.BadURIError,
                                      o.__class__.init_from_human_encoding,
                                      u)