mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-27 14:50:03 +00:00
Tests pass on Python 3.
This commit is contained in:
parent
e3a844e684
commit
f99f9cf7d1
@ -334,7 +334,8 @@ def save_grid_manager(file_path, grid_manager, create=True):
|
||||
if create:
|
||||
raise
|
||||
with file_path.child("config.json").open("w") as f:
|
||||
f.write("{}\n".format(data))
|
||||
f.write(data.encode("utf-8"))
|
||||
f.write(b"\n")
|
||||
|
||||
|
||||
def parse_grid_manager_certificate(gm_data):
|
||||
@ -465,7 +466,7 @@ def create_grid_manager_verifier(keys, certs, public_key, now_fn=None, bad_cert=
|
||||
now = now_fn()
|
||||
for cert in valid_certs:
|
||||
expires = datetime.utcfromtimestamp(cert['expires'])
|
||||
if cert['public_key'] == public_key:
|
||||
if cert['public_key'].encode("ascii") == public_key:
|
||||
if expires > now:
|
||||
# not-expired
|
||||
return True
|
||||
|
@ -534,7 +534,7 @@ class _Config(object):
|
||||
|
||||
cert_fnames = list(self.enumerate_section("grid_manager_certificates").values())
|
||||
for fname in cert_fnames:
|
||||
fname = self.get_config_path(fname.decode('utf8'))
|
||||
fname = self.get_config_path(fname)
|
||||
if not os.path.exists(fname):
|
||||
raise ValueError(
|
||||
"Grid Manager certificate file '{}' doesn't exist".format(
|
||||
|
@ -3,7 +3,6 @@ from past.builtins import unicode
|
||||
from datetime import (
|
||||
timedelta,
|
||||
)
|
||||
import json
|
||||
|
||||
from twisted.python.filepath import (
|
||||
FilePath,
|
||||
@ -22,6 +21,7 @@ from allmydata.crypto import (
|
||||
)
|
||||
from allmydata.util import (
|
||||
base32,
|
||||
jsonbytes as json,
|
||||
)
|
||||
from allmydata.grid_manager import (
|
||||
load_grid_manager,
|
||||
@ -173,8 +173,8 @@ class GridManagerVerifier(SyncTestCase):
|
||||
self.assertEqual(
|
||||
ed25519.verify_signature(
|
||||
gm_key,
|
||||
base32.a2b(cert0.signature.encode("ascii")),
|
||||
cert0.certificate.encode("ascii"),
|
||||
base32.a2b(cert0.signature),
|
||||
cert0.certificate,
|
||||
),
|
||||
None
|
||||
)
|
||||
@ -251,7 +251,7 @@ class GridManagerVerifier(SyncTestCase):
|
||||
}
|
||||
fp.makedirs()
|
||||
with fp.child("config.json").open("w") as f:
|
||||
json.dump(bad_config, f)
|
||||
f.write(json.dumps_bytes(bad_config))
|
||||
|
||||
with self.assertRaises(ValueError) as ctx:
|
||||
load_grid_manager(fp)
|
||||
@ -283,9 +283,9 @@ class GridManagerVerifier(SyncTestCase):
|
||||
|
||||
fp.makedirs()
|
||||
with fp.child("config.json").open("w") as f:
|
||||
json.dump(config, f)
|
||||
f.write(json.dumps_bytes(config))
|
||||
with fp.child("alice.cert.0").open("w") as f:
|
||||
json.dump(bad_cert, f)
|
||||
f.write(json.dumps_bytes(bad_cert))
|
||||
|
||||
with self.assertRaises(ValueError) as ctx:
|
||||
load_grid_manager(fp)
|
||||
@ -306,7 +306,7 @@ class GridManagerVerifier(SyncTestCase):
|
||||
}
|
||||
fp.makedirs()
|
||||
with fp.child("config.json").open("w") as f:
|
||||
json.dump(bad_config, f)
|
||||
f.write(json.dumps_bytes(bad_config))
|
||||
|
||||
with self.assertRaises(ValueError) as ctx:
|
||||
load_grid_manager(fp)
|
||||
@ -327,7 +327,7 @@ class GridManagerVerifier(SyncTestCase):
|
||||
}
|
||||
fp.makedirs()
|
||||
with fp.child("config.json").open("w") as f:
|
||||
json.dump(bad_config, f)
|
||||
f.write(json.dumps_bytes(bad_config))
|
||||
|
||||
with self.assertRaises(ValueError) as ctx:
|
||||
load_grid_manager(fp)
|
||||
@ -352,7 +352,7 @@ class GridManagerVerifier(SyncTestCase):
|
||||
}
|
||||
fp.makedirs()
|
||||
with fp.child("config.json").open("w") as f:
|
||||
json.dump(bad_config, f)
|
||||
f.write(json.dumps_bytes(bad_config))
|
||||
|
||||
with self.assertRaises(ValueError) as ctx:
|
||||
load_grid_manager(fp)
|
||||
|
@ -559,7 +559,6 @@ class JSONBytes(unittest.TestCase):
|
||||
)
|
||||
|
||||
|
||||
|
||||
class FakeGetVersion(object):
|
||||
"""Emulate an object with a get_version."""
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user