mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-02-25 19:21:36 +00:00
Tests pass on Python 3.
This commit is contained in:
parent
aacdf9906d
commit
6bfcda2a3d
@ -1,10 +1,10 @@
|
||||
from __future__ import print_function
|
||||
from past.builtins import unicode
|
||||
|
||||
from datetime import (
|
||||
datetime,
|
||||
timedelta,
|
||||
)
|
||||
import json
|
||||
|
||||
import click
|
||||
|
||||
@ -23,6 +23,7 @@ from allmydata.grid_manager import (
|
||||
save_grid_manager,
|
||||
load_grid_manager,
|
||||
)
|
||||
from allmydata.util import jsonbytes as json
|
||||
|
||||
|
||||
@click.group()
|
||||
@ -102,7 +103,7 @@ def public_identity(config):
|
||||
|
||||
@grid_manager.command()
|
||||
@click.argument("name")
|
||||
@click.argument("public_key", type=click.UNPROCESSED)
|
||||
@click.argument("public_key", type=click.STRING)
|
||||
@click.pass_context
|
||||
def add(ctx, name, public_key):
|
||||
"""
|
||||
@ -160,7 +161,9 @@ def list(ctx):
|
||||
"""
|
||||
for name in sorted(ctx.obj.grid_manager.storage_servers.keys()):
|
||||
blank_name = " " * len(name)
|
||||
click.echo("{}: {}".format(name, ctx.obj.grid_manager.storage_servers[name].public_key_string()))
|
||||
click.echo("{}: {}".format(
|
||||
name,
|
||||
unicode(ctx.obj.grid_manager.storage_servers[name].public_key_string(), "utf-8")))
|
||||
for cert in ctx.obj.grid_manager.storage_servers[name].certificates:
|
||||
delta = datetime.utcnow() - cert.expires
|
||||
click.echo("{} cert {}: ".format(blank_name, cert.index), nl=False)
|
||||
@ -209,7 +212,7 @@ def sign(ctx, name, expiry_days):
|
||||
)
|
||||
next_serial += 1
|
||||
with f:
|
||||
f.write(certificate_data)
|
||||
f.write(certificate_data.encode("ascii"))
|
||||
|
||||
|
||||
def _config_path_from_option(config):
|
||||
|
@ -1,7 +1,6 @@
|
||||
from future.utils import raise_
|
||||
|
||||
import os
|
||||
import json
|
||||
from io import (
|
||||
BytesIO,
|
||||
)
|
||||
@ -31,6 +30,7 @@ from twisted.python.filepath import (
|
||||
from twisted.python.runtime import (
|
||||
platform,
|
||||
)
|
||||
from allmydata.util import jsonbytes as json
|
||||
|
||||
|
||||
class GridManagerCommandLine(TestCase):
|
||||
@ -66,8 +66,8 @@ class GridManagerCommandLine(TestCase):
|
||||
An invalid config is reported to the user
|
||||
"""
|
||||
with self.runner.isolated_filesystem():
|
||||
with open("config.json", "w") as f:
|
||||
json.dump({"not": "valid"}, f)
|
||||
with open("config.json", "wb") as f:
|
||||
f.write(json.dumps_bytes({"not": "valid"}))
|
||||
result = self.runner.invoke(grid_manager, ["--config", ".", "public-identity"])
|
||||
self.assertNotEqual(result.exit_code, 0)
|
||||
self.assertIn(
|
||||
@ -117,7 +117,7 @@ class GridManagerCommandLine(TestCase):
|
||||
}
|
||||
result = self.invoke_and_check(
|
||||
grid_manager, ["--config", "-", "list"],
|
||||
input=BytesIO(json.dumps(config)),
|
||||
input=BytesIO(json.dumps_bytes(config)),
|
||||
)
|
||||
self.assertEqual(result.exit_code, 0)
|
||||
self.assertEqual(
|
||||
@ -260,7 +260,7 @@ class TahoeAddGridManagerCert(TestCase):
|
||||
"""
|
||||
code, out, err = yield run_cli(
|
||||
"admin", "add-grid-manager-cert", "--filename", "-",
|
||||
stdin="the cert",
|
||||
stdin=b"the cert",
|
||||
)
|
||||
self.assertIn(
|
||||
"Must provide --name",
|
||||
@ -274,7 +274,7 @@ class TahoeAddGridManagerCert(TestCase):
|
||||
"""
|
||||
code, out, err = yield run_cli(
|
||||
"admin", "add-grid-manager-cert", "--name", "foo",
|
||||
stdin="the cert",
|
||||
stdin=b"the cert",
|
||||
)
|
||||
self.assertIn(
|
||||
"Must provide --filename",
|
||||
@ -287,7 +287,7 @@ class TahoeAddGridManagerCert(TestCase):
|
||||
we can add a certificate
|
||||
"""
|
||||
nodedir = self.mktemp()
|
||||
fake_cert = """{"certificate": "", "signature": ""}"""
|
||||
fake_cert = b"""{"certificate": "", "signature": ""}"""
|
||||
|
||||
code, out, err = yield run_cli(
|
||||
"--node-directory", nodedir,
|
||||
@ -301,7 +301,7 @@ class TahoeAddGridManagerCert(TestCase):
|
||||
|
||||
self.assertIn("tahoe.cfg", nodepath.listdir())
|
||||
self.assertIn(
|
||||
"foo = foo.cert",
|
||||
b"foo = foo.cert",
|
||||
config_data,
|
||||
)
|
||||
self.assertIn("foo.cert", nodepath.listdir())
|
||||
|
Loading…
x
Reference in New Issue
Block a user