mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-02-21 18:06:46 +00:00
Start making tests pass on Python 3.
This commit is contained in:
parent
1f70d5c13a
commit
d3be3ce1e6
@ -1,5 +1,7 @@
|
||||
from __future__ import print_function
|
||||
|
||||
from past.builtins import unicode
|
||||
|
||||
try:
|
||||
from allmydata.scripts.types_ import SubCommands
|
||||
except ImportError:
|
||||
@ -22,8 +24,10 @@ def print_keypair(options):
|
||||
from allmydata.crypto import ed25519
|
||||
out = options.stdout
|
||||
private_key, public_key = ed25519.create_signing_keypair()
|
||||
print("private:", ed25519.string_from_signing_key(private_key), file=out)
|
||||
print("public:", ed25519.string_from_verifying_key(public_key), file=out)
|
||||
print("private:", unicode(ed25519.string_from_signing_key(private_key), "ascii"),
|
||||
file=out)
|
||||
print("public:", unicode(ed25519.string_from_verifying_key(public_key), "ascii"),
|
||||
file=out)
|
||||
|
||||
class DerivePubkeyOptions(BaseOptions):
|
||||
def parseArgs(self, privkey):
|
||||
@ -45,9 +49,10 @@ def derive_pubkey(options):
|
||||
out = options.stdout
|
||||
from allmydata.crypto import ed25519
|
||||
privkey_vs = options.privkey
|
||||
private_key, public_key = ed25519.signing_keypair_from_string(privkey_vs)
|
||||
print("private:", ed25519.string_from_signing_key(private_key), file=out)
|
||||
print("public:", ed25519.string_from_verifying_key(public_key), file=out)
|
||||
private_key, public_key = ed25519.signing_keypair_from_string(
|
||||
privkey_vs.encode("ascii"))
|
||||
print("private:", unicode(ed25519.string_from_signing_key(private_key), "ascii"), file=out)
|
||||
print("public:", unicode(ed25519.string_from_verifying_key(public_key), "ascii"), file=out)
|
||||
return 0
|
||||
|
||||
class AdminCommand(BaseOptions):
|
||||
|
@ -1,3 +1,5 @@
|
||||
from past.builtins import unicode
|
||||
|
||||
import os.path
|
||||
from six.moves import cStringIO as StringIO
|
||||
import urllib, sys
|
||||
@ -718,8 +720,9 @@ class Admin(unittest.TestCase):
|
||||
self.failUnlessEqual(pubkey_bits[0], vk_header, lines[1])
|
||||
self.failUnless(privkey_bits[1].startswith("priv-v0-"), lines[0])
|
||||
self.failUnless(pubkey_bits[1].startswith("pub-v0-"), lines[1])
|
||||
sk, pk = ed25519.signing_keypair_from_string(privkey_bits[1])
|
||||
vk_bytes = pubkey_bits[1]
|
||||
sk, pk = ed25519.signing_keypair_from_string(
|
||||
privkey_bits[1].encode("ascii"))
|
||||
vk_bytes = pubkey_bits[1].encode("ascii")
|
||||
self.assertEqual(
|
||||
ed25519.string_from_verifying_key(pk),
|
||||
vk_bytes,
|
||||
@ -729,8 +732,8 @@ class Admin(unittest.TestCase):
|
||||
|
||||
def test_derive_pubkey(self):
|
||||
priv_key, pub_key = ed25519.create_signing_keypair()
|
||||
priv_key_str = ed25519.string_from_signing_key(priv_key)
|
||||
pub_key_str = ed25519.string_from_verifying_key(pub_key)
|
||||
priv_key_str = unicode(ed25519.string_from_signing_key(priv_key), "ascii")
|
||||
pub_key_str = unicode(ed25519.string_from_verifying_key(pub_key), "ascii")
|
||||
d = run_cli("admin", "derive-pubkey", priv_key_str)
|
||||
def _done(args):
|
||||
(rc, stdout, stderr) = args
|
||||
|
Loading…
x
Reference in New Issue
Block a user