Exemplo n.º 1
0
    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)
Exemplo n.º 2
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)
Exemplo n.º 3
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)
Exemplo n.º 4
0
    def test_mdmf_verifier_cap(self):
        u1 = uri.MDMFVerifierURI(self.storage_index, self.fingerprint)
        self.failUnless(u1.is_readonly())
        self.failIf(u1.is_mutable())
        self.failUnlessReallyEqual(self.storage_index, u1.storage_index)
        self.failUnlessReallyEqual(self.fingerprint, u1.fingerprint)

        cap = u1.to_string()
        u2 = uri.MDMFVerifierURI.init_from_string(cap)
        self.failUnless(u2.is_readonly())
        self.failIf(u2.is_mutable())
        self.failUnlessReallyEqual(self.storage_index, u2.storage_index)
        self.failUnlessReallyEqual(self.fingerprint, u2.fingerprint)

        u3 = u2.get_readonly()
        self.failUnlessReallyEqual(u3, u2)

        u4 = u2.get_verify_cap()
        self.failUnlessReallyEqual(u4, u2)
Exemplo n.º 5
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)
Exemplo n.º 6
0
 def test_create_readonly_mdmf_cap_from_verifycap(self):
     u1 = uri.MDMFVerifierURI(self.storage_index, self.fingerprint)
     cap = u1.to_string()
     self.failUnlessRaises(uri.BadURIError,
                           uri.ReadonlyMDMFFileURI.init_from_string, cap)