mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-02-21 10:01:54 +00:00
Merge pull request #1001 from tahoe-lafs/3635.tests-python-3
Port more tests to Python 3 Fixes ticket:3635
This commit is contained in:
commit
6f40bd1da1
0
newsfragments/3635.minor
Normal file
0
newsfragments/3635.minor
Normal 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]
|
||||||
|
@ -1,4 +1,11 @@
|
|||||||
# Python 2 compatibility
|
"""
|
||||||
|
Ported to Python 3.
|
||||||
|
"""
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from __future__ import division
|
||||||
|
from __future__ import print_function
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from future.utils import PY2
|
from future.utils import PY2
|
||||||
if PY2:
|
if PY2:
|
||||||
from future.builtins import str # noqa: F401
|
from future.builtins import str # noqa: F401
|
||||||
@ -35,7 +42,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):
|
||||||
"""
|
"""
|
||||||
|
@ -1,5 +1,17 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
"""
|
||||||
|
Ported to Python 3.
|
||||||
|
"""
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from __future__ import division
|
||||||
|
from __future__ import print_function
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from future.utils import PY2
|
||||||
|
if PY2:
|
||||||
|
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
|
||||||
|
|
||||||
import os, shutil
|
import os, shutil
|
||||||
from twisted.trial import unittest
|
from twisted.trial import unittest
|
||||||
from twisted.internet import defer
|
from twisted.internet import defer
|
||||||
@ -14,8 +26,8 @@ from allmydata.test.common import ShouldFailMixin
|
|||||||
from allmydata.util.pollmixin import PollMixin
|
from allmydata.util.pollmixin import PollMixin
|
||||||
from allmydata.interfaces import NotEnoughSharesError
|
from allmydata.interfaces import NotEnoughSharesError
|
||||||
|
|
||||||
immutable_plaintext = "data" * 10000
|
immutable_plaintext = b"data" * 10000
|
||||||
mutable_plaintext = "muta" * 10000
|
mutable_plaintext = b"muta" * 10000
|
||||||
|
|
||||||
class HungServerDownloadTest(GridTestMixin, ShouldFailMixin, PollMixin,
|
class HungServerDownloadTest(GridTestMixin, ShouldFailMixin, PollMixin,
|
||||||
unittest.TestCase):
|
unittest.TestCase):
|
||||||
@ -105,7 +117,7 @@ class HungServerDownloadTest(GridTestMixin, ShouldFailMixin, PollMixin,
|
|||||||
self.shares = self.find_uri_shares(self.uri)
|
self.shares = self.find_uri_shares(self.uri)
|
||||||
d.addCallback(_uploaded_mutable)
|
d.addCallback(_uploaded_mutable)
|
||||||
else:
|
else:
|
||||||
data = upload.Data(immutable_plaintext, convergence="")
|
data = upload.Data(immutable_plaintext, convergence=b"")
|
||||||
d = self.c0.upload(data)
|
d = self.c0.upload(data)
|
||||||
def _uploaded_immutable(upload_res):
|
def _uploaded_immutable(upload_res):
|
||||||
self.uri = upload_res.get_uri()
|
self.uri = upload_res.get_uri()
|
||||||
@ -262,7 +274,7 @@ class HungServerDownloadTest(GridTestMixin, ShouldFailMixin, PollMixin,
|
|||||||
# is shut off. That will leave 4 OVERDUE and 1
|
# is shut off. That will leave 4 OVERDUE and 1
|
||||||
# stuck-but-not-overdue, for a total of 5 requests in in
|
# stuck-but-not-overdue, for a total of 5 requests in in
|
||||||
# _sf.pending_requests
|
# _sf.pending_requests
|
||||||
for t in self._sf.overdue_timers.values()[:4]:
|
for t in list(self._sf.overdue_timers.values())[:4]:
|
||||||
t.reset(-1.0)
|
t.reset(-1.0)
|
||||||
# the timers ought to fire before the eventual-send does
|
# the timers ought to fire before the eventual-send does
|
||||||
return fireEventually()
|
return fireEventually()
|
||||||
|
@ -154,6 +154,7 @@ PORTED_TEST_MODULES = [
|
|||||||
"allmydata.test.mutable.test_update",
|
"allmydata.test.mutable.test_update",
|
||||||
"allmydata.test.mutable.test_version",
|
"allmydata.test.mutable.test_version",
|
||||||
"allmydata.test.test_abbreviate",
|
"allmydata.test.test_abbreviate",
|
||||||
|
"allmydata.test.test_auth",
|
||||||
"allmydata.test.test_base32",
|
"allmydata.test.test_base32",
|
||||||
"allmydata.test.test_base62",
|
"allmydata.test.test_base62",
|
||||||
"allmydata.test.test_checker",
|
"allmydata.test.test_checker",
|
||||||
@ -182,6 +183,7 @@ PORTED_TEST_MODULES = [
|
|||||||
"allmydata.test.test_hashutil",
|
"allmydata.test.test_hashutil",
|
||||||
"allmydata.test.test_helper",
|
"allmydata.test.test_helper",
|
||||||
"allmydata.test.test_humanreadable",
|
"allmydata.test.test_humanreadable",
|
||||||
|
"allmydata.test.test_hung_server",
|
||||||
"allmydata.test.test_immutable",
|
"allmydata.test.test_immutable",
|
||||||
"allmydata.test.test_introducer",
|
"allmydata.test.test_introducer",
|
||||||
"allmydata.test.test_iputil",
|
"allmydata.test.test_iputil",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user