Merge pull request #1220 from twisted/9760-windows-build-failures
Author: glyph Reviewer: cdunklau Fixes: ticket:9760 Get continuous integration working again by fixing up some minor issues related to filesystem permissions and path configuration in tests.
This commit is contained in:
commit
b719119403
|
@ -0,0 +1 @@
|
|||
|
|
@ -22,6 +22,8 @@ from twisted.python.procutils import which
|
|||
|
||||
from twisted.conch.test.keydata import publicRSA_openssh, privateRSA_openssh
|
||||
from twisted.conch.test.keydata import publicDSA_openssh, privateDSA_openssh
|
||||
from twisted.python.filepath import FilePath
|
||||
from twisted.trial.unittest import SkipTest
|
||||
|
||||
try:
|
||||
from twisted.conch.test.test_ssh import ConchTestServerFactory, \
|
||||
|
@ -145,6 +147,7 @@ class ConchTestOpenSSHProcess(protocol.ProcessProtocol):
|
|||
|
||||
deferred = None
|
||||
buf = b''
|
||||
problems = b''
|
||||
|
||||
def _getDeferred(self):
|
||||
d, self.deferred = self.deferred, None
|
||||
|
@ -155,6 +158,10 @@ class ConchTestOpenSSHProcess(protocol.ProcessProtocol):
|
|||
self.buf += data
|
||||
|
||||
|
||||
def errReceived(self, data):
|
||||
self.problems += data
|
||||
|
||||
|
||||
def processEnded(self, reason):
|
||||
"""
|
||||
Called when the process has ended.
|
||||
|
@ -163,8 +170,13 @@ class ConchTestOpenSSHProcess(protocol.ProcessProtocol):
|
|||
"""
|
||||
if reason.value.exitCode != 0:
|
||||
self._getDeferred().errback(
|
||||
ConchError("exit code was not 0: {}".format(
|
||||
reason.value.exitCode)))
|
||||
ConchError(
|
||||
"exit code was not 0: {} ({})".format(
|
||||
reason.value.exitCode,
|
||||
self.problems.decode("charmap"),
|
||||
)
|
||||
)
|
||||
)
|
||||
else:
|
||||
buf = self.buf.replace(b'\r\n', b'\n')
|
||||
self._getDeferred().callback(buf)
|
||||
|
@ -334,17 +346,24 @@ class ConchServerSetupMixin:
|
|||
'kh_test']:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
with open('rsa_test','wb') as f:
|
||||
with open('rsa_test', 'wb') as f:
|
||||
f.write(privateRSA_openssh)
|
||||
with open('rsa_test.pub','wb') as f:
|
||||
with open('rsa_test.pub', 'wb') as f:
|
||||
f.write(publicRSA_openssh)
|
||||
with open('dsa_test.pub','wb') as f:
|
||||
with open('dsa_test.pub', 'wb') as f:
|
||||
f.write(publicDSA_openssh)
|
||||
with open('dsa_test','wb') as f:
|
||||
with open('dsa_test', 'wb') as f:
|
||||
f.write(privateDSA_openssh)
|
||||
os.chmod('dsa_test', 33152)
|
||||
os.chmod('rsa_test', 33152)
|
||||
with open('kh_test','wb') as f:
|
||||
os.chmod('dsa_test', 0o600)
|
||||
os.chmod('rsa_test', 0o600)
|
||||
permissions = FilePath('dsa_test').getPermissions()
|
||||
if permissions.group.read or permissions.other.read:
|
||||
raise SkipTest(
|
||||
"private key readable by others despite chmod;"
|
||||
" possible windows permission issue?"
|
||||
" see https://tm.tl/9767"
|
||||
)
|
||||
with open('kh_test', 'wb') as f:
|
||||
f.write(b'127.0.0.1 '+publicRSA_openssh)
|
||||
|
||||
|
||||
|
|
|
@ -243,10 +243,7 @@ class ProcessUtilsTests(unittest.TestCase):
|
|||
# the trial temporary directory.
|
||||
self.addCleanup(os.chmod, dir, originalMode)
|
||||
|
||||
# Pass in -S so that if run using the coverage .pth trick, it won't be
|
||||
# loaded and cause Coverage to try and get the current working
|
||||
# directory (see the comments above why this can be a problem) on OSX.
|
||||
d = utilFunc(self.exe, ['-S', '-u', scriptFile])
|
||||
d = utilFunc(self.exe, ['-u', scriptFile])
|
||||
d.addCallback(check, dir.encode(sys.getfilesystemencoding()))
|
||||
return d
|
||||
|
||||
|
|
Loading…
Reference in New Issue