use real parser

This commit is contained in:
meejah 2020-06-12 22:57:38 -06:00 committed by Sajith Sasidharan
parent 683c8d3e4f
commit 9d5e438c2d
2 changed files with 9 additions and 4 deletions

View File

@ -15,6 +15,10 @@ from twisted.internet.defer import (
inlineCallbacks, inlineCallbacks,
) )
from allmydata.uri import (
from_string,
CHKFileURI,
)
from allmydata.testing.web import ( from allmydata.testing.web import (
create_tahoe_treq_client, create_tahoe_treq_client,
) )
@ -60,11 +64,12 @@ class FakeWebTest(TestCase):
resp = yield self.http_client.put("http://example.com/uri", content) resp = yield self.http_client.put("http://example.com/uri", content)
self.assertEqual(resp.code, 201) self.assertEqual(resp.code, 201)
cap = yield resp.content() cap_raw = yield resp.content()
self.assertTrue(cap.startswith("URI:CHK:")) cap = from_string(cap_raw)
self.assertIsInstance(cap, CHKFileURI)
resp = yield self.http_client.get( resp = yield self.http_client.get(
"http://example.com/uri?uri={}".format(cap) "http://example.com/uri?uri={}".format(cap.to_string())
) )
self.assertEqual(resp.code, 200) self.assertEqual(resp.code, 200)

View File

@ -90,7 +90,7 @@ def capability_generator(kind):
key = base32.b2a(key_hasher.digest()[:16]) # key is 16 bytes key = base32.b2a(key_hasher.digest()[:16]) # key is 16 bytes
ueb_hash = base32.b2a(ueb_hasher.digest()) # ueb hash is 32 bytes ueb_hash = base32.b2a(ueb_hasher.digest()) # ueb hash is 32 bytes
cap = u"{kind}:{key}:{ueb_hash}:{n}:{k}:{size}".format( cap = u"{kind}{key}:{ueb_hash}:{n}:{k}:{size}".format(
kind=kind, kind=kind,
key=key, key=key,
ueb_hash=ueb_hash, ueb_hash=ueb_hash,