Tests pass on Python 3.

This commit is contained in:
Itamar Turner-Trauring 2021-03-15 10:50:00 -04:00
parent 9f31e119bc
commit dee9f622a9
2 changed files with 9 additions and 8 deletions

View File

@ -7,6 +7,7 @@ from twisted.cred import error, checkers, credentials
from twisted.conch.ssh import keys from twisted.conch.ssh import keys
from twisted.conch.checkers import SSHPublicKeyChecker, InMemorySSHKeyDB from twisted.conch.checkers import SSHPublicKeyChecker, InMemorySSHKeyDB
from allmydata.util.dictutil import BytesKeyDict
from allmydata.util import base32 from allmydata.util import base32
from allmydata.util.fileutil import abspath_expanduser_unicode from allmydata.util.fileutil import abspath_expanduser_unicode
@ -28,18 +29,18 @@ class AccountFileChecker(object):
credentials.ISSHPrivateKey) credentials.ISSHPrivateKey)
def __init__(self, client, accountfile): def __init__(self, client, accountfile):
self.client = client self.client = client
self.passwords = {} self.passwords = BytesKeyDict()
pubkeys = {} pubkeys = BytesKeyDict()
self.rootcaps = {} self.rootcaps = BytesKeyDict()
with open(abspath_expanduser_unicode(accountfile), "r") as f: with open(abspath_expanduser_unicode(accountfile), "rb") as f:
for line in f: for line in f:
line = line.strip() line = line.strip()
if line.startswith("#") or not line: if line.startswith(b"#") or not line:
continue continue
name, passwd, rest = line.split(None, 2) name, passwd, rest = line.split(None, 2)
if passwd.startswith("ssh-"): if passwd.startswith(b"ssh-"):
bits = rest.split() bits = rest.split()
keystring = " ".join([passwd] + bits[:-1]) keystring = b" ".join([passwd] + bits[:-1])
key = keys.Key.fromString(keystring) key = keys.Key.fromString(keystring)
rootcap = bits[-1] rootcap = bits[-1]
pubkeys[name] = [key] pubkeys[name] = [key]

View File

@ -35,7 +35,7 @@ DUMMY_ACCOUNTS = u"""\
alice password URI:DIR2:aaaaaaaaaaaaaaaaaaaaaaaaaa:1111111111111111111111111111111111111111111111111111 alice password URI:DIR2:aaaaaaaaaaaaaaaaaaaaaaaaaa:1111111111111111111111111111111111111111111111111111
bob sekrit URI:DIR2:bbbbbbbbbbbbbbbbbbbbbbbbbb:2222222222222222222222222222222222222222222222222222 bob sekrit URI:DIR2:bbbbbbbbbbbbbbbbbbbbbbbbbb:2222222222222222222222222222222222222222222222222222
carol {key} URI:DIR2:cccccccccccccccccccccccccc:3333333333333333333333333333333333333333333333333333 carol {key} URI:DIR2:cccccccccccccccccccccccccc:3333333333333333333333333333333333333333333333333333
""".format(key=DUMMY_KEY.public().toString("openssh")).encode("ascii") """.format(key=str(DUMMY_KEY.public().toString("openssh"), "ascii")).encode("ascii")
class AccountFileCheckerKeyTests(unittest.TestCase): class AccountFileCheckerKeyTests(unittest.TestCase):
""" """